Create Custom Robot in ROS

HARSH MITTAL
3 min readJan 1, 2022

--

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.

Gazebo Simulation of Robot

Read Full Tutorial:

Watch video: Video Link

Install ROS

Refer to the official guide of ROS: http://wiki.ros.org/ROS/Installation

Clone Repository

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

Link: https://github.com/harshmittal2210/Robotics_ws

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 https://github.com/harshmittal2210/Robotics_ws
$ cd Robotics_ws
$ catkin_make
$ source devel/setup.sh

Launch Atom

$ roslaunch atom world.launch

This will open the following windows:

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.

This is the RVIZ tool. Here you can visualize different sensors data. On the screen you can see live feed from the camera.

Build the Bot

Let’s start by creating XACRO files.

Xacro

Read More: http://wiki.ros.org/xacro

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.

atom.xacro

<!-- 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"/>

Add link: Each component is considered as link

Read more about XACRO code here (Code is not displayed properly on medium): http://www.harshmittal.com/tutorials/Custom-Robot-ROS/

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">
<include>
<uri>model://ground_plane</uri>
</include>
<!-- Light source -->
<include>
<uri>model://sun</uri>
</include>
<!-- World camera -->
<gui fullscreen='0'>
<camera name='world_camera'>
<pose>4.927360 -4.376610 3.740080 0.000000 0.275643 2.356190</pose>
<view_controller>orbit</view_controller>
</camera>
</gui>
</world>
</sdf>

As you can clearly see right now I am just adding simple ground plane, sun and camera angles for the empty world.

Control The Bot

For controlling the bot Teleop Twist keyboard library is used.

Installing:

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

Running:

rosrun teleop_twist_keyboard teleop_twist_keyboard.py

Read More: http://wiki.ros.org/teleop_twist_keyboard

Hope you liked this brief demo. To know more checkout http://www.harshmittal.com/tutorials/Custom-Robot-ROS/ and the YouTube link.

--

--

HARSH MITTAL
HARSH MITTAL

Written by HARSH MITTAL

Software Developer, with extensive knowledge in Software Development, Robotics and Machine Learning.