Skip to content
Matteo Caravati edited this page Aug 8, 2023 · 2 revisions

SP//dr for Python

SP//dr provides an easy-to-use Python library for you to interact with your Poppy Ergo Jr robot.

Installation

Requirements

Installation

To install the Python library, you simply have to go in the creative-extensions/python directory then execute the following command:

python setup.py install

And that's it !

Usage

To import the Client class into your Python script, you need to add the following line:

from ergojunior.client import Client

To be able to communicate with the robot, you need to create a new instance of the class:

host = '127.0.0.1' # The address of the machine hosting the control server
port = 9000 # The port on which the server is listening
client = Client(host, port)

You should now be able to send commands to the server.

API

Client

Client(host: str, port: int) -> Client

Creates a new Client instance. The host and port parameters are the IP address and port of the OSC server connected to the Poppy Ergo Jr robot.

set_motor(motor_id: int, angle: float) -> None

Sets the angle of the motor with the given motor_id to the given angle. The motor_id must be between 1 and 6. The angle must be a float.

toggle_led(motor_id: int, state: bool) -> None

Turns on or off the LED of the motor with the given motor_id. The motor_id must be between 1 and 6. The state must be a boolean, True to turn on the LED, False to turn it off.

toggle_torque(motor_id: int, state: bool) -> None

Turns on or off the torque of the motor with the given motor_id. The motor_id must be between 1 and 6. The state must be a boolean, True to turn on the torque, False to turn it off.

set_speed(motor_id: int, speed: int) -> None

Sets the speed of the motor with the given motor_id to the given speed. The motor_id must be between 1 and 6. The speed must be a 32-bits integer.

inverse_kinematics(x: float, y: float, z: float) -> None

Computes the motor angles for the robot to reach the given 3D position before moveing it. x, y and z must be floats.