Right way to move robots in Gazebo with ROS
Setup:
- Pioneer2DX in Gazebo world
- Test python script, which rotates robot's right wheel for a second, using ROS service "gazebo/apply_body_wrench":
#!/usr/bin/env python
#ros
import rospy
#msgs
from gazebo_msgs.srv import ApplyBodyWrench
#position
from geometry_msgs.msg import *
apply_wrench = rospy.ServiceProxy("gazebo/apply_body_wrench", ApplyBodyWrench)
wrench = Wrench()
wrench.torque.z = 30.0
apply_wrench("pioneer2dx::right_wheel", "", None, wrench, rospy.Time.from_sec(0), rospy.Duration.from_sec(1.0))
In the result robot moves a little, but the wheel does not change it's relative orientation to the robot. So, the force is created, but the robot rotates not because of the wheel's motion. Nevertheless, when I apply the same torque to the same wheel through Gazebo GUI, it rotates.
So, the questions are:
- Why does it happen?
- How to make robot move properly? (Maybe I am using the wrong method)