Ask Your Question

How to control turtlesim by a publisher data sent by arduino rosserial

asked 2019-07-26 18:55:12 -0500

requestadepache gravatar image

updated 2019-07-27 12:29:30 -0500

jayess gravatar image

I'm noob in ROS, and i used this aduino code to send Float64 data to ros

#include <std_msgs/Float64.h>

ros::NodeHandle  nh;

std_msgs::Float64 float_msg;

ros::Publisher chatter("chatter", &float_msg);

float x = 5;

void setup()





void loop()
{ = x;

  chatter.publish( &float_msg );


then i used the following command to control turtle sent publisher data

rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist -- '[chatter, 0.0, 0.0]' '[0.0, 0.0, 1.8]'

but it doesn't read chatter as Float64 data so it doesn't work , even i checked rostopic info chatter and it had float64 data type

Thanks in advance

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2019-07-27 03:58:59 -0500

nkhedekar gravatar image

updated 2019-07-27 12:30:09 -0500

jayess gravatar image

rostopic is not the right command for republishing the content of one topic as a separate message on another topic since it does not evaluate the arguments passed ('[chatter, 0.0, 0.0]' '[0.0, 0.0, 1.8]').

rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist -- '[chatter, 0.0, 0.0]' '[0.0, 0.0, 1.8]'

The relay_field node from topic_tools( is more appropriate for your purpose as it provides this functionality. The command for this would be

rosrun topic_tools relay_field /chatter /turtle1/cmd_vel geometry_msgs/Twist "linear:
  y: 0.0
  z: 0.0
  x: 0.0
  y: 0.0
  z: 1.8"
edit flag offensive delete link more


Thanks for your help :)

requestadepache gravatar imagerequestadepache ( 2019-07-27 06:18:38 -0500 )edit

Happy to help :) please accept the answer by clicking on the tick mark on the left if this solved your problem.

nkhedekar gravatar imagenkhedekar ( 2019-07-27 06:31:20 -0500 )edit

answered 2019-08-30 12:22:19 -0500

houssem trabelsi gravatar image

updated 2019-08-30 12:22:36 -0500

According to rosserial documentation :
The Arduino does not support 64-bit float datatypes. The serialization/deserialization code generated by make_library will automatically convert 64-bit floats into 32-bit datatypes, however, it should be noted that a loss of precision may occur!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2019-07-26 18:55:12 -0500

Seen: 57 times

Last updated: Aug 30