Conversation
dirk-thomas
left a comment
There was a problem hiding this comment.
Please also try you patch with a message which doesn't have a header field. I would expect it to fail atm.
| # TODO(dhood): use sim time if parameter has been set on the node. | ||
| _clock = ROSClock() | ||
| _time_source = TimeSource(node=node) | ||
| _time_source.attach_clock(_clock) |
There was a problem hiding this comment.
Instead of creating a new clock please use the clock already available in the node: clock = node.get_clock()
| print('publishing #%d: %r\n' % (count, msg)) | ||
| curr_rostime = _clock.now().nanoseconds | ||
| msg.header.stamp.sec = int(curr_rostime * 1e-9) | ||
| msg.header.stamp.nanosec = int(curr_rostime % 1e9) |
There was a problem hiding this comment.
To avoid doing this "calculation" I added a new method seconds_nanoseconds on the Time class in ros2/rclpy#235. Please use that one:
msg.header.stamp.sec, msg.header.stamp.nanosec = clock.now().seconds_nanoseconds
82b8df1 to
118fcbb
Compare
|
@dirk-thomas thanks for review, updated the code. the patch depends on ros2/rclpy#235. Pass verified on msg with header(sensor_msgs/Image) and without header(std_msgs/String)
$ ros2 topic pub /msg std_msgs/String
|
|
Having the option to set the header timestamp to the current is great. If the user wan't to publish a specific message with a specific timestamp though this isn't possible anymore. I would recommend to add an option to conditionally control this "magic" step. Opt out is likely a good choice. |
|
when user set specific message, the time basically will not set to zero. Below is changes to fill timestamp if msg has header but the timestamp is not zero. is this ok? |
|
What if the user wants to intentionally publish a message with the timestamp being zero? I don't think tools should prohibit users from doing whatever they want. |
|
Oh. Do you mean to add optional argument like "--timestamp" "-t" ? |
Yes, the ROS 1 tool
Since that seems to work fine it might be best to follow this approach. |
|
I would suggest to rather implement the same option as in ROS 1 as it is strictly more flexible / capable. |
|
the |
|
Message generation is very different between the ROS versions. The packages in ROS 2 are called e.g. |
a1ad5df to
416e9a2
Compare
When publishing with a rate, performs keyword ('now' or 'auto') substitution for each message. Implemented the same option as in ROS1.
Signed-off-by: Chris Ye <chris.ye@intel.com>
|
This patch is not necessary. closed it. |
* Fix ros2 launch on Windows argcomplete it doesn't support Windows. Moved the `argcomplete` outside the try catch Signed-off-by: ahcorde <ahcorde@gmail.com> * Fixed comment on ros2launch Signed-off-by: ahcorde <ahcorde@gmail.com>
publish msg with timestamp could be used to verify ros2opic delay command porting
Signed-off-by: Chris Ye chris.ye@intel.com