How to publish time stamped message from terminal

asked 2020-05-20 07:24:27 -0500

Gates gravatar image

I would like to create a custom IMU message from terminal (or rqt_publisher). I can publish the message /imu_test and echo it from terminal but I cannot monitor it using rqt_plot. The data doesn't show up.

I think that the problem is because I didn't fill the header properly and my guess is that I didn't state any time info. Please correct me if I am wrong. I can publish a custom /turtle1/cmd_vel the same way I try to publish an IMU message and visualize it without any problem. See the figure below that I can visualize /cmd_vel as -5.0 as I stated and no /imu_test message.

image description

My guess is that the geometry_msgs/Twist doesn't have the header part and doesn't require to specify ROS time explicitly.

I have tried to give a "time" object in the expression by following API documentation. According to that should create a time instance and I should be able to write Python expressions but it doesn't work. It gives me "# error evaluating as "Time" ".

I am stuck at how to solve the syntax issue or whatever the problem is. I appreciate any help or comment. Thanks.

edit retag flag offensive close merge delete


Could you check whether #q275143 provides an answer?

gvdhoorn gravatar image gvdhoorn  ( 2020-05-20 12:34:38 -0500 )edit

yes but unfortunately I couldn't make it work. I have tried ros::Time::now(), now, 'now', 'data: { secs: 1, nsecs: 2 }', data: { secs: 1, nsecs: 2 } and many other different silly syntax trials gave me the same error. Whatever I write as a /header/stamp expression, it gives me "# error evaluating as "Time""

Gates gravatar image Gates  ( 2020-05-22 02:47:10 -0500 )edit

Please edit your original post and show verbatim copy-pastes of the commands you've tried.

Including verbatim copy-pastes of the error messages you got.

I have tried ros::Time::now()

this doesn't really work in any case as that's a C++ expression. You cannot pass those to a Python command line utility which uses YAML as input for message fields.

gvdhoorn gravatar image gvdhoorn  ( 2020-05-22 03:44:07 -0500 )edit

I don't understand what you want me to edit in my original post. I have already written the python command I tried, I wrote the error I get. And I knew that C++ expression wouldn't work but I just tried to explain that I tried tens of silly commands even if it wouldn't work 99.9% chance. I don't think that it helps if I write down the list of all unsuccessful trials which I have tried so far. In fact, it will make the post way too long unnecessarily.

Gates gravatar image Gates  ( 2020-05-22 04:42:07 -0500 )edit

We don't need to see everything you've tried.

Just show one or two, especially those which are supposed to work according to the documentation.

I cannot help you without you showing what you've done, and the error you get.

have already written the python command I tried

where exactly is the command line you used?

gvdhoorn gravatar image gvdhoorn  ( 2020-05-22 05:00:17 -0500 )edit