CMPUT 412 competition 1
This project is a ROS package that allows a robot to follow another robot that is moving in a counter-clockwise circular path.
Requires a Turtlebot 2 with the RGB-D camera in its default position, and Python 2.7 with ROS Kinetic. Gazebo is required if one wants to test the project in a simulated environment (although it must be noted that the robot parameters are currently tuned for a real-world turtlebot and perform sub-optimally on the simulator).
To get started, simply clone the repository:
git clone https://github.com/alex-epp/cmput412-competition1
The project can be built as follows:
cd cmput412-competition1
catkin_make
source devel/setup.bash
To run the project in Gazebo:
roslaunch follow_bot run_sim.launch
If you want to run the project on a physical Turtlebot, you must plug in the RGB-D camera and the Kobuki base into your computer, then run
roslaunch follow_bot run.launch
The task of following another robot is split into several subtasks.
The first step the follow-bot performs is to locate the robot it is tracking. This is done by means
a virtual laser scan (obtained from the camera's RGB-D information from the depthimage_to_laserscan
package). The closest point in the laser scan that has angle <= 0.25 (where pi/2 to the right and
-pi/2 is to the left) is considered the location of the robot. This point is transformed into the
odometry frame for the next step.
The next step is to locate a target to move towards. This is not actually the location of the target robot--instead it is a point in between the follow-bot and the target robot. This is to prevent the follow-bot from colliding with the target, and also because when the target is farther away from the follow-bot it is in a wider portion of the follow-bot's field of view, reducing the chances of losing the target if it moves laterally to the follow-bot's view direction. The target point is 1 meter behind the target robot.
The follow-bot is directed toward the target point by simple proportional control. The difference in the forward direction from the target point to the robot is calculated, and the robot's forward velocity is set to be proportional to this (capped at a maximum speed). The robot moves slower backward than forward.
If the robot is moving forward, it also changes direction according to a proportional control on the z-angle (again capped and smoothed with a velocity smoother).
This node estimates and publishes the target's position from the laser scan. It is called automatically by the run*.launch files.
- target_pose (geometry_msgs/Pose2D): The estimated 2D pose of the target in the
odomframe. The angle is not used. - target_point (geometry_msgs/PointStamped): The estimated position of the target. In general it is probably simpler to subscribe to target_pose, but this topic is useful for visualization.
- pose2d (geometry_msgs/Pose2D): The pose of the robot in the
odomframe. - scan (sensor_msgs/LaserScan): The laser scan data.
- angle_cutoff_offset (float): Controls the angle at which points in the laserscan are ignored. If 0, then all points in the right hemisphere are ignored. If positive, then some points in the right hemisphere are kept (those with angle from the center of less than
angle_cutoff_offset). If negative, then similarly some points in the left hemisphere are discarded.
This node contains the smach state machine used to control the robot. It is called automatically by the run*.launch files.
- cmd_vel (geometry_msgs/Twist): The Twist messages used to control the robot
- joy (sensor_msgs/Joy): Joystick input
- odom (nav_msgs/Odometry): Robot odometry
- pose2d (geometry_msgs/Pose2D): The robot's pose in the
odomframe - target (geometry_msgs/Pose2D): The pose of the target to follow, in the
odomframe (angle is ignored).
- follow_distance (float, default
1.0): The distance between the target and the midpoint (the point the robot follows) - retreat_speed (float, default
0.1): Speed at which robot backs up when midpoint is behind it. - angle_switch_distance (float, default
0.1): Distance to midpoint at which the robot starts turning toward the target instead of toward the midpoint. - linear_speed_cutoff (float, default
0.8): Maximum linear speed before controller starts to cap the proportional control. - linear_speed_multiplier (float, default
1.0): Proportional constant for the linear speed. - angular_speed_cutoff (float, default
2.0): Maximum angular speed before controller starts to cap the proportional control. - angular_speed_multiplier (float, default
6.0): Proportional constant for the angular speed.