ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Hi,
what you are talking about is called Robot navigation
, that is, the ability of the robot to go from one place to another.
Then, in order to achieve that, you need to decide at least the following three things:
Let's assume the simplest answer to the questions above:
odometry frame
(I'm assuming you know what odometry is). The problem with this frame is that has a sift (an error) which increases over time. But for your example is good enough.potential fields
or else.Even if this is a very simple setup, that setup can be used, for example, to move the robot to the position of a detected target. Imagine that the robot has a camera and a program that detects people. Then, once the program detects a person in 5 meters in front of the robot, it means that the robot can go to the person location using that simple framework we defined in the questions above.
Now, you need to built a controller that converts the distances from the current position AND orientation of the robot into velocity commands that are sent to the /cmd_vel
of the robot to make it move towards the location. That controller can be built in many ways.
A simple controller to do that would be the following:
If the robot (odometry) orientation is not towards the target, then rotate only the robot until its orientation is towards the target.
speed = Twist()
speed.linear.x = 0.0
speed.angular.z = 0.2
Once the robot is headed towards the target, just move straight towards the goal until reached
speed = Twist()
speed.linear.x = 0.5
speed.angular.z = 0.0
I have created this video that shows how that controller works with a Husky robot in a Gazebo simulated environment.
More complex controllers can be implemented that optimize the time to reach the goal, or other factors like moving faster when far away from goal and moving slower when getting closer.
In case you want to make the robot include obstacle avoidance, navigation in bigger environments of which a map can be built, then you need to use the Navigation Stack of ROS
which includes all that (and more). Check this video tutorial for a good overview of what the ROS Navigation stack can do.
Hope it helps, and welcome to the robot navigation world!