Custom Robot in ROS

Build custom robot using ROS and Gazebo

Featured image

ROS is really an excellent tool to create your bots and simulate them with real-world scenarios. In this tutorial, we will dive into how you can create your own custom robot in ROS.

For demonstration, we will create a 4 wheeled bot with LiDAR and a Camera in it.

Atom Bot

Install ROS

Refer to the official guide of ROS:

# For Ubunuto 20
$ sudo apt install ros-noetic-desktop-full

Clone Repository

To follow along with this tutorial you need to clone my repository.


Along with Atom Bot, that is described on this tutorial, there are other bots as well do check them out.

Atom Bot

This is a 4 Wheeled robot with camera and lidar installed in it.

Build the workspace

$ git clone
$ cd Robotics_ws
$ catkin_make
$ source devel/

Launch Atom

roslaunch atom world.launch

This will open the following windows:

Atom Bot

Your Gazebo world will be having just the Atom Bot. Here you can see on top we have our LiDAR and at front we have our camera.

Build the Bot

Let’s start by creating XACRO files.

Read More:

Xacro (XML Macros) Xacro is an XML macro language. With xacro, you can construct shorter and more readable XML files by using macros that expand to larger XML expressions.


<!-- Define Different Robot Properties -->
<xacro:property name="robot_name" value="atom" /> 
<xacro:property name="robot_chassis_mass" value="15"/>
<xacro:property name="camera_mass" value="0.1"/>
<xacro:property name="hokoyu_mass" value="1e-5"/>

Each component is considered as link

<!-- Make Chassis of Bot -->
	<link name="chassis">
		<pose>0 0 0.1 0 0 0</pose>

			<mass value="${robot_chassis_mass}"/>
      		<origin xyz="0.0 0 0" rpy=" 0 0 0"/>

      			ixx="0.147116667" ixy="0" ixz="0"
      			iyy="0.334951167" iyz="0"

		<collision name="collision">
			<origin xyz="0 0 0.05" rpy=" 0 0 0"/>
				<box size="0.5 0.5 0.2"/>

		<visual name="chassis_visual">
			<origin xyz="0 0 0.05" rpy=" 0 0 0"/>
				<box size="0.5 0.5 0.2"/>

Similarly add for Wheels, camera and LiDAR. Checkout the GitHub Repository for complete code

Add Different Joints

For Wheels continuous type is used and for camera and lidar fixed type is used.

<!-- Define Joints -->

	<!-- Right Wheel Joint Back-->
	<joint type="continuous" name="right_wheel_hinge_back">
	    <origin xyz="-0.2 -0.30 0" rpy="0 0 0" />
	    <parent link="chassis"/>
	    <child link="right_wheel_back" />
	    <axis xyz="0 1 0" rpy="0 0 0" />
	    <limit effort="10000" velocity="1000" />
	    <dynamics damping="1.0" friction="1.0" />

  <!-- Camera Joint -->
	<joint name="camera_joint" type="fixed">
		<origin xyz="0.26 0 0" rpy="0 0 0" />
		<parent link="chassis"/>
		<child link="camera" />
		<axis xyz="0 1 0"/>

Similarly add for other links as well.

Add Color

<!-- Color of bot -->
	<gazebo reference="left_wheel_front">
		<kp>1000000.0</kp> <!-- kp and kd for rubber -->

Include Gazebo Plugins

<!-- Motor, Camera and Lidar Simulation -->
<xacro:include filename="$(find atom)/urdf/atom.gazebo" />

Gazebo Plugins

In order to run all the sensors and actuators we need to connect our robot links to gazebo plugins

Skid Steer Drive

For controlling 4 wheeled robot skid steer drive plugin is used and for 2 wheeled robot differential drive plugins are used.

<plugin name="skid_steer_drive_controller" filename="">







Camera Plugin

For camera we need to specify:

<!-- camera -->
  <gazebo reference="camera">
    <sensor type="camera" name="camera1">
      <camera name="head">
      <plugin name="camera_controller" filename="">


For LiDAR we need to specify:

<!-- hokuyo -->
  <gazebo reference="hokuyo">
    <sensor type="ray" name="head_hokuyo_sensor">
      <pose>0 0 0 0 0 0</pose>
          <!-- Noise parameters based on published spec for Hokuyo laser
               achieving "+-30mm" accuracy at range < 10m.  A mean of 0.0m and
               stddev of 0.01m will put 99.7% of samples within 0.03m of the true
               reading. -->
      <plugin name="gazebo_ros_head_hokuyo_controller" filename="">

World File

This file describes the initial world that gazebo will spawn on launching the ROS environment.

<?xml version="1.0" ?>
<sdf version="1.4">
	<world name="default">

		<!-- Light source -->

		<!-- World camera -->
		<gui fullscreen='0'>
			<camera name='world_camera'>
				<pose>4.927360 -4.376610 3.740080 0.000000 0.275643 2.356190</pose>

Launch File

This file is used to run multiple ROS nodes together.


First we need to give robot pose:

	<!-- Robot pose -->
	<arg name="x" default="0"/>
	<arg name="y" default="0"/>
	<arg name="z" default="0"/>
	<arg name="roll" default="0"/>
	<arg name="pitch" default="0"/>
	<arg name="yaw" default="0"/>
	<arg name="robot_name" default="atom"/>

Include Robot Description Launch file

	<!-- Launch other relevant files-->
	<include file="$(find atom)/launch/robot_description.launch"/>

Add World File:

	<!-- World File -->
	<arg name="world_file" default="$(find atom)/worlds/"/>

	<!-- Launch Gazebo World -->
	<include file="$(find gazebo_ros)/launch/empty_world.launch">
		<arg name="use_sim_time" value="true"/>
		<arg name="verbose" value="false"/>
		<arg name="debug" value="false"/>
		<arg name="gui" value="true" />
		<arg name="world_name" value="$(arg world_file)"/>

Spawn The robot:

	<!-- Spawn My Robot -->
	<node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
		args="-urdf -param robot_description -model atom
			  -x $(arg x) -y $(arg y) -z $(arg z)
			  -R $(arg roll) -P $(arg pitch) -Y $(arg yaw)"/>

Launch RVIZ (Optional)

<!--launch rviz-->
	<node name="rviz" pkg="rviz" type="rviz" respawn="false"
		  args="-d $(find atom)/default.rviz"/>

Control The Bot

For controlling the bot Teleop Twist keyboard library is used.

Instalation (Ubuntu 20):

sudo apt-get install ros-noetic-teleop-twist-keyboard


rosrun teleop_twist_keyboard

Read More:

Hope you liked this brief demo.