In this project, you should create two ROS packages inside your catkin_ws/src:
the drive_bot
and the ball_chaser
. Here are the steps to design the robot, house it inside your world, and program it to chase white-colored balls:
-
drive_bot
:- Create a
my_robot
ROS package to hold your robot, the white ball, and the world. - Design a differential drive robot with the Unified Robot Description Format. Add two sensors to your robot: a lidar and a camera. Add Gazebo plugins for your robot’s differential drive, lidar, and camera. The robot you design should be significantly different from the one presented in the project lesson. Minimum required changes are adjusting the color, wheel radius, and chassis dimensions. You can also completely redesign the robot model!
- Create a new world, which is different from the world you built in the Build My World project and house your robot inside that world.
- Add a white-colored ball to your Gazebo world and save a new copy of this world.
- The
world.launch
file should launch your world with the white-colored ball and your robot.
- Create a
-
ball_chaser
:- Create a
ball_chaser
ROS package to hold your C++ nodes. - Write a
drive_bot
C++ node that will provide aball_chaser/command_robot
service to drive the robot by controlling its linear x and angular z velocities. The service should publish to the wheel joints and return back the requested velocities. - Write a
process_image
C++ node that reads your robot’s camera image, analyzes it to determine the presence and position of a white ball. If a white ball exists in the image, your node should request a service via a client to drive the robot towards it. - The
ball_chaser.launch
should run both thedrive_bot
and theprocess_image
nodes.
- Create a
.Project2
├── ball_chaser # ball_chaser package
│ ├── CMakeLists.txt # compiler instructions
│ ├── launch # launch folder for launch files
│ │ └── ball_chaser.launch
│ ├── package.xml # package info
│ ├── src # source folder for C++ scripts
│ │ ├── drive_bot.cpp
│ │ └── process_image.cpp
│ └── srv # service folder for ROS services
│ └── DriveToTarget.srv
├── images # output results
│ ├── demo.gif
│ ├── gazebo1.png
│ ├── gazebo2.png
│ └── rviz.png
├── my_robot # my_robot package
│ ├── CMakeLists.txt # compiler instructions
│ ├── launch # launch folder for launch files
│ │ ├── robot_description.launch
│ │ └── world.launch
│ ├── meshes # meshes folder for sensors
│ │ └── hokuyo.dae
│ ├── package.xml # package info
│ ├── urdf # urdf folder for xarco files
│ │ ├── my_robot.gazebo
│ │ └── my_robot.xacro
│ └── worlds # world folder for world files
│ ├── empty.world
│ └── UdacityOffice.world
└── README.md
- Open Terminal/CLI by using
Ctrl + Alt + T
shortcut. - Create and initialize a
catkin_ws
mkdir -p /<your_dir>/catkin_ws/src
cd /<your_dir>/catkin_ws/src
catkin_init_workspace
- Clone this repo inside
/<your_dir>/catkin_ws/src
- Ensure src directory has
my_robot
andball_chaser
directory inside it - Switch to
catkin_ws
cd /<your_dir>/catkin_ws
- Build the code and ensure there are no build errors reported
catkin_make
- Launch RViz and Gazebo. This may take a while upon initial loading.
source devel/setup.bash
roslaunch my_robot world.launch
- Setup RViz (ROS Visualization) to visualize sensor readings. On the left side of RViz, under
Displays
:- Select
odom
for fixed frame - Click the
Add
button and- add
RobotModel
and your robot model should load up in RViz. - add
Camera
and select the rgb/image_raw topic that was defined in the camera Gazebo plugin - add
LaserScan
and select the /scan topic that was defined in the Hokuyo Gazebo plugin
- add
- Select
- Open another Terminal/CLI by using
Ctrl + Alt + T
shortcut. Switch tocatkin_ws
cd /<your_dir>/catkin_ws
- Run
drive_bot
andprocess_image
, which can be done by executingball_chaser.launch
source devel/setup.bash
roslaunch ball_chaser ball_chaser.launch
- In Gazebo, move the white ball around so its in the robot's cameras field of view. The robot will move right if the white ball is found on the right side, left for left and forward if its in the center region. The robot will not move if there is no white ball detected in the camera.