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?
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?
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2021-11-05 17:02:48 -0500
Seen: 74 times
Last updated: Nov 07 '21
Error "Does your IK Solver support approximate IK ?" Moveit!
rqt_image_view look at only one image
Gazebo is not able to send the joint states to generate tf tree.
Best practices for hardware interface with multiple motor drivers
How to build and deploy ROS product?
Connecting & Reading to a TCP/IP socket from a different ROS Node
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