ROS (Robot Operating System) is a popular multipurpose robotics framework used widely in research and industry. It is highly modular, with an architecture based around many "nodes" communicating with each other, and can be used with many different programming languages, notably Python and C++. With an active community surrounding it, it's easy to find support and useful packages to perform many advanced tasks.
We included ROS support for the Multipurpose Mobile Manipulator to encourage its use for advanced robotics research and education. This support is provided in the form of a ROS package called mmmros
. However, note that most basic applications of ROS can be achieved in pure Python. Please consider your needs before taking the time to delve into ROS.
Before you start, make sure you have the following:
dialout
group in order to access USB ports without root privileges: sudo adduser your_username dialout
We are using the latest version of ROS, "Kinetic Kame". The official install instructions can be found here, but there is also a more detailed guide below.
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 0xB01FA116
sudo apt update
sudo apt install ros-kinetic-desktop-full
sudo apt install python-serial
sudo apt install python-pip
sudo pip install pyOSC
sudo rosdep init
rosdep update
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source /opt/ros/kinetic/setup.bash
Catkin is the system that ROS uses to manage and automate the build process for your applications. (Even though you may be programming only in Python, the build system is necessary to generate some important ROS resources from your code) The "catkin workspace" is the directory where your development environment and source files will be stored. More information can be found in the official catkin documentation.
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
cd ~/catkin_ws/
catkin_make
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/catkin_ws/devel/setup.bash
mmmros
packageNow that your catkin workspace is fully set up, you can download the mmmros
package.
cd ~/catkin_ws/src
git clone https://github.com/Choitek/mmmros.git
mmmros
package.chmod -R +x mmmros/scripts
cd ~/catkin_ws
catkin_make
If the package built successfully, you are now ready to begin controlling your MMM through ROS! You should restart your terminal window to reload all of the new variables created.
Note: If at any time you want to uninstall ROS and then reinstall it, make sure you do a complete uninstall with sudo apt-get remove --auto-remove ros-kinetic-*
Otherwise, when you try to run ROS commands, you will get errors such as the absence of /opt/ros/kinetic/setup.bash
.
These tutorials will get you on track with the skills to write your own ROS programs and may give you some ideas of where to go next. Before delving straight into programming the MMM, it is highly suggested that you complete the sequence of ROS beginner tutorials, starting with #2, "Navigating the ROS Filesystem". If you plan on using Python to develop for ROS, it is also worthwhile to look through the overview of the rospy API. Finally, you can refer to the MMM API Documentation below while completing these tutorials. Note that it's possible to use C++ with mmmros
due to the modular nature of ROS, but all provided code and tutorials will be in Python.
Create a program to control the movements of the robot.
Learn how to use the tf library to give your robot some spatial awareness.
Use the Microsoft Kinect to give your robot vision, mapping, and autonomy capabilities.
This repository has the completed packages for all of the tutorials for your reference. You can clone the entire repository into your catkin workspace and build it (catkin_make
) so all of the tutorials are ready to run.
Our ROS library operates in a very similar way to the pure Python library (in fact, it uses it as its base), except that it allows for higher-level robotics work in conjunction with other nodes. You are encouraged to look through the well-commented code for the MMM node, located in mmmros/scripts/mmm_node.py
. It is expected that you are already familiar with the regular MMM Python library.
One node is included, named mmm
. As soon as it starts, it attempts to establish a serial connection with the robot's Arduino board over the specified port. If it cannot connect, the node and the entire ROS stack will exit due to it being specified as a "required" node. As soon as movement command messages are received, they will be clamped to appropriate values and relayed to the Arduino. By default, the node will not collect ultrasonic sensor data, but this capability can be toggled on and off. In the tutorials, you will make other nodes to supplement the mmm
node
Two custom message types are included in the mmmros
package.
The Movement
message type can be imported from the Python library mmmros.msg
and has a field for each actuator. The following table shows the values that can be passed into the mmm/move_commands
topic.
Part | Unit | Min value | Max value | Message field |
---|---|---|---|---|
Wheels | Speed (meters/s) | -0.18 | 0.18 | float64 leftWheelSpeed float64 rightWheelSpeed |
Shoulders | Angle (degrees) | 0 | 135 | float64 leftShoulderAngle float64 rightShoulderAngle |
Elbow | Angle (degrees) | -60 | 60 | float64 leftElbowAngle float64 rightElbowAngle |
Arm | Length (meters) | 0 | 0.127 | float64 leftArmExtension float64 rightArmExtension |
Grippers | Angle (degrees) | 0 | 180 | float64[5]* leftGripperAngles float64[5]* rightGripperAngles |
* These are arrays of the angles for each finger, use a list or tuple in Python
If the capability is turned on, the mmm/sensor_data
topic contains a stream of messages of type SensorData
(also imported from the Python library mmmros.msg
) with fields leftRange
and rightRange
, both formatted as int64. These indicate the detected obstacle distance in centimeters.
You can connect to the "face" of MMM (written in the Unity engine) and make it talk over the OSC protocol! Download the face program here. To have it say something, publish a ROS message of type String
from the std_msgs
library to the topic mmm/speaker_msgs
. Enable this capability by setting the parameter mmm/face/active
to true.
mmm/move_commands
mmm/sensor_data
mmm/speaker_msgs
Publish messages here to have them relayed to the "face" to be spoken. (If capability is turned on)The ROS parameter server is used to keep track of a number of variables that are used in running the mmm
node or simply provided for your convenience. Modify them in your application's roslaunch file with the <param>
tag if they need to be changed from their default values. The rospy API allows you to access them inside your Python code, but generally it's best to set them in your roslaunch file. Defaults are set in the
mmm/port
Specifies the port over which the mmm
node will attempt to make a connection to the Arduino.
(default is "/dev/ttyACM0"
)
mmm/sensor/active
Toggles ultrasonic sensor data collection on and off.
(default is false
)
mmm/sensor/rate
If the ultrasonic sensor is on, this specifies the rate in Hertz at which readings are requested.
(default is 10
)
mmm/face/active
mmm/dimensions/...
Specify the various dimensions of the robot in meters for use in the tf tutorial, etc.
(defaults are the dimensions of a typical MMM mark II robot)
mmm/dimensions/baseToChest
: the height from the ground to the middle of the chest sectionmmm/dimensions/chestToShoulder
: the horizontal length from the middle of the chest to the middle of the shoulder jointmmm/dimensions/shoulderToElbow
: the distance from the middle of the shoulder joint to the middle of the elbow jointmmm/dimensions/elbowToWrist
: the distance from the middle of the elbow joint to the end of the armmmm/dimensions/wheelSeparation
: the length between the wheelsmmm/dimensions/wheelRadius
: the radius of the wheelsmmm/ACTUATOR_NAME/min
and mmm/ACTUATOR_NAME/max
Specifies the minimum and maximum limits of the various actuators in the MMM robot. Replace ACTUATOR_NAME
with the name of the move_command
message field to return the limiting values. These are for your use only in limiting the values of sent to the robot. The mmm
node does clamp down your values, but it has no way of signaling back that this has happened. There is an example of these parameters in use in the teleop tutorial.
(defaults are the actuator limits given in the "Movement commands" table above)
The recommended and easiest way of using the MMM node in your application with the roslaunch tool. In order to have the mmm
node automatically started and all of the appropriate parameters set, we provide a roslaunch file that can be included in your own. With that in mind, most uses of the mmmros
library will have a roslaunch file structured like this:
<launch>
<include file="$(find mmmros)/launch/mmm.launch"/>
<param name="mmm/port" value="specify_your_port_here"/>
<node pkg="package_name" name="node_name" type="node_file_name.py" output="screen"/>
</launch>
Note that the <include>
tag should be placed before any tags setting MMM parameters of your own. If you want to enable the ultrasonic depth sensors or the face, add additional parameters like so:
<param name="mmm/sensor/active" value="true"/>
<param name="mmm/face/active" value="true"/>