0
$\begingroup$

Rosanswers logo

Hello,
I would like to run one of my robot's wheel with a ros command in a terminal.
The function I use need two parameters so I wanted to use Float32MultiArray.

My arduino code ressembles to the following one:

float x,y;
----------
/*callback*/
void cmd(const std_msgs::Float32MultiArray& array){
  x = a.data[0];  
  y = a.data[1];  
  motor1.run(x,y); }
----------
/*suscriber*/
ros::Subscriber sub("cmd", &cmd);


In a terminal, I type the following command:
rostopic pub /cmd std_msgs/Float32MultiArray "layout:
 dim:
 - label: "run"
 size: 2
 stride: 1
 data_offset:0
data:[100 100]" --once 

However, I have the following error:

[WARN] [..]: Inbound TCP/IP connection failed: : 'required argument is not a float' when writing 'label: run
size: 2

Thank you in advance for your help.

Kindest regards,


Originally posted by Shanika on ROS Answers with karma: 66 on 2019-05-24

Post score: 0


Original comments

Comment by Jasmin on 2019-05-28:
Could you precise what does your (x, y) variables stand for? If they are velocities, we could come up with a more natural/coherent way to publish them.

Comment by Shanika on 2019-05-29:
In fact, (x,y) variables stands for the position (degrees) the robot has to reach and its speed (rpm)

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The following command will publish your data and give you access to your two parameters.

rostopic pub /cmd std_msgs/Float32MultiArray '{data: [100, 100]}' --once 

You're not using the layout in your code so we don't need to set it in this use case. The error you had is mainly because the published data is not formatted correctly.


Originally posted by Jasmin with karma: 188 on 2019-05-28

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Shanika on 2019-05-29:
Indeed, it was the cause of the error. Thank you Jasmin :)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.