Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rostopic pub completion wrong for dynamic arrays of type duration/time (was: publishing time or duration arrays with rostopic fails) #252

Open
cyborg-x1 opened this issue Jul 12, 2013 · 8 comments
Labels
Milestone

Comments

@cyborg-x1
Copy link

Currently stumbled upon this, I tried to send every built in message type in one message and those also in arrays. But it only works in rostopic when I remove the time and duration arrays from my message. Currently I do not have a cpp or python program, cause I only want to get the char array from that message with wireshark for developing rosc, so I can't say if anything else than rostopic is affected.

Command (it's the one suggested by autocomplete, just changed some values), it also does the same error with the unchanged suggestion. (ROS Version Groovy, Kubuntu 13.04)

rostopic pub /test rosc_linux_test/testbuiltin "tbi_int8: 2
tbi_int16: 3
tbi_int32: 40
tbi_int64: 50
tbi_uint8: 60
tbi_uint16: 70
tbi_uint32: 80
tbi_uint64: 90
tbi_float32: 30.40
tbi_float64: 120.20
tbi_bool: true
tbi_string: 'testing'
tbi_time: {secs: 1212, nsecs: 1212}
tbi_duration: {secs: 121, nsecs: 1}
tbi_int8_A: [1]
tbi_int16_A: [1, 2]
tbi_int32_A: [3,4]
tbi_int64_A: [8,9]
tbi_uint8_A: '45454'
tbi_uint16_A: [5]
tbi_uint32_A: [234, 234234]
tbi_uint64_A: [234234]
tbi_float32_A: [3.344, 2.344]
tbi_float64_A: [10815]
tbi_bool_A: [false]
tbi_string_A: ['narf']
tbi_time_A:

  • {secs: 9, nsecs: 1}
  • {secs: 4, nsecs: 5}
    tbi_duration_A:
  • data: {secs: 2, nsecs: 3}
    t_nbi_sub: {tbi_tm_bool: false, tbi_tm_int8: 1}
    t_nbi_sub_A:
  • {tbi_tm_bool: true, tbi_tm_int8: 2}
  • {tbi_tm_bool: false, tbi_tm_int8: 1}"

Traceback (most recent call last):
File "/opt/ros/groovy/bin/rostopic", line 35, in
rostopic.rostopicmain()
File "/opt/ros/groovy/lib/python2.7/dist-packages/rostopic/init.py", line 1654, in rostopicmain
_rostopic_cmd_pub(argv)
File "/opt/ros/groovy/lib/python2.7/dist-packages/rostopic/init.py", line 1330, in _rostopic_cmd_pub
argv_publish(pub, msg_class, pub_args, rate, options.once, options.verbose)
File "/opt/ros/groovy/lib/python2.7/dist-packages/rostopic/init.py", line 1354, in argv_publish
publish_message(pub, msg_class, pub_args, rate, once, verbose=verbose)
File "/opt/ros/groovy/lib/python2.7/dist-packages/rostopic/init.py", line 1224, in publish_message
genpy.message.fill_message_args(msg, pub_args, keys=keys)
File "/opt/ros/groovy/lib/python2.7/dist-packages/genpy/message.py", line 513, in fill_message_args
_fill_message_args(msg, msg_args[0], keys, '')
File "/opt/ros/groovy/lib/python2.7/dist-packages/genpy/message.py", line 461, in _fill_message_args
_fill_val(msg, f, v, keys, prefix)
File "/opt/ros/groovy/lib/python2.7/dist-packages/genpy/message.py", line 425, in _fill_val
list_msg_class = get_message_class(base_type)
File "/opt/ros/groovy/lib/python2.7/dist-packages/genpy/message.py", line 570, in get_message_class
cls = _get_message_or_service_class('msg', message_type, reload_on_error=reload_on_error)
File "/opt/ros/groovy/lib/python2.7/dist-packages/genpy/message.py", line 532, in _get_message_or_service_class
raise ValueError("message type is missing package name: %s"%str(message_type))
ValueError: message type is missing package name: duration

@dirk-thomas
Copy link
Member

Please provide a reproducible command which fails for you. The above command seems to be incomplete or formatted incorrectly.

@cyborg-x1
Copy link
Author

Oh github interpreted the "-" as list. Now it should be correct

According to the last line of the error message, rostopic seems to think duration (also same for time, when I remove the duration array) is a "custom" type message

ValueError("message type is missing package name: %s"%str(message_type)) ValueError: message type is missing package name: duration

Here is the full message specification:

#Integer
int8 tbi_int8
int16 tbi_int16
int32 tbi_int32
int64 tbi_int64

#Unsigned Integer
uint8 tbi_uint8
uint16 tbi_uint16
uint32 tbi_uint32
uint64 tbi_uint64

#Float
float32 tbi_float32
float64 tbi_float64

#Bool
bool tbi_bool

#String
string tbi_string

#Time
time tbi_time

#Duration
duration tbi_duration

#Integer
int8[] tbi_int8_A
int16[2] tbi_int16_A
int32[] tbi_int32_A
int64[] tbi_int64_A

#Unsigned Integer
uint8[] tbi_uint8_A
uint16[] tbi_uint16_A
uint32[2] tbi_uint32_A
uint64[] tbi_uint64_A

#Float
float32[2] tbi_float32_A
float64[] tbi_float64_A

#Bool
bool[] tbi_bool_A

#String
string[] tbi_string_A

#Time
time[2] tbi_time_A

#Duration
duration[] tbi_duration_A

testsubmessage t_nbi_sub
testsubmessage[2] t_nbi_sub_A

testsubmessage

bool tbi_tm_bool
int8 tbi_tm_int8

When I comment the following lines:
time[2] tbi_time_A
duration[] tbi_duration_A

Everything works fine with the message type. The auto completion can be used to publish messages. If those arrays are in, even if I do not change the values of the auto completion, when the arrays are in, I get the error which I posted.

@dirk-thomas
Copy link
Member

Please consider updating your original post next time instead of duplicating a lot of stuff. That makes a ticket less readable.

Also try creating the smallest possible example in the future - that makes it much easier to reproduce an issue.

I was able to reproduce the issue with a simple message containing only:

duration[] duration_array

Compilation passed but the following rostopic command failed:

rostopic pub /test test_pkg/duration_array "tbi_duration_A:
- data: {secs: 2, nsecs: 3}"

The same for time.

@dirk-thomas
Copy link
Member

The pull request will fix the issue that you can currently not use time or duration in array specifications and fill the values from the rostopic command line.

Time and duration is some kind of hybrid builtin type. You can easily work around the problem by specifying the type in your message with the fuil message types:

std_msgs/Time[] time_array
std_msgs/Duration[] duration_array

You could use the same type for the non-array fields as well. But when filling the value with rostopic be aware that you need to explicitly mention the data field within the time/duration message:

rostopic pub /test my_package/MyMessage "time: {data: {secs: 1, nsecs: 2}}
duration: {data: {secs: 1, nsecs: 2}}
time_array:
- data: {secs: 1, nsecs: 2}
duration_array:
- data: {secs: 3, nsecs: 4}
- data: {secs: 5, nsecs: 6}"

@dirk-thomas
Copy link
Member

Can you please verify that both the patched version of genpy (ros/genpy#14) and the workaround mentioned in the previous comment work for you?

@cyborg-x1
Copy link
Author

Well, it works when I remove the "data" field from the duration array from the auto-completion of rostopic pub ...
#Time
time[2] tbi_time_A

#Duration
duration[] tbi_duration_A

...
tbi_time_A:

  • {secs: 0, nsecs: 0}
  • {secs: 0, nsecs: 0}
    tbi_duration_A:
  • data: {secs: 0, nsecs: 0}
    ...

The data field is only generated by auto completion for undefined arrays for me at the moment.
which leads to error
ERROR: No field name [data]

When I delete "data", it works.

When I change the message to
#Duration
duration[2] tbi_duration_A

There is no "data" field in auto-complete and everything works just fine.

So now there is only a bug in auto completion of rostopic, which seems to expect "std_msgs/Time" instead of "time" for undefined arrays

@dirk-thomas
Copy link
Member

What do you mean with "undefined arrays"? Arrays with dynamic size?

@cyborg-x1
Copy link
Author

Ehm yep exactly.

dirk-thomas added a commit to ros/genpy that referenced this issue Aug 14, 2013
fix issue with Time/Duration message fields when used as array (ros/ros_comm#252)
@dirk-thomas dirk-thomas changed the title Publishing time or duration arrays with rostopic fails. rostopic pub completion wrong for dynamic arrays of type duration/time (was: publishing time or duration arrays with rostopic fails) May 2, 2014
@dirk-thomas dirk-thomas added this to the untargeted milestone May 2, 2014
@dirk-thomas dirk-thomas removed their assignment Jul 18, 2014
contradict pushed a commit to contradict/ros_comm that referenced this issue Aug 12, 2016
…y_if_available

use TopicStatistics only if available
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants