This package serves the following purposes:
- Create a
URDF
(Unified Robot Description Format) file for a differential robot. - Set up a Gazebo environment.
- Add all Gazebo package requirements for differential drive, lidar, or depth camera.
- Create Python scripts to enable basic autonomous robot movement.
Before you start working with this package, ensure you have the following prerequisites:
- A functional ROS workspace. If you don't have one, you can create a workspace by following the official ROS tutorial on creating a package.
Follow these steps to create a URDF file for your differential robot:
-
Create a ROS Package
If you haven't already set up a ROS workspace and package, you can create one by referring to the official ROS tutorial mentioned in the prerequisites.
-
Create a URDF File
Inside your ROS package directory, create a folder named
urdf
. This folder will be used to store your URDF files, create a new file with the extension.xacro
. You can choose any name for this file, but for this example, let's name itfile.xacro
. You can write your robot's URDF description in this file by following the guidelines provided in the official ROS URDF tutorial. -
Create a Gazebo enviroment File
folow this tutorial : official Building a world.
-
Create a Lauch File folow this tutorial : official Building a world.
To control your robot's movement autonomously, you can use a Publisher to write to the /cmd_vel
topic and a Subscriber to read from the /kobuki/laser/scan
topic. Here's a compact explanation of the control logic:
-
Publisher for
/cmd_vel
Topic:Create a Publisher that writes into the
/cmd_vel
topic to move the robot. You will adjust the linear and angular velocity values based on the laser sensor readings. -
Subscriber for
/kobuki/laser/scan
Topic:Create a Subscriber that reads data from the
/kobuki/laser/scan
topic. This topic contains laser sensor data, which you will use to make decisions about robot movement. -
Control Logic:
-
If the laser reading in front of the robot is higher than 1 meter (indicating no obstacle within 1 meter in front), set the robot to move forward.
-
If the laser reading in front of the robot is lower than 1 meter (indicating an obstacle closer than 1 meter in front), make the robot turn left.
-
If the laser reading at the right side of the robot is lower than 1 meter (indicating an obstacle closer than 1 meter on the right side), make the robot turn left.
-
If the laser reading at the left side of the robot is lower than 1 meter (indicating an obstacle closer than 1 meter on the left side), make the robot turn right.
-
This logic ensures that the robot can navigate autonomously based on its laser sensor readings, avoiding obstacles in its path.
Implement this control logic in your ROS nodes to achieve autonomous robot movement.
Follow these steps to start the autonomous_frist_pkg
package:
-
Launch
robot.launch
:To launch the
robot.launch
file, use the following command:roslaunch autonomous_frist_pkg robot.launch
-
Launch
robot_move.launch
:To launch the
robot_move.launch
file, use the following command:roslaunch autonomous_frist_pkg robot_move.launch