robot Package

robot Module

class pypot.robot.robot.Robot(motor_controllers=[], sensor_controllers=[], sync=True)[source]

Bases: object

This class is used to regroup all motors and sensors of your robots.

Most of the time, you do not want to directly instantiate this class, but you rather want to use a factory which creates a robot instance - e.g. from a python dictionnary (see Writing the configuration).

This class encapsulates the different controllers (such as dynamixel ones) that automatically synchronize the virtual sensors/effectors instances held by the robot class with the real devices. By doing so, each sensor/effector can be synchronized at a different frequency.

This class also provides a generic motors accessor in order to (more or less) easily extends this class to other types of motor.

Parameters:
  • motor_controllers (list) – motors controllers to attach to the robot
  • sensor_controllers (list) – sensors controllers to attach to the robot
  • sync (bool) – choose if automatically starts the synchronization loops
close()[source]

Cleans the robot by stopping synchronization and all controllers.

start_sync()[source]

Starts all the synchonization loop (sensor/effector controllers).

stop_sync()[source]

Stops all the synchonization loop (sensor/effector controllers).

attach_primitive(primitive, name)[source]
motors

Returns all the motors attached to the robot.

sensors

Returns all the sensors attached to the robot.

active_primitives

Returns all the primitives currently running on the robot.

primitives

Returns all the primitives name attached to the robot.

compliant

Returns a list of all the compliant motors.

goto_position(position_for_motors, duration, control=None, wait=False)[source]

Moves a subset of the motors to a position within a specific duration.

Parameters:
  • position_for_motors (dict) – which motors you want to move {motor_name: pos, motor_name: pos,…}
  • duration (float) – duration of the move
  • control (str) – control type (‘dummy’, ‘minjerk’)
  • wait (bool) – whether or not to wait for the end of the move
power_up()[source]

Changes all settings to guarantee the motors will be used at their maximum power.

to_config()[source]

Generates the config for the current robot.

Note

The generated config should be used as a basis and must probably be modified.

motor Module

class pypot.robot.motor.Motor(name)[source]

Bases: object

Purely abstract class representing any motor object.

registers = []
name

sensor Module

class pypot.robot.sensor.Sensor(name)[source]

Bases: object

Purely abstract class representing any sensor object.

registers = []
name
class pypot.robot.sensor.ObjectTracker(name)[source]

Bases: pypot.robot.sensor.Sensor

registers = ['position', 'orientation']
position
orientation

controller Module

class pypot.robot.controller.AbstractController(io, sync_freq)[source]

Bases: pypot.utils.stoppablethread.StoppableLoopThread

Abstract class for motor/sensor controller.

The controller role is to synchronize the reading/writing of a set of instances with their “hardware” equivalent through an AbstractIO object. It is defined as a StoppableLoopThread where each loop update synchronizes values from the “software” objects with their “hardware” equivalent.

To define your Controller, you need to define the update() method. This method will be called at the predefined frequency. An exemple of how to do it can be found in BaseDxlController.

Parameters:
  • io (AbstractIO) – IO used to communicate with the hardware motors
  • sync_freq (float) – synchronization frequency
start()[source]

Start the run method as a new thread.

It will first stop the thread if it is already running.

close()[source]

Cleans and closes the controller.

class pypot.robot.controller.MotorsController(io, motors, sync_freq=50)[source]

Bases: pypot.robot.controller.AbstractController

Abstract class for motors controller.

The controller synchronizes the reading/writing of a set of motor instances with their “hardware”. Each update loop synchronizes values from the “software” DxlMotor with their “hardware” equivalent.

Parameters:
  • io (AbstractIO) – IO used to communicate with the hardware motors
  • motors (list) – list of motors attached to the controller
  • sync_freq (float) – synchronization frequency
class pypot.robot.controller.DummyController(motors)[source]

Bases: pypot.robot.controller.MotorsController

setup()[source]

Setup method call just before the run.

update()[source]

Update method called at the pre-defined frequency.

class pypot.robot.controller.SensorsController(io, sensors, sync_freq=50.0)[source]

Bases: pypot.robot.controller.AbstractController

Abstract class for sensors controller.

The controller frequently pulls new data from a “real” sensor and updates its corresponding software instance.

Parameters:
  • io (AbstractIO) – IO used to communicate with the hardware motors
  • sensors (list) – list of sensors attached to the controller
  • sync_freq (float) – synchronization frequency

io Module

class pypot.robot.io.AbstractIO[source]

Bases: object

AbstractIO class which handles communication with “hardware” motors.

close()[source]

Clean and close the IO connection.

config Module

The config module allows the definition of the structure of your robot.

Configuration are written as Python dictionary so you can define/modify them programmatically. You can also import them form file such as JSON formatted file. In the configuration you have to define:

  • controllers: For each defined controller, you can specify the port name, the attached motors and the synchronization mode.
  • motors: You specify all motors belonging to your robot. You have to define their id, type, orientation, offset and angle_limit.
  • motorgroups: It allows to define alias of group of motors. They can be nested.
pypot.robot.config.from_config(config, strict=True, sync=True, use_dummy_io=False, **extra)[source]

Returns a Robot instance created from a configuration dictionnary.

Parameters:
  • config (dict) – robot configuration dictionary
  • strict (bool) – make sure that all ports, motors are availaible.
  • sync (bool) – choose if automatically starts the synchronization loops

For details on how to write such a configuration dictionnary, you should refer to the section Writing the configuration.

pypot.robot.config.motor_from_confignode(config, motor_name)[source]
pypot.robot.config.sensor_from_confignode(config, s_name, robot)[source]
pypot.robot.config.dxl_io_from_confignode(config, c_params, ids, strict)[source]
pypot.robot.config.check_motor_eprom_configuration(config, dxl_io, motor_names)[source]

Change the angles limits depanding on the robot configuration ; Check if the return delay time is set to 0.

pypot.robot.config.instatiate_motors(config)[source]
pypot.robot.config.make_alias(config, robot)[source]
pypot.robot.config.from_json(json_file, sync=True, strict=True, use_dummy_io=False, **extra)[source]

Returns a Robot instance created from a JSON configuration file.

For details on how to write such a configuration file, you should refer to the section Writing the configuration.

pypot.robot.config.use_dummy_robot(json_file)[source]

remote Module

class pypot.robot.remote.RemoteRobotClient(host, port)[source]

Bases: object

Remote Access to a Robot through the REST API.

This RemoteRobot gives you access to motors and alias. For each motor you can read/write all of their registers.

You also have access to primitives. More specifically you can start/stop them.

pypot.robot.remote.from_remote(host, port)[source]

Remote access to a Robot through the REST API.