MinJun Song
When we manipulate a robot in the gazebo world, there are times when the odometry of the robot does not correspond correctly with the actual position of the robot. This might be due to the robot running into objects which leads to mismatch between the rotation of the wheels and the calculation for the location derived from it. So it will be useful to get the absolute position of the robot that is given by the gazebo environment.
For the robot to navigate autonomously, it has to know its exact location. To manifest this process of localization, the simplest method is to receive values from the wheel encoder that calculates the odometry of the robot from the starting position.
In terms of mobile robots like turtlebot that we use for most of the projects, localization is impossible when the robot collides with other objects such as walls, obstacles, or other mobile robots.
So in this case, we can use the p3d_base_controller
plugin that gazebo provides to receive the correct odometry data of the robot to localize in the environment.
What I needed was relative positions of the robots. Originally we need to get the odometry data of the two robots and use rotation, translation matrix to find the relative coordinate values and yaw by ourselves.
In gazebo.xacro
file paste the following commands:
Explaination of the Code
bodyName: the name of the body that we want the location of
topicName: the name of odometry topic
With the code above, we can represent two robot’s location. To find robot 1’s location relative to robot 2’s location, we can use the following code: