Publishing Odometry using Rosserial
What type of message should I use to publish encoder value which is read by an Arduino? Should I use Twist, Odometry or tfMessage message type?
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
What type of message should I use to publish encoder value which is read by an Arduino? Should I use Twist, Odometry or tfMessage message type?
Please refer to this tutorial for further info: https://www.clearpathrobotics.com/ass...
#include <ArduinoHardware.h>
#include <ros.h>
#include <geometry_msgs/Twist.h>
ros::NodeHandle nh;
geometry_msgs::Twist msg;
ros::Publisher pub("husky/cmd_vel", &msg);
void setup()
{
nh.initNode();
nh.advertise(pub);
} void loop()
{
if(digitalRead(8)==1)
msg.linear.x=-0.25;
else if (digitalRead(4)==1)
msg.linear.x=0.25;
else if (digitalRead(8)==0 && digitalRead(4)==0)
msg.linear.x=0;
pub.publish(&msg);
nh.spinOnce();
}
As you can see a Twist
message is published to the cmd_vel
topic. Twist message is composed of Linear and Angular velocities as can be seen here:
Once code loaded in Arduino and publishing velocity commands, we can pass these messages along into our ROS environment through rosserial
@osilva It's not clear to me what kind of sensor data the user is gathering. If it's wheel encoder values, I think it's confusing to put that in a Twist
message.
This is a bit of a strange answer @osilva. The title of the question is rather clear:
Publishing Odometry using Rosserial
we have a message type which is almost always used for this, being nav_msgs/Odometry
. Could you clarify why you're showing how to publish a geometry_msgs/Twist
instead? Conceptual reuse is not easy for someone just starting out, so I would probably recommend to stick to examples implementing what the OP asked, instead of some other message.
I appreciate the feedback @Mike Scheutzow and @gvdhoorn. The reason I used this example is that some new users find it easier to grasp the concept of Twist
msg but I can see how this can be confusing as the request is for publishing Odometry. I opted for the part of the question that said what should be used :
Should I use **Twist**, Odometry or tfMessage message type?
Asked: 2021-11-05 17:02:48 -0600
Seen: 413 times
Last updated: Nov 07 '21
Rosserial/Arduino Publishers and Subscribers
Problem setting up rosserial_arduino
rosserial debs for rosserial_arduino
rosserial lost sync with device
rosserial spinOnce() blocks if not connected to ROS
rosserial - losing sync when running servo example [closed]
Take a look at this tutorial as reference: https://www.clearpathrobotics.com/ass...
I’ll summarize it and add it as an answer a little later