Supported Hardware¶
Microcontroller Peripherals¶
Raw pins¶
$ rosservice call /mirte/get_pin_value "{pin: '', type: ''}"
$ rosservice call /mirte/set_pin_value "{pin: '', type: '', value: }"
Setting a pin can be either ‘analog’ (PWM) or ‘digital’. The pin itself can be defined as the print on the MCU (e.g. ‘GP3’). You can have a look in the web interface to see all options.
from mirte_robot import robot
mirte = robot.createRobot()
mirte.getAnalogPinValue()
- class robot.Robot
Robot API
This class allows you to control the robot from Python. The getters and setters are just wrappers calling ROS topics or services.
- getAnalogPinValue(pin)
Gets the input value of an analog pin.
- Parameters:
pin (str) – The pin number of an analog pin as printed on the microcontroller.
- Returns:
Value between 0-255.
- Return type:
int
- getDigitalPinValue(pin)
Gets the input value of a digital pin.
- Parameters:
pin (str) – The pin number of an analog pin as printed on the microcontroller.
- Returns:
The input value.
- Return type:
bool
- setAnalogPinValue(pin, value)
Sets the output value of an analog pin (PWM).
- Parameters:
pin (str) – The pin number of an analog pin as printed on the microcontroller.
value (int) – Value between 0-255.
- setDigitalPinValue(pin, value)
Sets the output value of a digital pin.
- Parameters:
pin (str) – The pin number of an analog pin as printed on the microcontroller.
value (bool) – Value to set.
Warning
Currently there is no check on whether a pin is already in use by some hardware defined in the yaml configuration discussed earlier. Therefore there is no expected behavior when using getting or setting raw pins.
DC Motor¶
Depending on the interface of your motor controller, the DC motor can be controlled though three different interfaces:
ddp (digital, digital, pwm): This interface uses two digital pins to set the direction of the motor, and uses a PWM dignal to set the speed. The L298 can use this interface.
dp (digital, pwm): This interface uses one digital pin for teh direction, and pwm for the speed. The downside is that the motor will slightly ‘kick’ when switching between forward and backward. This can be done on both L298 and L9110.
pp (pwm, pwm): This interface uses two PWM signals to control the motor. The downside is that this will take up 2 PWM pins. Can be used on both L298 and L9110.
As you can see the choice for interface depends on the actual interface provided by the motor controller, and the number of (PWM) pins you have available on the MCU.
ddp (e.g. L298)¶
motor:
left:
name: left
device: mirte
type: ddp
pins:
d1: GP19
d2: GP18
p1: GP17 # pwm
dp (e.g. L298 or L9110)¶
motor:
left:
name: left
device: mirte
type: dp
pins:
d1: GP19
p1: GP18 # pwm
pp (e.g. L298 or L9110)¶
motor:
left:
name: left
device: mirte
type: pp
pins:
p1: GP19 # pwm
p2: GP18 # pwm
$ rosservice call /mirte/set_left_speed "speed: "
from mirte_robot import robot
mirte = robot.createRobot()
mirte.setMotorSpeed('left', 50)
- class robot.Robot
Robot API
This class allows you to control the robot from Python. The getters and setters are just wrappers calling ROS topics or services.
- setMotorSpeed(motor, value)
Sets the speed of the motor.
- Parameters:
motor (str) – The name of the sensor as defined in the configuration.
value (int) – The ‘directional duty cycle’ (range [-100, 100]) of the PWM signal (-100: full backward, 0: stand still, 100: full forward).
- Returns:
True if set successfully.
- Return type:
bool
The motors will be defined separately. In this case there are two motors called ‘left_motor’ and ‘right_motor’, both controlled on the ‘mirte’ device defined above. The pins are set corresponding to the L9110s motor driver.
Warning
Please not that it is adviced to call the motors ‘left’ and ‘right’. You can chose your own names when you are only using these interfaces. In order to also get the ROS twist message (and steering in the web interface to work) you need to have the motors called ‘left’ and ‘right’.
Servo¶
servo:
left:
name: left
device: mirte
pins:
pin: GP3
$ rosservice call /mirte/set_left_servo_angle "angle: 90"
from mirte_robot import robot
mirte = robot.createRobot()
mirte.setServoAngle('left', 90)
- class robot.Robot
Robot API
This class allows you to control the robot from Python. The getters and setters are just wrappers calling ROS topics or services.
- setServoAngle(servo, angle)
Sets the angle of a servo.
- Parameters:
servo (str) – The name of the sensor as defined in the configuration.
angle (int) – The angle of the servo (range [0-360], but some servos might be hysically limited to [0-180].
- Returns:
True if set successfully.
- Return type:
bool
Warning
The servo uses the Servo library from Arduino (through Telemetrix). This also means that, when a servo is used and the library is enabled, the last timer on the MCU will be used for timing of the servos. This timer therefore can not be used for PWM anymore. For Arduino Nano/Uno this means pins D9 and D10 will not have PWM anymore. For the SMT32 this means pins A1, A2, A3, A15, B3, B10, and B11 will not have PWM anymore.
Warning
A maximum of 12 servos is supported.
Keypad¶
encoder:
left:
name: left
device: mirte
pins:
pin: GP28 # analog input
As a topic (non-blocking):
$ rostopic echo /mirte/keypad/left
As a service (blocking):
$ rosservice call /mirte/get_keypad_left "{}"
from mirte_robot import robot
mirte = robot.createRobot()
mirte.getKeypad('left')
- class robot.Robot
Robot API
This class allows you to control the robot from Python. The getters and setters are just wrappers calling ROS topics or services.
- getKeypad(keypad)
Gets the value of the keypad: the button that is pressed.
- Parameters:
keypad (str) – The name of the sensor as defined in the configuration.
- Returns:
The name of the button (‘up’, ‘down’, ‘left’, ‘right’, ‘enter’).
- Return type:
str
OLED¶
oled:
left:
name: left
device: mirte
pins:
scl: GP5
sda: GP4
$ rosservice call /mirte/set_left_image "{type: 'text', value: 'hello mirte'}"
$ rosservice call /mirte/set_left_image "{type: 'image', value: 'mirte_logo'}"
$ rosservice call /mirte/set_left_image "{type: 'animation', value: 'eye'}"
from mirte_robot import robot
mirte = robot.createRobot()
mirte.setOLEDText('left', 'hello mirte')
mirte.setOLEDImage('left', 'mirte_logo')
mirte.setOLEDAnimation('left', 'eye')
- class robot.Robot
Robot API
This class allows you to control the robot from Python. The getters and setters are just wrappers calling ROS topics or services.
- setOLEDAnimation(oled, animation)
Shows animation on the OLED.
- Parameters:
oled (str) – The name of the sensor as defined in the configuration.
animation (str) – Animation (directory) name as defined in the animations folder of the mirte-oled-images repository.
- setOLEDImage(oled, image)
Shows image on the OLED.
- Parameters:
oled (str) – The name of the sensor as defined in the configuration.
image (str) – Image name as defined in the images folder of the mirte-oled-images repository (excl file extension).
- setOLEDText(oled, text)
Shows text on the OLED.
- Parameters:
oled (str) – The name of the sensor as defined in the configuration.
text (str) – String to be shown on the 128x64 OLED.
Distance sensor¶
distance:
left:
name: left
device: mirte
pins:
trigger: GP7
echo: GP6
As a topic (non-blocking):
$ rostopic echo /mirte/distance/left
As a service (blocking):
$ rosservice call /mirte/get_distance_left "{}"
from mirte_robot import robot
mirte = robot.createRobot()
mirte.getDistance('left')
- class robot.Robot
Robot API
This class allows you to control the robot from Python. The getters and setters are just wrappers calling ROS topics or services.
- getDistance(sensor)
Gets data from a HC-SR04 distance sensor: calculated distance in meters.
- Parameters:
sensor (str) – The name of the sensor as defined in the configuration.
- Returns:
Range in meters measured by the HC-SR04 sensor.
- Return type:
int
Warning
A maximum of 6 distance sensors is supported.
IR sensor¶
intensity:
left:
name: left
device: mirte
pins:
digital: GP16
analog: GP26 # analog input
As a topic (non-blocking):
$ rostopic echo /mirte/intensity/left
$ rostopic echo /mirte/intensity/left_digital
As a service (blocking):
$ rosservice call /mirte/get_intensity_left "{}"
$ rosservice call /mirte/get_intensity_left_digital "{}"
from mirte_robot import robot
mirte = robot.createRobot()
mirte.getIntensity('left')
- class robot.Robot
Robot API
This class allows you to control the robot from Python. The getters and setters are just wrappers calling ROS topics or services.
- getIntensity(sensor, type='analog')
Gets data from an intensity sensor.
- Parameters:
sensor (str) – The name of the sensor as defined in the configuration.
type (str) – The type of the sensor (either ‘analog’ or ‘digital’).
- Returns:
Value of the sensor (0-255 when analog, 0-1 when digital).
- Return type:
int
USB Camera¶
By default the robot assumes you have connected the supported USB cam (see basic hardware). Currently only a ROS interface is defined.
The camera image is published in three ways (using ROS image transport).
$ rostopic echo /webcam/image_raw
$ rostopic echo /webcam/image_raw/compressed
$ rostopic echo /webcam/image_raw/theora
Other USB Cameras¶
In case you have another USB webcam, you might need to change the parameters of the USB cam to reflect your webcam. This then needs to be changed in the launchfile:
$ v4l2-ctl --list-formats-ext
$ nano /home/mirte/mirte_ws/src/mirte_bringup/launch/minimal.launch