ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Robot overturn when I controlled with the keyboard

asked 2018-10-19 12:56:02 -0500

Elric gravatar image

updated 2018-10-21 02:01:53 -0500

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:

image description

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.

edit retag flag offensive close merge delete

Comments

2

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 gravatar image ahendrix  ( 2018-10-19 22:05:07 -0500 )edit

@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?

Elric gravatar image Elric  ( 2018-10-21 02:00:16 -0500 )edit

Ok. So, I will modify the program that controls the robot with the keyboard instead of modifying the diff drive plugin. Thanks.

Elric gravatar image Elric  ( 2018-10-21 12:35:40 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-10-21 10:14:48 -0500

You're controlling it in exactly the right way, you're just using a speed that's too high. Try using 0.1ms^1 instead which is a more realistic speed for that platform. By changing instantly from +2 to -2 ms^1 you're asking the robot to instantly change it's velocity by 14.4 Kmph, no wonder it flips!

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-10-19 12:56:02 -0500

Seen: 314 times

Last updated: Oct 21 '18