Simple, Comprehensive ROS Melodic Robot

There are a number of good tutorials out there, but at least as far as google’s results are concerned, there needs to be some glue in between, which is what this writing is designed to do.

I first started by searching for building mobile robot tutorials in Gazebo. I learned a bit, but ultimately wish I would have found some instructions like the following.

Assuming you have installed ROS Melodic Desktop Full version per these instructions: http://wiki.ros.org/melodic/Installation/Ubuntu

Follow this tutorial to create a URDF http://wiki.ros.org/urdf/Tutorials

Essentially you must:
1) Create a catkin workspace

$ source /opt/ros/melodic/setup.bash
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/
$ catkin_make
$ source devel/setup.bash

2) Create a package for your model

$ cd %TOP_DIR_YOUR_CATKIN_WS%/src
$ catkin_create_pkg [your robot name] roscpp rospy tf geometry_msgs

3) Create the following folder structure (this part is simply organizational) in catkin_ws/src/[your package]:
../[your package]
/launch
/model

4) Create a [your robot].urdf file in the model folder using this tutorial: ROS URDF Tutorial from Scratch

5) Create a display.launch file in the launch folder. Cut and paste the following:

<launch>
        <arg name="model" default="$(find [your_package])/model/[your_robot].urdf" />
        <param name="robot_description" command="cat $(find [your_package])/model/[your_robot].urdf" />
        <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
        <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />
        <arg name="gui" default="true" />
        <node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" />
        <param name="use_gui" value="$(arg gui)"/>
</launch>

Then open a terminal go to the root of your catkin_ws and:

$ source devel/setup.bash
$ catkin_make
$ roslaunch [your_pacakge] display.launch

You should now see your robot in RVIZ.