Conveyor

This file presents the different Conveyor - Command functions, Conveyor - Enums, Conveyor - Niryo Topics & Conveyor - Namedtuple available with the Arm API

Conveyor - Command functions

This section reference all existing functions to control your robot, which include

  • Controlling conveyors

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

robot = NiryoRobot(<robot_ip_address>)

conveyor_id = robot.conveyor.set_conveyor()
robot.conveyor.run_conveyor(conveyor_id)
...

See examples on Examples Section

List of functions subsections:

Conveyor functions

class Conveyor(client)[source]

Conveyor robot functions

Example:

ros_instance = NiryoRos("10.10.10.10") # Hotspot
conveyor_interface = Conveyor(ros_instance)
Parameters

client (NiryoRos) – Niryo ROS client

set_conveyor()[source]

Scan if a conveyor is plugged or not on a can bus. If a new conveyor is detected, activate it and return its conveyor ID. If a conveyor is already set, return its ID

Example:

# Get the id of the conveyor plugged
conveyor_id = conveyor.set_conveyor()

# Scan and set the conveyor plugged
conveyor.set_conveyor()

:return : New conveyor ID :rtype: ConveyorID

unset_conveyor(conveyor_id)[source]

Remove and unset a conveyor previously plugged and set

Example:

conveyor_id = conveyor.set_conveyor()
conveyor.unset_conveyor(conveyor_id)
conveyor.unset_conveyor(ConveyorID.ID_1)
conveyor.unset_conveyor(ConveyorID.ID_2)
Parameters

conveyor_id (ConveyorID) – Basically, ConveyorID.ID_1 or ConveyorID.ID_2

Return type

None

run_conveyor(conveyor_id, speed=100, direction=<ConveyorDirection.FORWARD: 1>)[source]

Run conveyor at id ‘conveyor_id’

Example:

# Set the conveyor and get its id and un it. 
# By default, the conveyor will go forward at a speed of 50
# You can't choose the parameters with this method

conveyor_id = conveyor.set_conveyor()
conveyor.run_conveyor(conveyor_id) 
Parameters
  • conveyor_id (ConveyorID) – The conveyor id

  • speed (int) – speed percentage between 0% and 100%

  • direction (ConveyorDirection) – direction = ConveyorDirection.FORWARD

Return type

None

stop_conveyor(conveyor_id)[source]

Stop conveyor at id ‘conveyor_id’

Example:

# Set the conveyor and get its id, run it and then stop it after 3 seconds
# By default, the conveyor will go forward at a speed of 50
# When the conveyor is stopped, its control_on parameter is False and its speed is 0

import time

conveyor_id = conveyor.set_conveyor()
conveyor.run_conveyor(conveyor_id)
time.sleep(3)
conveyor.stop_conveyor(conveyor_id) 
Parameters

conveyor_id (ConveyorID) –

Return type

None

control_conveyor(conveyor_id, control_on, speed, direction)[source]

Control conveyor associated to conveyor_id. Then stops it if bool_control_on is False, else refreshes it speed and direction

Example:

# Example 1
# Set the conveyor and get its id, control it and then stop it after 3 seconds
# It this first example, we control the conveyor at a speed of 100% and in the forward direction

import time

conveyor_id = conveyor.set_conveyor()
conveyor.control_conveyo(conveyor_id, True, 100, ConveyorDirection.FORWARD.value)
time.sleep(3)
conveyor.stop_conveyor(conveyor_id) 
# Example 2

# Set the conveyor and get its id, control it and then stop it after 3 seconds # It this second example, we control the conveyor at a speed of 30% and in the backward direction

import time

conveyor_id = conveyor.set_conveyor() conveyor.control_conveyor(conveyor_id, True, 30, ConveyorDirection.BACKWARD.value) time.sleep(3) conveyor.stop_conveyor(conveyor_id)

Parameters
  • conveyor_id (ConveyorID) –

  • control_on (bool) – True for activate, False for deactivate

  • speed (int) – New speed which is a percentage of maximum speed (0% to 100%)

  • direction (ConveyorDirection) – ConveyorDirection.FORWARD.value, ConveyorDirection.BACKWARD.value

Return type

None

property get_conveyors_feedback

Returns the conveyors feedback client which can be used synchronously or asynchronously to obtain the conveyors feedback: (conveyor_id, connection_state, running, speed, direction)

Examples:

# Get last value
arm.get_conveyors_feedback()
arm.get_conveyors_feedback.value

# Subscribe a callback
def conveyor_callback(conveyor_feedback):
    print conveyor_feedback

arm.hardware_status.subscribe(conveyor_callback)
# wait
arm.hardware_status.unsubscribe()
Returns

namedtuple[conveyor_id, running, speed, direction]

Return type

namedtuple(ConveyorID, bool, int, ConveyorDirection)

property conveyors

Return list of registered conveyors

Returns

namedtuple[conveyor_id, running, speed, direction]

Return type

namedtuple(ConveyorID, bool, int, ConveyorDirection)

Conveyor - Niryo Topics

The use of these functions is explained in the NiryoTopic section. They allow the acquisition of data in real time by callbacks or by direct call.

Conveyors’s Niryo Topics

Name

Function

Return type

/niryo_robot/conveyor/feedback

get_conveyors_feedback

list [ ConveyorInfo ]

Conveyor - Enums

List of enums:

  • ConveyorID

  • ConveyorDirection

  • ConveyorStatus

class ConveyorID(value)[source]

ConveyorID to be able to have CAN (id 12 and 13) and TTL (id 9 and 10) conveyor in any possible combination

ID_1 = 12 # One, Ned ID_2 = 13 # One, Ned ID_3 = 9 # Ned2 ID_4 = 10 # Ned2

NONE = 0
ID_1 = -1
ID_2 = -2
class ConveyorCan(value)[source]

ConveyorID to control conveyors with CAN interface

NONE = 0
ID_1 = 12
ID_2 = 13
class ConveyorTTL(value)[source]

ConveyorID to control conveyors with TTL interface

NONE = 0
ID_1 = 9
ID_2 = 10
class ConveyorDirection(value)[source]

Enumeration of the directions of the conveyor

FORWARD = 1
BACKWARD = -1
class ConveyorStatus(value)[source]

Enumeration of the different Conveyor status

ADD = 1
REMOVE = 2

Conveyor - Namedtuple

class ConveyorInfo(conveyor_id, running, speed, direction)

Create new instance of ConveyorInfo(conveyor_id, running, speed, direction)

conveyor_id

Alias for field number 0

direction

Alias for field number 3

running

Alias for field number 1

speed

Alias for field number 2