ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Does rostopic pub .. not work for you?

The following works for me:

rostopic pub -r 1 /some_topic std_msgs/Time 'data: { secs: 1, nsecs: 2 }'

Does rostopic pub .. not work for you?

The following works for me:

rostopic pub -r 1 /some_topic std_msgs/Time 'data: { secs: 1, nsecs: 2 }'

Edit: just noticed this:

I'd like to publish the current ROS time to a topic from the command line.

That would seem to be something else.

If I understand you correctly, you'd like to take the messages published on /clock and republish them on a different topic?

I haven't tested it, but topic_tools/relay should be able to do that.

Does rostopic pub .. not work for you?

The following works for me:

rostopic pub -r 1 /some_topic std_msgs/Time 'data: { secs: 1, nsecs: 2 }'

Edit: just noticed this:

I'd like to publish the current ROS time to a topic from the command line.

That would seem to be something else.

If I understand you correctly, you'd like to take the messages published on /clock and republish them on a different topic?

I haven't tested it, but topic_tools/relaytopic_tools/transform should be able to do that.that. It would have to transform a rosgraph_msgs/Clock msg into a std_msgs/Time msg.

The documentation should help to construct the Python expression. #q261935 provides an example.

Edit2: ah, I'd completely misunderstood you.

I was hoping there was a quick way to specify a "now" message from the cli.

rostopic pub should actuallys support this.

I'm not sure how well it is documented, but rostopic pub --substitute-keywords .. allows you to use a now keyword that should be substituted with the current time as a timestamp:

  -s, --substitute-keywords
                        When publishing with a rate, performs keyword ('now'
                        or 'auto') substitution for each message

I haven't checked, but you should be able to use something like:

rostopic pub -s -r 1 /some_topic std_msgs/Time 'now'

Does rostopic pub .. not work for you?

The following works for me:

rostopic pub -r 1 /some_topic std_msgs/Time 'data: { secs: 1, nsecs: 2 }'

Edit: just noticed this:

I'd like to publish the current ROS time to a topic from the command line.

That would seem to be something else.

If I understand you correctly, you'd like to take the messages published on /clock and republish them on a different topic?

I haven't tested it, but topic_tools/transform should be able to do that. It would have to transform a rosgraph_msgs/Clock msg into a std_msgs/Time msg.

The documentation should help to construct the Python expression. #q261935 provides an example.

Edit2: ah, I'd completely misunderstood you.

I was hoping there was a quick way to specify a "now" message from the cli.

rostopic pub should actuallys support this.

I'm not sure how well it is documented, but rostopic pub --substitute-keywords .. allows you to use a now keyword that should be substituted with the current time as a timestamp:

  -s, --substitute-keywords
                        When publishing with a rate, performs keyword ('now'
                        or 'auto') substitution for each message

I haven't checked, but you should be able to use something like:

rostopic pub -s -r 1 /some_topic std_msgs/Time 'now'

That publishes ros::Time::now() at a rate of 1 Hz.


Does rostopic pub .. not work for you?

The following works for me:

rostopic pub -r 1 /some_topic std_msgs/Time 'data: { secs: 1, nsecs: 2 }'

Edit: just noticed this:

I'd like to publish the current ROS time to a topic from the command line.

That would seem to be something else.

If I understand you correctly, you'd like to take the messages published on /clock and republish them on a different topic?

I haven't tested it, but topic_tools/transform should be able to do that. It would have to transform a rosgraph_msgs/Clock msg into a std_msgs/Time msg.

The documentation should help to construct the Python expression. #q261935 provides an example.