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

how to publish linear velocity and angular velocity rosserial arduino?

asked 2017-11-19 23:10:56 -0500

nada2bnm gravatar image

how to publish linear velocity and angular velocity rosserial arduino with Twist.h ?

I tried

geometry_msgs::TransformStamped t;

t.transform.translation.x = x; t.transform.translation.y = y; t.transform.translation.z = 0;

t.transform.rotation = tf::createQuaternionFromYaw(th); t.Twist.Twist.linear.x=dx/dt; t.Twist.Twist.linear.z=dth/dt;

but last two lines error

I need your help plz thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-11-20 06:36:15 -0500

rreignier gravatar image

From the documentation, this is the definition of a geometry_msgs/Twist message:

# This expresses velocity in free space broken into its linear and angular parts.
Vector3  linear
Vector3  angular

So to fill it, you only have to set it like this (the same way than within a normal ROS node):

geometry_msgs::Twist msg;
msg.linear.x = 1.0;  // m/s
msg.angular.z = 0.5; // rad/s

Then you can publish it with your already defined publisher (note that we pass a pointer with rosserial_arduino):

cmd_pub.publish(&msg);

To see an publisher example on rosserial_arduino, please, look at this tutorial.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-11-19 23:10:56 -0500

Seen: 1,462 times

Last updated: Nov 20 '17