# Why cannot robot move diagonally?

I am using ROS melodic and ubuntu 18.04 and python 2.7. I am referring to this lecture of a two wheeled robot moving in a world. https://www.theconstructsim.com/ros-p...

I placed the robot at position 8,8 with an orientation to face position 0,0, in a gazebo world. I wanted to move the robot, diagonally, to position 0,0. I used following code:

 twist=Twist() while not rospy.is_shutdown():   twist.linear.x = 0.5   twist.angular.z = 0.0   pub.publish(twist)   rospy.sleep(0.1) 

The robot starts towards origin(0,0) but immediately turns and starts moving parallel to y axis. I cannot understand, why it turns parallel to an axis, when I have not given it any angular command. Why it cannot keep going diagonally? On the other hand if I initially keep its orientation parallel to an axis, it keeps moving along a line parallel to axis. and does not make any kind of turn. Could any one guide how to move it diagonally?

edit retag close merge delete

Sort by » oldest newest most voted

This post is a wiki. Anyone with karma >75 is welcome to improve it.

In my opinion, your robot is in position control mode and you are giving him velocities commands. When you make twist.linear.x = 0.5. Your drone start moving towards global x = 0.5. First possible solution: update the value of both linear.x and linear.y to move it diagonally.

more