Robot overturn when I controlled with the keyboard
I've just started with ROS and Gazebo and I'm learning how and where to implement my code to control a robot in Gazebo.
I'm trying to control robot Pioneer 2DX robot in Gazebo using ROS.
To do it, I have followed the tutorial: Controlling a differential drive robot in Gazebo from ROS. And to control it with the keyboard, I run this:
rosrun turtlesim turtle_teleop_key /turtle1/cmd_vel:=/pioneer2dxCamera/cmd_vel
But, there is a problem, because if I press up key, and then down key the robot overturn:
I think, the problem is because the linear velocity changes from 2 to -2. Look:
linear:
x: 2.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.0
---
linear:
x: -2.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.0
---
I have decided to modify program turtle_teleop_key
to store current linear and angular velocity, and, if linear velocity is 2 and I press down key, linear velocity will 0 instead of -2.
My question is:
Is this the correct place to do it or do I have to do it in the diff drive plugin?
By the way, I'm using this plugin, libgazebo_ros_diff_drive.so, to control the robot.
Yes, I know that change linear velocity to 2 to -2 will flip a real robot too. I'm not asking that.
This is probably not too far from reality; commanding a change in velocity from 2m/s to -2m/s could probably flip the real robot too. Maybe choose a lower speed?
@ahendrix Yes, I know that is not real. I'm not asking that, I'm asking where that: in diff drive plugin or in program to control the robot with keyboard?
Ok. So, I will modify the program that controls the robot with the keyboard instead of modifying the diff drive plugin. Thanks.