Python API Reference

class reynard_the_robot.Reynard(host='localhost', port=29201)

The Reynard class implements Reynard the Robot. Reynard the Robot is a simple two dimensional 5 degree of freedom cartoon robot. It is intended to be used as a simple target device for learning Robot Raconteur and other robotics software.

The GUI interface is accessed using a standard web browser with the URL http://localhost:29201. The host and port can be changed when constructing the Reynard object using the host and port parameters.

Reynard the Robot is implemented as a simple web server using the aiohttp and python-socketio libraries. Reynard can be controlled directly using the Python API, or through the other communication methods provided by the Python package. Reynard the Robot provides the following interactions:

  • teleport: Move Reynard to a new position instantly

  • say: Make Reynard say a message

  • drive_robot: Drive Reynard’s base in the x and y directions at a given velocity

  • set_arm_position: Set the position of Reynard’s arm joints instantly

  • drive_arm: Drive Reynard’s arm joints at a given velocity

  • arm_position: Get the current position of Reynard’s arm joints

  • robot_position: Get the current position of Reynard’s base

  • robot_velocity: Get the current velocity of Reynard’s base

  • arm_velocity: Get the current velocity of Reynard’s arm joints

  • time: Get the current simulation time in seconds

  • color: Get or set the color of Reynard’s body as an RGB tuple between 0 and 1

  • new_message: Signal that is emitted when a new message is received from the API

The Reynard class can be used with AIO or with the standard Python threading model. When used with AIO, the methods starting with aio_ should be used. When used with the standard Python threading model, the methods without aio_ should be used.

The start or aio_start method must be called to start the Reynard server. The close method should be called to stop the Reynard server.

Parameters:
  • host (str) – The host to bind the Reynard server to. Default is localhost. Set to 0.0.0.0 to bind to all interfaces.

  • port (int) – The port to bind the Reynard server to. Default is 29201.

async aio_drive_arm(q1, q2, q3, timeout=-1, wait=False)

AIO version of drive_arm. Drive Reynard’s arm joints at a given angular velocity. Use with await in an async function.

Parameters:
  • q1 (float) – The angular velocity of the first arm joint in degrees per second

  • q2 (float) – The angular velocity of the second arm joint in degrees per second

  • q3 (float) – The angular velocity of the third arm joint in degrees per second

async aio_drive_robot(vel_x, vel_y, timeout=-1, wait=False)

AIO version of drive_robot. Drive Reynard’s base in the x and y directions at a given velocity. Use with await in an async function.

Parameters:
  • vel_x (float) – The velocity in the x direction in millimeters per second

  • vel_y (float) – The velocity in the y direction in millimeters per second

  • timeout (float) – The time to drive Reynard at the given velocity. If timeout is greater than 0, Reynard will stop after the given time. If timeout is less than 0, Reynard will continue indefinitely. Default is -1.

  • wait – If wait is True, the function will wait until the timeout has expired before returning. Default is False.

async aio_say(message)

AIO version of say. Make Reynard say a message. Use with await in an async function.

Parameters:

message (str) – The message to say

async aio_set_arm_position(q1, q2, q3)

AIO version of set_arm_position. Set the position of Reynard’s arm joints instantly. Use with await in an async function.

Parameters:
  • q1 (float) – The position of the first arm joint in degrees

  • q2 (float) – The position of the second arm joint in degrees

  • q3 (float) – The position of the third arm joint in degrees

async aio_set_color(r, g, b)

“AIO version of property set color. Set the color of Reynard’s body as an RGB tuple between 0 and 1. Use with await in an async function.

Parameters:
  • r (float) – The red component of the color between 0 and 1

  • g (float) – The green component of the color between 0 and 1

  • b (float) – The blue component of the color between 0 and 1

async aio_start()

AIO version of start. Must be called to start the Reynard server. Use with await in an async function.

async aio_teleport(x, y)

AIO version of teleport. Teleport Reynard to a new position instantly. Use with await in an async function.

Parameters:
  • x (float) – The x position to teleport Reynard to in millimeters

  • y (float) – The y position to teleport Reynard to in millimeters

property arm_position

Get the current position of Reynard’s arm joints in degrees.

property arm_velocity

Get the current velocity of Reynard’s arm joints.

close()

Close the Reynard server. This synchronous method should be used with the standard Python threading model. This is not needed when using AIO.

property color

Get or set the color of Reynard’s body as an RGB tuple between 0 and 1. Use aio_set_color to set the color when using AIO.

drive_arm(q1, q2, q3, timeout=-1, wait=False)

Drive Reynard’s arm joints at a given angular velocity.

Parameters:
  • q1 (float) – The angular velocity of the first arm joint in degrees per second

  • q2 (float) – The angular velocity of the second arm joint in degrees per second

  • q3 (float) – The angular velocity of the third arm joint in degrees per second

  • timeout (float) – The time to drive Reynard at the given velocity. If timeout is greater than 0, Reynard will stop after the given time. If timeout is less than 0, Reynard will continue indefinitely. Default is -1.

  • wait – If wait is True, the function will wait until the timeout has expired before returning. Default is False.

drive_robot(vel_x, vel_y, timeout=-1, wait=False)

Drive Reynard’s base in the x and y directions at a given velocity.

Parameters:
  • vel_x (float) – The velocity in the x direction in millimeters per second

  • vel_y (float) – The velocity in the y direction in millimeters per second

  • timeout (float) – The time to drive Reynard at the given velocity. If timeout is greater than 0, Reynard will stop after the given time. If timeout is less than 0, Reynard will continue indefinitely. Default is -1.

  • wait (bool) – If wait is True, the function will wait until the timeout has expired before returning. Default is False.

property new_message

Event for new messages received from the API. Connect to this event to receive new messages. This property is a blinker signal. Use the connect method to connect to the signal.

property robot_position

Get the current position of Reynard’s base.

property robot_velocity

Get the current velocity of Reynard’s base.

say(message)

Make Reynard say a message.

Parameters:

message (str) – The message to say

set_arm_position(q1, q2, q3)

Instantly set the position of Reynard’s arm joints.

Parameters:
  • q1 (float) – The position of the first arm joint in degrees

  • q2 (float) – The position of the second arm joint in degrees

  • q3 (float) – The position of the third arm joint in degrees

start()

Start the Reynard server. This synchronous method should be used with the standard Python threading model. A thread will be created to run the server. If you are using AIO, use aio_start instead. The AIO version will use the asyncio event loop to run the server instead of a thread.

teleport(x, y)

Instantly move Reynard to a new position.

Parameters:
  • x (float) – The x position to teleport Reynard to in millimeters

  • y (float) – The y position to teleport Reynard to in millimeters

property time

Get the current simulation time in seconds. The simulation time starts at 0 when the server is started.