ROS_02 Simulate a Four-wheel Mobile Robot Model in Gazebo

ROS is installed with gazebo, check the version by gazebo –version, which gzserver, which gzclient to see more info.

Next, we need to install the necessary packages
sudo apt-get install ros-noetic-gazebo-ros-pkgs
sudo apt-get install ros-noetic-gazebo-msgs
sudo apt-get install ros-noetic-gazebo-plugins
sudo apt-get install ros-noetic-gazebo-ros-control
sudo apt-get install ros-noetic-teleop-twist-keyboard

ros-noetic-gazebo-ros-pkgs – is a set of ROS packages that provide the necessary interfaces to
simulate a robot in the Gazebo 3D rigid body simulator for robots. It integrates with ROS using ROS
messages, services and dynamic reconfigure.
ros-noetic-gazebo-msgs – Messages and service data structures for interfacing ROS and Gazebo
ros-noetic-gazebo-plugins – Robot-independent Gazebo plugins for sensors, motors and dynamic
reconfigurable components.
Ros-noetic-gazebo-ros-control – controllers to communicate between between ROS and Gazebo
ros-noetic-teleop-twist-keyboard -package for controlling the robot by using keyboard keys

Then we need to create the workspace and CATKIN package

mkdir -p ~/my_workspace/src
cd ~/my_workspace
catkin_make
source ~/my_workspace/devel/setup.bash
echo $ROS_PACKAGE_PATH
cd ~/my_workspace/src
create the package:
catkin_create_pkg robot_model_pkg gazebo_msgs gazebo_plugins gazebo_ros
gazebo_ros_control

Dependencies are: gazebo_msgs, gazebo_plugins, gazebo_ros, gazebo_ros_control.

STEP 3: CREATE THE SOURCE FILES DEFINING THE ROBOT GEOMETRY
cd ~/my_workspace/src/robot_model_pkg
mkdir urdf
cd ~/my_workspace/src/robot_model_pkg/urdf
gedit robot.xacro
Check the URDF file:
check_urdf <(xacro robot.xacro), edit the file, then create another file

gedit robot.gazebo
edit the file
cd ~/my_workspace
catkin_make

STEP 4: CREATE THE LAUNCH FILE AND LAUNCH THE FILE IN GAZEBO
cd ~/robot_four/src/robot_model_pkg
mkdir launch
cd ~/robot_four/src/robot_model_pkg/launch
gedit robot_xacro.launch
Edit the file and save

Then, open a new terminal and start
roscore
and then,
Finally, we can launch our model in gazebo as: roslaunch robot_model_pkg robot_xacro.launch

STEP 5: Control the robot by Using Teleop
Create a teleop node for controlling the robot. Open a new terminal and type
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
Then, investigate the topics that are being used and published to. Open a new terminal and type
rostopic list
rostopic echo /odom
rostopic info /cmd_vel

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.