NiryoRobot

The NiryoRobot class includes the different APIs of the PyNiryo2 library. It allows the connection of the program to the robot via roslibpy. This interface facilitates and centralizes all the control functions of the Niryo environment and products.

NiryoRobot - Command functions

This section reference all existing functions of the NiryoRobot client, which include

  • Connecting to your Ned

  • Disconnecting from your Ned

  • Waiting

  • Access to the entire PyNiryo2 API

All functions to control the robot are accessible via an instance of the class NiryoRobot

robot = NiryoRobot(<robot_ip_address>)

robot.run("10.10.10.10")
robot.wait(2) # wait 2 seconds
robot.end()

See examples on Examples Section

List of functions subsections:

NiryoRobot functions

class NiryoRobot(ip_address='127.0.0.1', port=9090)[source]

Connect your robot to your computer:

robot_simulation = NiryoRobot("127.0.0.1") # Simulation

robot_hotpot = NiryoRobot("10.10.10.10") # Hotspot

robot_ethernet = NiryoRobot("169.254.200.201") # Ethernet
Parameters
  • ip_address (str) – robot ROS ip

  • port (int) – robot ROS port

property client

Get the Niryo Ros client

Returns

NiryoRos client

Return type

NiryoRos

end()[source]

Disconnect from your robot and ROS:

# Start
robot = NiryoRobot("10.10.10.10")

# End
robot.end()
Return type

None

static wait(duration)[source]

Wait for a certain time

Parameters

duration (float) – duration in seconds

Return type

None

NiryoRobot properties

class NiryoRobot(ip_address='127.0.0.1', port=9090)[source]

Connect your robot to your computer:

robot_simulation = NiryoRobot("127.0.0.1") # Simulation

robot_hotpot = NiryoRobot("10.10.10.10") # Hotspot

robot_ethernet = NiryoRobot("169.254.200.201") # Ethernet
Parameters
  • ip_address (str) – robot ROS ip

  • port (int) – robot ROS port

property arm

Access to the Arm API

Example:

robot = NiryoRobot(<robot_ip_address>)
robot.arm.calibrate_auto()
robot.arm.move_joints([0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
Return type

Arm

property conveyor

Access to the Conveyor API

Example:

robot = NiryoRobot(<robot_ip_address>)
conveyor_id = robot.conveyor.set_conveyor()
robot.conveyor.run_conveyor(conveyor_id)
Return type

Conveyor

property io

Access to the I/Os API

Example:

robot = NiryoRobot(<robot_ip_address>)
robot.io.set_pin_mode(PinID.GPIO_1A, PinMode.INPUT)
robot.io.digital_write(PinID.GPIO_1A, PinState.HIGH)
Return type

IO

property pick_place

Access to the PickPlace API

Example:

robot = NiryoRobot(<robot_ip_address>)
robot.pick_place.pick_from_pose([0.2, 0.0, 0.1, 0.0, 1.57, 0.0])
robot.pick_place.place_from_pose([0.0, 0.2, 0.1, 0.0, 1.57, 0.0])
Return type

PickPlace

property saved_poses

Access to the SavedPoses API

Example:

robot = NiryoRobot(<robot_ip_address>)
pose_name_list = robot.saved_poses.get_saved_pose_list()
robot.saved_poses.get_pose_saved(pose_name_list[0])
Return type

SavedPoses

property sound

Access to the Sound API

Example:

robot = NiryoRobot(<robot_ip_address>)
sound.play_sound_user("test_sound.wav")
sound_name = sound.get_sounds()[0]
sound_duration = sound.play(sound_name)
Return type

Sound

property tool

Access to the Tool API

Example:

robot = NiryoRobot(<robot_ip_address>)
robot.tool.update_tool()
robot.tool.grasp_with_tool()
robot.tool.release_with_tool()
Return type

Tool

property trajectories

Access to the Trajectories API

Example:

robot = NiryoRobot(<robot_ip_address>)
trajectories = robot.trajectories.get_saved_trajectory_list()
if len(trajectories) > 0:
    robot.trajectories.execute_trajectory_saved(trajectories[0])
Return type

Trajectories

property vision

Access to the Vision API

Example:

robot = NiryoRobot(<robot_ip_address>)
robot.vision.vision_pick("workspace_1", 0.0, ObjectShape.ANY, ObjectColor.ANY)
robot.vision.detect_object("workspace_1", ObjectShape.ANY, ObjectColor.ANY)
Return type

Vision

property led_ring

Access to the Led Ring API

Example:

robot = NiryoRobot(<robot_ip_address>)
niryo_robot.led_ring.led_ring_flash([20,255,78], iterations = 10, wait = True, frequency = 8)
niryo_robot.led_ring.led_ring_turn_off()
Return type

LedRing

property frames

Access to the frame API

Example:

robot = NiryoRobot(<robot_ip_address>)
Return type

Frames

Globals Enums

List of enums:

class RobotErrors(value)[source]

An enumeration.

SUCCESS = 1
CANCELLED = 2
PREEMPTED = 3
FAILURE = -1
ABORTED = -3
STOPPED = -4
ROS_ERROR = -20
FILE_ALREADY_EXISTS = -30
UNKNOWN_COMMAND = -50
NOT_IMPLEMENTED_COMMAND = -51
INVALID_PARAMETERS = -52
HARDWARE_FAILURE = -110
HARDWARE_NOT_OK = -111
LEARNING_MODE_ON = -112
CALIBRATION_NOT_DONE = -113
DIGITAL_IO_PANEL_ERROR = -114
LED_MANAGER_ERROR = -115
BUTTON_ERROR = -116
WRONG_MOTOR_TYPE = -117
DXL_WRITE_ERROR = -118
DXL_READ_ERROR = -119
CAN_WRITE_ERROR = -120
CAN_READ_ERROR = -121
NO_CONVEYOR_LEFT = -122
NO_CONVEYOR_FOUND = -123
CONVEYOR_ID_INVALID = -124
CALIBRATION_IN_PROGRESS = -125
VIDEO_STREAM_ON_OFF_FAILURE = -170
VIDEO_STREAM_NOT_RUNNING = -171
OBJECT_NOT_FOUND = -172
MARKERS_NOT_FOUND = -173
ARM_COMMANDER_FAILURE = -220
GOAL_STILL_ACTIVE = -221
JOG_CONTROLLER_ENABLED = -222
CONTROLLER_PROBLEMS = -223
SHOULD_RESTART = -224
JOG_CONTROLLER_FAILURE = -225
PLAN_FAILED = -230
NO_PLAN_AVAILABLE = -231
INVERT_KINEMATICS_FAILURE = -232
TOOL_FAILURE = -251
TOOL_ID_INVALID = -252
TOOL_NOT_CONNECTED = -253
TOOL_ROS_INTERFACE_ERROR = -254
POSES_HANDLER_CREATION_FAILED = -300
POSES_HANDLER_REMOVAL_FAILED = -301
POSES_HANDLER_READ_FAILURE = -302
POSES_HANDLER_COMPUTE_FAILURE = -303
WORKSPACE_CREATION_FAILED = -308
PROGRAMS_MANAGER_FAILURE = -320
PROGRAMS_MANAGER_READ_FAILURE = -321
PROGRAMS_MANAGER_UNKNOWN_LANGUAGE = -325
PROGRAMS_MANAGER_NOT_RUNNABLE_LANGUAGE = -326
PROGRAMS_MANAGER_EXECUTION_FAILED = -327
PROGRAMS_MANAGER_STOPPING_FAILED = -328
PROGRAMS_MANAGER_AUTORUN_FAILURE = -329
PROGRAMS_MANAGER_WRITING_FAILURE = -330
PROGRAMS_MANAGER_FILE_ALREADY_EXISTS = -331
PROGRAMS_MANAGER_FILE_DOES_NOT_EXIST = -332
SERIAL_FILE_ERROR = -400
SERIAL_UNKNOWN_ERROR = -401
MQTT_PUBLISH_FUNCTION_DOESNT_EXIST = -420
MQTT_PUBLISH_FUNCTION_INVALID_ARGUMENTS = -421
SYSTEM_API_CLIENT_UNKNOWN_ERROR = -440
SYSTEM_API_CLIENT_INVALID_ROBOT_NAME = -441
SYSTEM_API_CLIENT_REQUEST_FAILED = -442
class ArmMoveCommandType(value)[source]

Enumeration of Arm Move Command : it used for move commands

JOINTS = 0
POSE = 1
POSITION = 2
RPY = 3
POSE_QUAT = 4
LINEAR_POSE = 5
SHIFT_POSE = 6
SHIFT_LINEAR_POSE = 7
EXECUTE_TRAJ = 8
DRAW_SPIRAL = 9
DRAW_CIRCLE = 10
EXECUTE_FULL_TRAJ = 11
EXECUTE_RAW_TRAJ = 12

Globals Objects

class PoseObject(x, y, z, roll, pitch, yaw)[source]

Pose object which stores x, y, z, roll, pitch & yaw parameters

Variables
  • x (float) – X (meter)

  • y (float) – Y (meter)

  • z (float) – Z (meter)

  • roll (float) – Roll (radian)

  • pitch (float) – Pitch (radian)

  • yaw (float) – Yaw (radian)

copy_with_offsets(x_offset=0.0, y_offset=0.0, z_offset=0.0, roll_offset=0.0, pitch_offset=0.0, yaw_offset=0.0)[source]

Create a new pose from copying from copying actual pose with offsets

Return type

PoseObject

to_list()[source]

Return a list [x, y, z, roll, pitch, yaw] corresponding to the pose’s parameters

Return type

list[float]

property quaternion

Return the quaternion in a list [qx, qy, qz, qw]

Returns

quaternion [qx, qy, qz, qw]

Return type

list[float, float, float, float]

property quaternion_pose

Return the position and the quaternion in a list [x, y, z, qx, qy, qz, qw]

Returns

position [x, y, z] + quaternion [qx, qy, qz, qw]

Return type

list[float, float, float, float, float, float, float]

static euler_to_quaternion(roll, pitch, yaw)[source]

Convert euler angles to quaternion

Parameters
  • roll (float) – roll in radians

  • pitch (float) – pitch in radians

  • yaw (float) – yaw in radians

Returns

quaternion in a list [qx, qy, qz, qw]

Return type

list[float, float, float, float]

static quaternion_to_euler_angle(qx, qy, qz, qw)[source]

Convert euler angles to quaternion

Parameters
Returns

euler angles in a list [roll, pitch, yaw]

Return type

list[float, float, float]