Now that the low level firmware has been installed and tested to work on the Arduino Mega, we can now setup the high level.
- Download and install Python 2.7 (NOT 3.0).
- Download and install Python Serial for Python 2.7.
- Download and install Python OSC for Python 2.7.
- Download the Multipurpose Mobile Manipulator library for Python 2.7.
- Extract the MMM Python 2.7 folder to a location of your choice.
- Start programming with Python 2.7 by including this header for every script to interface with the robot:
from MMM import MMM
from MMM_Speaker import Speaker
Although the high level can be implemented in any language that outputs a basic serial communication to the Arduino Mega, we will be using Python 2.7, as we have already developed a basic control library for the Multipurpose Mobile Manipulator with Python 2.7. Additional libraries for high level control using Python 3.0, ROS, C++, Processing, Unity, MATLAB, Scratch, and RobotC are planned and underway.
After completing the previous step, you should be ready to start using the provided Multipurpose Mobile Manipulator library to begin developing applications using Python 2.7. The main script that controls the robot's actuators and sensors is called MMM.py
. Here is an overview of how it works:
Serial Communication Commands:
MMM(portName) opens a new serial channel at the robot's Arduino Mega 2560 portname. Give the Arduino roughly 5 seconds to initialize after connecting before sending any further commands.
parseData() gets the sensor readings on the robot by reading the serial port and parsing the input.
update() sends all actuator positions to the Arduino by writing to the serial port, updating the actual robot. Note that the robot will not move any of its actuators until update() is called!
Actuator Position and Sensor Reading Commands:
reset() resets all actuator positions to their default values.
setWheelVelocity(leftSpeed, rightSpeed) controls the wheels. Units are in meters, and positive values move the wheels forward while negative values sends the wheels backwards. The range of input is +.18 m/s to -.18 m/s.
rotateShoulders(leftAngle, rightAngle) rotates the shoulders. The range of input is from 0 to 120 degrees, where 120 degrees rotates the shoulders fully inwards.
rotateElbows(leftAngle, rightAngle) rotates the elbows. The range of input is from -60 to 60 degrees, where 60 degrees rotates the elbows fully upwards.
extendArms(leftAmount, rightAmount) extends the arms in meters. The range of input is from 0 meters to .127 meters (roughly 5 inches).
setLeftGrippers(l1, l2, l3, l4, l5) rotates up to 5 servomotors on the left gripper. The range of input for each servo is 0 to 180 degrees.
setRightGrippers(r1, r2, r3, r4, r5) rotates up to 5 servomotors on the right gripper. The range of input for each servo is 0 to 180 degrees.
getLeftRange() and getRightRange() return the left and right rangefinder distance readings, from 0 to 100 cm. Readings that are out of bounds return -1.
- Here is a very basic example script of how these commands are used to make the robot move in Python 2.7:
from MMM import MMM
mmm = MMM('COM3') # Create an serial connection at COM3
time.sleep(5) # give some time to connect
mmm.setWheelVelocity(.18,-.18) # rotates robot left
mmm.rotateShoulders(120,0) # one shoulder in, one out
mmm.rotateElbows(60,-60) # one elbow up, one down
mmm.extendArms(0,.127) # one arm retracted, one extended
mmm.setLeftGrippers(0,0,0,0,0) # all servos at 0 degrees
mmm.setRightGrippers(0,0,0,0,0) # all servos at 180 degrees
mmm.update() # send updated actuator states to robot