Skip to main content

Task Python API

pycm Module

Here we introduce two ways to use pycm module.

import pycm # pycm should NOT be omitted in the following code

pycm.led.on(pycm.const.RED)
from pycm import * # pycm should be omitted in the following code

led.on(const.RED)

We assume the SECOND case in the following description.

MethodsDescriptionParameterReturnExample
console(ch: int) -> NoneConfigure controller's communication channelBLE (0)<br>UART (1)<br>USB (2)Noneconsole(BLE)
delay(ms: int) -> NoneDelay in milliseconds0 ~ 4,294,967,295Nonedelay(1000)
millis() -> NoneMilliseconds since controller turns onNone0 ~ 4294967295pre_time = millis()
micros() -> NoneMicroseconds since controller turns onNone0 ~ 4294967295pre_time = micros()

Submodules of pycm

Submodules of pycmDescription
constConstant values
ledLED control
infoController's information
eepromController's parameters stored in EEPROM area
rcRemote control
etcMiscellaneous functions
timerTimer functions
buttonButtons
dxlbusBatch controlling Dynamixel actuators
motionMotion control
buzzerBuzzer
micMicrophone
imuIMU(Inertial Measurement Unit)
OLLO5-pin port extension interface
DXLDynamixel actuator
rpiRaspberry Pi interface

Const Submodule

Constant members of constDescriptionExample
REDRed color constant for controller's RGB LEDled.on(const.RED)
GREENGreen color constant for controller's RGB LEDled.on(const.GREED)
BLUEBlue color constant for controller's RGB LEDled.on(const.BLUE)
ALLWhite color constant for controller's RGB LEDled.on(const.ALL)
OLLO_WHEEL_SPEEDUse 5-pin servo motor in wheel modewheel = OLLO(1, const.OLLO_WHEEL_SPEED)
OLLO_JOINT_POSITIONUse 5-pin servo motor in joint mode and control its positionjoint = OLLO(1, const.OLLO_JOINT_POSITION)
OLLO_JOINT_SPEEDUse 5-pin servo motor in joint mode and control its speedspeed = OLLO(1, const.OLLO_JOINT_SPEED)
OLLO_IRIR sensor 5-pin deviceir = OLLO(1, const.OLLO_IR)
OLLO_DMSDMS sensor 5-pin devicedms = OLLO(1, const.OLLO_DMS)
OLLO_TOUCHTouch sensor 5-pin devicetouch = OLLO(1, const.OLLO_TOUCH)
OLLO_LEDLED module 5-pin deviceled = OLLO(1, const.OLLO_LED)
OLLO_USER5-pin user deviceuser = OLLO(1, const.OLLO_USER)
OLLO_TEMPERATURETemperature sensor 5-pin devicetemperature = OLLO(1, const.OLLO_TEMPERATURE)
OLLO_MAGNETMagnet sensor 5-pin devicemagnet = OLLO(1, const.OLLO_MAGNET)
OLLO_MOTION_DETECTIONMotion detecting sensor 5-pin devicemotion_detection = OLLO(1, const.OLLO_MOTION_DETECTION)
OLLO_COLORColor sensor 5-pin devicecolor = OLLO(1, const.OLLO_COLOR)
OLLO_MOISTUREMoisture value of Moisture-Temperature sensor 5-pin devicemoisture = OLLO(1, const.OLLO_MOISTURE)
OLLO_MOISTURE_TEMPTemperature value of Moisture-Temperature sensor 5-pin devicetemperature = OLLO(1, const.OLLO_MOISTURE_TEMP)
OLLO_BRIGHTNESSBrightness sensor 5-pin devicebrightness = OLLO(1, const.OLLO_BRIGHTNESS)
OLLO_RED_BRIGHTNESSBrightness of red LED of Red-Blue LEDred = OLLO(1, const.OLLO_RED_BRIGHTNESS)
OLLO_BLUE_BRIGHTNESSBrightness of blue LED of Red-Blue LEDblue = OLLO(1, const.OLLO_BLUE_BRIGHTNESS)
VVertical mode imu.imu_type(const.V)
HHorizontal mode imu.imu_type(const.H)
JOINTJoint mode of Dynamixel actuatorDXL(2).mode(const.JOINT)
WHEELWheel mode of Dynamixel actuatorDXL(3).mode(const.WHEEL)

Led Submodule

MethodsDescriptionParameterReturnExample
on(color: int) -> NoneTurn on specified color of controller's LEDcolor: LED name<br>- const.RED / const.BLUE / const.GREENNoneled.on(const.RED)
off(color: int) -> NoneTurn off specified color of controller's LEDcolor: LED name<br>- const.RED / const.BLUE / const.GREENNoneled.off(const.RED | const.GREEN)
set(color: int) -> NoneSet controller's LED as specified colorcolor: LED name<br>- const.RED / const.BLUE / const.GREENNoneled.set(const.BLUE)
toggle(color: int) -> NoneToggle specified color of controller's LEDcolor: LED name<br>- const.RED / const.BLUE / const.GREENNoneled.toggle(const.GREEN | const.BLUE)

Info Submodule

Methods of info submobuleDescriptionExample
model_number() -> intReturn controller's model number (450)info.model_number()
fw_version() -> intReturn controller's firmware versioninfo.fw_version()
id() -> intReturn controller's id (200)info.id()
boot_version() -> intReturn controller's bootloader versioninfo.boot_version()
voltage() -> intReturn controller's voltage (unit: 0.1V)info.voltage()
temperature() -> intReturn controller's temperature (unit: °C)info.temperature()
address() -> strReturn controller's BLE MAC address as stringinfo.address()

EEPROM Submodule

Methods of eeprom submobuleDescriptionParameterReturnExample
dxl_baud() -> int Return controller's dynamixel bus baudrateNone0 : 9600bps<br>1 : 57600bps<br>2 : 115200bps<br>3 : 1000000bps<br>4 : 2000000bps<br>5 : 3000000bps<br>6 : 4000000bps<br>7 : 4500000bpseeprom.dxl_baud()
dxl_baud(baud: int) -> NoneSet controller's dynamixel bus baudrate0 : 9600bps<br>1 : 57600bps<br>2 : 115200bps<br>3 : 1000000bps<br>4 : 2000000bps<br>5 : 3000000bps<br>6 : 4000000bps<br>7 : 4500000bpsNoneeeprom.dxl_baud(3)
uart_baud() -> intReturn controller's uart port baudrateNone0 : 9600bps<br>1 : 57600bps<br>2 : 115200bps<br>3 : 1000000bps<br>4 : 2000000bps<br>5 : 3000000bps<br>6 : 4000000bps<br>7 : 4500000bpseeprom.uart_baud()
uart_baud(baud: int) -> NoneSet controller's uart port baudrate0 : 9600bps<br>1 : 57600bps<br>2 : 115200bps<br>3 : 1000000bps<br>4 : 2000000bps<br>5 : 3000000bps<br>6 : 4000000bps<br>7 : 4500000bpsNoneeeprom.uart_baud(1)
imu_type() -> intReturn controller's imu direction typeNone0 : VERTICAL<br>1 : HORIZONTALeeprom.imu_type()
imu_type(type:int) -> NoneSet controller's imu direction typeconst.V<br>const.HNoneeeprom.imu_type(const.V)

RC Submodule

Methods of rc submobuleDescriptionParameterReturnExample
port(ch: int) -> NoneSet controller's remote control channelBLE (0)<br>UART (1)<br>USB (2)Nonerc.port(BLE)
received() -> boolReturn if reveived a new remote control packetNoneTrue : new packet arrived<br>False : new packet not arrivedrc.received()
read() -> intReturn last received remote control packet valueNone0 ~ 65535rc.read()
write(data: int) -> NoneSend remote control packet value0 ~ 65535Nonerc.write(128)

Etc Submodule

Methods of etc submobuleDescriptionParameterReturnExample
print_screen(val: int) -> NonePrint an integer value to task monitor with a space-2,147,483,647 ~ 2,147,483,647Noneetc.print_screen(100)
println_screen(val: int) -> NonePrint an integer value to task monitor with a new line-2,147,483,647 ~ 2,147,483,647Noneetc.println_screen(100)
print_string(str: str) -> NonePrint a string to task monitor with a spacemax 19 bytesNoneetc.print_string("Hello world!")
println_string(str: str) -> NonePrint a string to task monitor with a new linemax 19 bytesNoneetc.println_string("Hello world!")
port(ch: int) -> NoneSet controller's print screen channelBLE (0)<br>UART (1)<br>USB (2)Noneetc.port(BLE)

Timer Submodule

Methods of etc submobuleDescriptionParameterReturnExample
init(ms: int, func: function) -> NoneRegister a callback function which will be called periodically<br>Only one function can be registeredms<br>function calling period in millisecond<br>func<br>function to be calledNonetimer.init(1000, func)
start() -> NoneStart the registered function callback processNoneNonetimer.start()
stop() -> Nonestop the registered function callback processNoneNonetimer.stop()

Button Submodule

Methods of button submobuleDescriptionParameterReturnExample
pressed() -> bool Return if controller's user button is pressedNoneTrue : pressed<br>False : not pressedbutton.pressed()
released() -> bool Return if controller's user button is released after pressedNoneTrue : release event happened<br>False : release event not happenedbutton.released()
millis() -> int Return last pressed time in millisecondsNone0 ~ 65535button.millis()
seconds() -> int Return last pressed time in secondsNone0 ~ 255button.seconds()

Dxlbus Submodule

Methods of dxlbus submobuleDescriptionParameterReturnExample
power_on() -> None Turn on power for dynamixel busNoneNonedxlbus.power_on()
power_off() -> None Turn off power for dynamixel busNoneNonedxlbus.power_off()
scan() -> int Scan dynamixels, return the number of dynamixels foundNone0 ~ 253dxlbus.scan()
count() -> int Return the number of found dynamixel(s)None0 ~ 253dxlbus.count()
torque_on() -> None Turn on torque for all found dynamixel(s)NoneNonedxlbus.torque_on()
torque_off() -> None Turn off torque for all found dynamixel(s)NoneNonedxlbus.torque_off()
reboot() -> None Reboot all dynamixel(s)NoneNonedxlbus.reboot()

Motion Submodule

Methods of motion submobuleDescriptionParameterReturnExample
speed() -> int Return motion speed (%)None20% ~ 200%motion.speed()
speed(speed: int) -> int Set motion speed (%)20% ~ 200%Nonemotion.speed(150)
play(motion: int) -> None Play a specified motion page or stop current motion0 : Stop motion using an Exit Motion Unit<br>1~65532 : Play motion with a specified page<br>65533 : Stop motion immediately<br>65534 : Stop motion at the current Key Frame<br>65535 : Stop motion at current unitNonemotion.play(1)
play(motion: int, next: int) -> None Play a specified motion with a motion reserved for playing contiguouslymotion<br>0 : Stop motion using an Exit Motion Unit<br>165532 : Play motion with a specified page<br>65533 : Stop motion immediately<br>65534 : Stop motion at the current Key Frame<br>65535 : Stop motion at current unit<br><br>next<br>065534 : Page to move next.<br>65535 : No next pageNonemotion.play(1, 2)
next(next: int) -> None Reserve the next motion to play contiguously. This function must be used before motion.play(motion)next<br>0~65534 : Page to move next.<br>65535 : No next pageNonemotion.next(2)
status() -> bool Return motion play statusNoneTrue : Motion is being played<br>False : Motion is NOT being playedmotion.status()
count() -> int Return the number of motions stored in FLASH memoryNone0 ~ 1023motion.count()
wait() -> None Wait until current motion stops playingNoneNonemotion.wait()

Buzzer Submodule

Methods of buzzer submobuleDescriptionParameterReturnExample
melody(index) -> None Play the specified melody by index.0 ~ 25Nonebuzzer.melody(1)
note(index) -> None Play the specified note by index for 0.3 sec0 ~ 51Nonebuzzer.note(1)
note(index, ms) -> None Play the specified note by index for specified time lengthindex<br> 0 ~ 51<br>ms(unit: 0.1s)<br>0 ~ 50 : 0 ~ 5.0sbuzzer.note(1, 10)
wait() -> None Wait until current melody or note endsNoneNonebuzzer.wait()

Mic Submodule

Methods of mic submobuleDescriptionParameterReturnExample
counted() -> int Return the final number of detected sound after the clapping finishesNone0 ~ 255mic.counted()
counting() -> int Return the real-time number of detected sound while the clapping continuesNone0 ~ 255mic.counting()
clear() -> int Clear the final number of detected sound to zeroNoneNonemic.clear()

IMU Submodule

Methods of imu submobuleDescriptionParameterReturnExample
roll() -> int Return the roll value of CM-550 controllerNone-18000 ~ 18000imu.roll()
pitch() -> int Return the pitch value of CM-550 controllerNone-9000 ~ 9000imu.pitch()
yaw() -> int Return the yaw value of CM-550 controllerNone-9000 ~ 9000imu.yaw()
gyro_x() -> int Return the Gyro X axis value of CM-550 controllerNone-32768 ~ 32767 (unit: 0.01degree/sec)imu.gyro_x()
gyro_y() -> int Return the Gyro Y axis value of CM-550 controllerNone-32768 ~ 32767 (unit: 0.01degree/sec)imu.gyro_y()
gyro_z() -> int Return the Gyro Z axis value of CM-550 controllerNone-32768 ~ 32767 (unit: 0.01degree/sec)imu.gyro_z()
accel_x() -> int Return the accelerometer X axis value of CM-550 controllerNone-32768 ~ 32767 (unit: 0.01G)imu.accel_x()
accel_y() -> int Return the accelerometer Y axis value of CM-550 controllerNone-32768 ~ 32767 (unit: 0.01G)imu.accel_y()
accel_z() -> int Return the accelerometer Z axis value of CM-550 controllerNone-32768 ~ 32767 (unit: 0.01G)imu.accel_z()

OLLO Submodule

Methods of OLLO submobuleDescriptionParameterReturnExample
OLLO(port, mode) -> objectCreate an object with Port Number and Device Modemode<br> const.OLLO_WHEEL_SPEED (port: 1 ~ 2)<br>const.OLLO_JOINT_POSITION (port: 1 ~ 2)<br>const.OLLO_JOINT_SPEED (port: 1 ~ 2)<br>const.OLLO_IR (port: 1 ~ 2)<br>const.OLLO_MOISTURE (port: 1 ~ 2)<br>const.OLLO_MOISTURE_TEMP (port: 1 ~ 2)<br>const.OLLO_RED_BRIGHTNESS (port: 1 ~ 2)<br>const.OLLO_BLUE_BRIGHTNESS (port: 1 ~ 2)<br>const.OLLO_DMS (port: 1 ~ 5)<br>const.OLLO_TOUCH (port: 1 ~ 5)<br>const.OLLO_LED (port: 1 ~ 5)<br>const.OLLO_USER (port: 1 ~ 5)<br>const.OLLO_TEMPERATURE (port: 1 ~ 5)<br>const.OLLO_MAGNET (port: 1 ~ 5)<br>const.OLLO_MOTION_DETECTION (port: 1 ~ 5)<br>const.OLLO_COLOR (port: 1 ~ 5)<br>const.OLLO_BRIGHTNESS (port: 1 ~ 5)<br>5-pin port objectobj = OLLO(1, OLLO_WHEEL_SPEED)
read() -> int Return the value of objectNone0 ~ 2047 (mode: const.OLLO_WHEEL_SPEED)<br>0 ~ 1023 (mode: const.OLLO_JOINT_POSITION)<br>0 ~ 1023 (mode: const.OLLO_JOINT_SPEED)<br>0 ~ 1023 (mode: const.OLLO_IR)<br>0 ~ 100 (mode: const.OLLO_MOISTURE, unit: %)<br>-19 ~ 105 (mode: const.OLLO_MOISTURE_TEMP, unit: ℃)<br>0 ~ 100 (mode: const.OLLO_RED_BRIGHTNESS, unit: %)<br>0 ~ 100 (mode: const.OLLO_BLUE_BRIGHTNESS, unit: %)<br>0 ~ 1023 (mode: const.OLLO_DMS)<br>0, 1 (mode: const.OLLO_TOUCH)<br>0 ~ 3 (mode: const.OLLO_LED)<br>0 ~ 1023 (mode: const.OLLO_USER)<br>-20 ~ 120 (mode: const.OLLO_TEMPERATURE, unit: ℃)<br>0, 1 (mode: const.OLLO_MAGNET)<br>0 ~ 1 (mode: const.OLLO_MOTION_DETECTION)<br>0 ~ 6 (mode: const.OLLO_COLOR)<br>0 ~ 100 (mode: const.OLLO_BRIGHTNESS, unit: %)<br>obj.read()
write(speed) -> None Set wheel speed of object of wheel mode<br>(mode: const.OLLO_WHEEL_SPEED)0 ~ 1023 : CCW (Counter clock wise) speed<br>1024 ~ 2047 : CW (Clockwise) speedNoneobj.write(512)
write(position) -> None Set joint poistion of object of joint mode<br>(mode: const.OLLO_JOINT_POSITION)0 ~ 1023Noneobj.write(512)
write(speed) -> None Set moving speed of object of joint mode<br>(mode: const.OLLO_JOINT_POSITION)0 ~ 1023Noneobj.write(256)
write(pwm) -> None Set pwm duty cycle of object of LED brightness mode<br>(mode: const.OLLO_RED_BRIGHTNESS / OLLO_BLUE_BRIGHTNESS)0 ~ 100 (unit: %)Noneobj.write(50)
write(left, right) -> None Set LED status of left and right LED of LED module<br>(mode: const.OLLO_LED)0, 1Noneobj.write(1, 0)
write(left, right) -> None Set LED status of left and right output port of User Device<br>(mode: const.OLLO_USER)0, 1Noneobj.write(1, 1)

DXL Submodule

Methods of DXL submobuleDescriptionParameterReturnExample
DXL(id) -> object Create an Dynamixel object with specified ID0 ~ 252 : Single ID<br>254 : Broadcast IDDynamixel objectobj = DXL(1)
mode() -> int Return mode number of Dynamixel objectNone1 : Velocity Control Mode<br>3 : Position Control Mode<br>4 : Multi-turn Mode<br>obj.mode()
mode(mode) -> None Set mode for Dynamixel object1 : Velocity Control Mode<br>3 : Position Control Mode<br>4 : Multi-turn Mode<br>Noneobj.mode(3)
torque_on() -> None Turn on torque for Dynamixel objectNoneNoneobj.torque_on()
torque_off() -> None Turn off torque for Dynamixel objectNoneNoneobj.torque_off()
led_on() -> None Turn on LED for Dynamixel objectNoneNoneobj.led_on()
led_off() -> None Turn off LED for Dynamixel objectNoneNoneobj.led_off()
led_toggle() -> None Toggle LED for Dynamixel objectNoneNoneobj.led_toggle()
goal_velocity() -> int Return goal velocity valueNone-1023 ~ 1023 (unit: 0.229 rev/min)obj.goal_velocity()
goal_velocity(v) -> None Set goal velocity value-1023 ~ 1023 (unit: 0.229 rev/min)Noneobj.goal_velocity(100)
goal_position() -> int Return goal position valueNone-4095 ~ 4095obj.goal_position()
goal_position(p) -> None Set goal position value-4095 ~ 4095Noneobj.goal_position(1024)
is_moving() -> bool Return moving statusNoneTrue : Dynamixel is moving<br>False : Dyanmixel is not movingobj.is_moving()
present_velocity() -> int Return present velocity valueNone-1023 ~ 1023 (unit: 0.229 rev/min)obj.present_velocity()
present_position() -> int Return present position valueNone-4095 ~ 4095obj.present_position()

RPI Submodule

Methods of rpi submoduleDescriptionParameterReturnExample
mode() -> intReturn mode number of connected Raspberry PiNone0 : Standby<br>1 : Color Detection<br>2 : Face Detection<br>3 : Streamingrpi.mode()
mode(mode: int) -> NoneSet the mode of the connected Raspberry Pimode<br>0 : Standby<br>1 : Color Detection<br>2 : Face Detection<br>3 : StreamingNonerpi.mode(1)
sub_mode() -> intReturn the sub-mode of the current mode<br>(only for Color Detection Mode)None1 : Red<br>2 : Orange<br>3 : Yellow<br>4 : Green<br>5 : Blue<br>6 : Purple<br>7 : Whiterpi.sub_mode()
sub_mode(mode: int) -> NoneSet the sub-mode of the current mode<br>(only for Color Detection Mode)mode<br>1 : Red<br>2 : Orange<br>3 : Yellow<br>4 : Green<br>5 : Blue<br>6 : Purple<br>7 : WhiteNonerpi.sub_mode(1)
ip() -> tupleReturn the IP address of the connected Raspberry Pi as a tuple with 4 integersNoneIP address as a tuple<br>eg. (192, 168, 13, 5)rpi.ip()
position_x() -> intReturn the x-coordinate of the camera detection positionNoneX-coordinate valuerpi.position_x()
position_y() -> intReturn the y-coordinate of the camera detection positionNoneY-coordinate valuerpi.position_y()
area() -> intReturn the detection area of the cameraNoneArea valuerpi.area()
resolution_w() -> intReturn the width of the camera resolutionNoneWidth in pixelsrpi.resolution_w()
resolution_h() -> intReturn the height of the camera resolutionNoneHeight in pixelsrpi.resolution_h()
h_max() -> intReturn the maximum hue value for color detectionNone0 ~ 179rpi.h_max()
h_max(h_max: int) -> NoneSet the maximum hue value for color detection0 ~ 179Nonerpi.h_max(179)
h_min() -> intReturn the minimum hue value for color detectionNone0 ~ 179rpi.h_min()
h_min(h_min: int) -> NoneSet the minimum hue value for color detection0 ~ 179Nonerpi.h_min(0)
s_max() -> intReturn the maximum saturation value for color detectionNone0 ~ 255rpi.s_max()
s_max(s_max: int) -> NoneSet the maximum saturation value for color detection0 ~ 255Nonerpi.s_max(255)
s_min() -> intReturn the minimum saturation value for color detectionNone0 ~ 255rpi.s_min()
s_min(s_min: int) -> NoneSet the minimum saturation value for color detection0 ~ 255Nonerpi.s_min(0)
v_max() -> intReturn the maximum value (brightness) for color detectionNone0 ~ 255rpi.v_max()
v_max(v_max: int) -> NoneSet the maximum value (brightness) for color detection0 ~ 255Nonerpi.v_max(255)
v_min() -> intReturn the minimum value (brightness) for color detectionNone0 ~ 255rpi.v_min()
v_min(v_min: int) -> NoneSet the minimum value (brightness) for color detection0 ~ 255Nonerpi.v_min(0)