Ask Your Question
2

How do I reset the /odom topic back to 0 without restarting the robot?

asked 2015-07-07 09:28:57 -0500

shahvineet98 gravatar image

updated 2015-07-10 07:17:13 -0500

I am using this callback function because I want to tell the robot to move a specified angle. I was wondering if there is a way to restart the /odom topic back to 0 for simplicity purposes. Your help is really appreciated!

I am using ROS Indigo and I have a create turtlebot base

def odometry_cb(self, data):
        pose = data.pose.pose
        quaternion = (pose.orientation.x, pose.orientation.y, pose.orientation.z, pose.orientation.w)
        euler = tf.transformations.euler_from_quaternion(quaternion)
        roll = euler[0]
        pitch = euler[1]
        yaw = euler[2] 
        yaw_angle = (yaw*(180/math.pi))
        self._last_yaw_angle = yaw_angle
        print(self._last_yaw_angle)
edit retag flag offensive close merge delete

Comments

It would be useful if you name the robot you use and which package.

BennyRe gravatar image BennyRe  ( 2015-07-10 03:32:11 -0500 )edit

I am sorry for not clarifying earlier but I updated that in my question

shahvineet98 gravatar image shahvineet98  ( 2015-07-10 07:17:45 -0500 )edit

4 Answers

Sort by ยป oldest newest most voted
2

answered 2015-07-14 22:08:25 -0500

vinjk gravatar image

This is how odometry is reset for Kobuki:

void KobukiRos::subscribeResetOdometry(const std_msgs::EmptyConstPtr /* msg */)
{
  ROS_INFO_STREAM("Kobuki : Resetting the odometry. [" << name << "].");
  joint_states.position[0] = 0.0; // wheel_left
  joint_states.velocity[0] = 0.0;
  joint_states.position[1] = 0.0; // wheel_right
  joint_states.velocity[1] = 0.0;
  odometry.resetOdometry();
  kobuki.resetOdometry();
  return;
}

Hope this helps.

edit flag offensive delete link more
1

answered 2015-07-10 01:51:03 -0500

mgruhler gravatar image

If you do have a Kobuki base, you can use the ~commands/reset_odometry topic of type std_msgs/Empty for this, as described here

edit flag offensive delete link more

Comments

This is exactly what I am looking for but is it possible on a create base?

shahvineet98 gravatar image shahvineet98  ( 2015-07-10 07:18:09 -0500 )edit
1

I think if you search in the source code where this topic is defined and how its callback function looks like, you can copy it for the create.

Mehdi. gravatar image Mehdi.  ( 2015-07-10 10:10:37 -0500 )edit

Hello, I just creat a publisher topic to publish the ~commands/reset_odometry , but I find the turtlebot doesn't change it's pose ,do you know the reason?

OsgoodWu gravatar image OsgoodWu  ( 2017-12-05 01:03:37 -0500 )edit
1

answered 2015-07-10 10:00:13 -0500

updated 2015-07-10 10:01:25 -0500

As far I can see there is no such service for the create node.

I guess you would have to add a service for that yourself in

https://github.com/turtlebot/turtlebo...

Maybe the _robot_reboot(self): function does what you want but you will have to add a service to call it externally.

Regards,

Christian

edit flag offensive delete link more
0

answered 2019-11-30 12:38:38 -0500

haitm gravatar image

updated 2019-11-30 12:39:45 -0500

in terminal, run

$ rostopic pub /mobile_base/commands/reset_odometry std_msgs/Empty

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-07-07 09:28:57 -0500

Seen: 5,352 times

Last updated: Nov 30 '19