0
$\begingroup$

Rosanswers logo

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.


Originally posted by nada2bnm on ROS Answers with karma: 3 on 2017-11-20

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by rreignier with karma: 544 on 2017-11-20

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

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