ROS Basics
General information about ROS 1 (Noetic), Ubuntu and Ubiquity Robotics
ROS “Robot Operating System” isn’t really in any sense an “OS.” It is an application framework. ROS was developed starting in 2007 at Willow Garage and is now maintained by the Open Source Robotics Foundation. ROS is computer code that allows control of a robot by communicating between the sensors, effectors, computers, and networks to operate a robot both via autonomous and tele-operation. Versions of ROS are closely associated with Ubuntu releases, Noetic is the last ROS 1 release and is linked to Ubuntu 20.04. While it is possible to operate a Ubiquity Robotics product without any knowledge of Ubuntu, any development will require the use of a Ubuntu capable workstation. The Magni robot uses a Raspberry Pi (preferably Pi 4).
ROS Concepts
ROS consists of nodes (pieces of code) that use message passing to control the numerous functions of a robot and its interaction with the environment. The method is called publish and subscribe, and can be used across multiple processors. Since multiple computers are almost always used to control our robot, networks working well is important. Synchronizing time between computers running ROS is critical. Navigation and go to goal only work if the timestamps are within 1 to 2 seconds of each other. While most of ROS is loaded via debs using apt and is in /opt/ros, some of the vendor specific code exists in the ~/catkin_ws/src/
directory. Developers as well as Ubiquity Robotics support software via Github and updates are frequently distrubuted via git commands. Most ‘code’ support is via Python, but developers may encounter Java, C++, yaml, xml, shell scripts, etc. Most complex software requires a steep learning curve; ROS requires a deep dive off a steep cliff!
Key Takeaways:
-
ROS code runs in nodes
-
roslaunch and rosrun start nodes
-
nodes publish or subcribe to topics
-
roscore
is the master node -
parameters (constants) can be changed without restarting nodes
-
an entire ROS data stream can be captured in a BAG file
ROS generally has good documentation, that’s where you should start.
Visualize with RVIZ
Rviz (ROS visualization) is a 3D visualizer for displaying sensor and state information from ROS. It can show the robot in space as well as graph practically any robot parameter.
There is a nice short introductory rviz video at this location.
To ensure that the launch and configuration files are on your workstation you can run
sudo apt install ros-$ROS_DISTRO-magni-robot
.
To run rviz, type
roslaunch magni_viz view_nav.launch
when navigation is running
or
roslaunch magni_viz view_robot.launch
when it is not.
Using rviz, you can move the robot:
Click on “2D Nav Goal” in the menu bar.
Click again in the black screen area and indicate what the robot is to do.
Here is a short video showing the robot navigating with our setup. As you can see this was recorded on a workstation operating the robot. With the left side being a window that’s logged in to the robot and the right window being a local terminal on the workstation. This video assumes that a standard robot has been set up according to the instructions - its probably obvious that the name of the robot has been changed, as per the instructions, in this case to ‘frank’.
In the right hand window you see the steps that are carried out on the workstation including loading rviz etc.
Once RViz is loaded you can see that the user issues a go to goal target in RViz using a few mouse clicks. She first clicks 2D Nav Goal in the menu bar, then clicks on the desired pose. The arrow that is on the field of view is the desired location and orientation.
The system determines its location by looking at the fiducials in the environment, then the robot turns and drives to the target location.
Running Magni in Simulation
The Magni simulator utilizes the full desktop install of ROS, plus components of the magni-robot distribution from Ubiquity robotics. The simulator runs a virtual magni within the Gazibo simulator and allows development without a physical robot.
Prerequisites
We suggest your workstation be a machine with a Nvidia GPU display running Ubuntu 20.04. You can verify the required components are present by looking for required files
$ roscd magni_gazebo
$ ls
CHANGELOG.rst CMakeLists.txt config launch media package.xml urdf
If the above commands fail or the list of files is not found you will need to add the components required for Magni simulation in Gazebo.
Adding the required Components
Install catkin
Catkin may already have been installed, but if so this will do no harm.
~$ sudo apt-get install ros-$ROS_DISTRO-catkin
Make Catkin Folders And Run catkin_make
~$ mkdir -p ~/catkin_ws/src
~$ cd catkin_ws
~/catkin_ws$ catkin_make
Source the Setup.bash file
~/catkin_ws$ source devel/setup.bash
Install gazebo
~/catkin_ws$ sudo apt-get install ros-$ROS_DISTRO-gazebo-ros-pkgs ros-$ROS_DISTRO-gazebo-ros-control
Download the Gazebo ROS Packages
Make catkin_ws/src the current directory.
~/catkin_ws/src$ git clone https://github.com/ros-simulation/gazebo_ros_pkgs.git -b $ROS_DISTRO-devel
Install libgazebo and Check the Dependencies
Looks like this has already been done!
~/catkin_ws$ sudo apt-get install -y libgazebo7-dev
~/catkin_ws$ rosdep check --from-paths . --ignore-src --rosdistro $ROS_DISTRO
After you run this you may find you need ros_navigation and other modules. You may have to do sudo apt install ros-$ROS_DISTRO-xxxxx for those where xxxx may perhaps be ‘navigation’ and other modules.
You may also need our OLED repository as of mid 2020
~/catkin_ws/src$ git clone https://github.com/UbiquityRobotics/oled_display_node
Run Catkin Make
This may take rather a long time.
~/catkin_ws$ catkin_make
Add the Required Lines to setup.bash
Ensure that the last few lines in your ~/.bashrc look like this:
source /opt/ros/$ROS_DISTRO/setup.bash
source ~/catkin_ws/devel/setup.bash
export ROS_HOSTNAME=`cat /etc/hostname`.local
Now get the Magni Gazebo Software
Make catkin_ws/src the current directory. Then from catkin_ws, check the dependencies.
~/catkin_ws/src$ git clone http://github.com/ubiquityrobotics/magni_robot
~/catkin_ws$ rosdep install --from-paths src --ignore-src --rosdistro=$ROS_DISTRO -y
Run Catkin Make Again
~/catkin_ws$ catkin_make
This completes the installation of the prerequisites.
Run Gazebo
In a new terminal, launch rviz and gazebo_ros_pkgs
$ roslaunch magni_gazebo empty_world.launch
When empty_world.launch
starts it will start 3 windows–Rviz, Gazebo, and a control pad.
Rviz:
Gazebo:
Control Pad:
The Desktop with Gazebo and the Velocity Controller App opened:
Magni in Rviz showing ping sensor cones: