I/Os
This file presents the different api_doc/io:I/Os - Command functions, api_doc/io:I/Os - Enums, api_doc/io:I/Os - Niryo Topics & api_doc/io:I/Os - Objects available with the Arm API
I/Os - Command functions
- pyniryo2.io.io.check_ned2_version(func)
Decorator that check the robot version
- pyniryo2.io.io.check_ned_one_version(func)
Decorator that check the robot version
This section reference all existing functions to control your robot, which include
Getting IOs status
Setting IOs mode
Setting IOs value
All functions to control the robot are accessible via an instance of the class api_doc/niryo_robot:NiryoRobot
robot = NiryoRobot(<robot_ip_address>)
robot.io.set_pin_mode(PinID.GPIO_1A, PinMode.INPUT)
robot.io.digital_write(PinID.GPIO_1A, PinState.HIGH)
...
See examples on Examples Section
List of functions subsections:
- class pyniryo2.io.io.IO(client)
IO robot functions
Example:
ros_instance = NiryoRos("10.10.10.10") # Hotspot io_interface = IO(ros_instance)
- Parameters:
client (NiryoRos) – Niryo ROS client
State functions
- property IO.digital_io_states
Return the value of digital ios.
- Returns:
State, Name, Mode of the pin
- Return type:
DigitalPinObject
- property IO.get_digital_io_states
Returns the io state client which can be used synchronously or asynchronously to obtain the io states. The io state client returns a list of DigitalPinObject.
Examples:
# Get last value io.get_digital_io_states() io.get_digital_io_states.value # Subscribe a callback def io_callback(io_state): print io_state io.get_digital_io_states.subscribe(io_callback) io.get_digital_io_states.unsubscribe()
- Returns:
io state topic instance
- Return type:
- IO.get_digital_io_state(pin_id)
Return the value of a digital io.
- Returns:
digital io object
- Return type:
DigitalPinObject
Read & Write functions
- IO.set_pin_mode(**kwargs)
- IO.digital_write(pin_id, digital_state)
Set pin_id state to digital_state
Examples:
io.digital_write(PinID.GPIO_1A, PinState.HIGH) io.digital_write('1A', PinState.LOW)
- Parameters:
pin_id (PinID or String)
digital_state (PinState or bool)
- Return type:
None
- IO.digital_read(pin_id)
Return the value of a digital pin.
Examples:
io.set_pin_mode(PinID.GPIO_1A, PinMode.OUTPUT) io.digital_read(PinID.GPIO_1A)
- Parameters:
pin_id (PinID or str)
- Return type:
bool
I/Os - Niryo Topics
The use of these functions is explained in the api_doc/niryo_topics:NiryoTopic section. They allow the acquisition of data in real time by callbacks or by direct call.
Name |
Function |
Return type |
|---|---|---|
|
|
I/Os - Enums
List of enums:
PinModePinStatePinID
- class pyniryo2.io.enums.PinMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Enumeration of Pin Modes
- OUTPUT = 0
- INPUT = 1
- class pyniryo2.io.enums.PinState(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Pin State is either LOW or HIGH
- LOW = False
- HIGH = True
- class pyniryo2.io.enums.PinID(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Enumeration of Robot Pins
- GPIO_1A = '1A'
- GPIO_1B = '1B'
- GPIO_1C = '1C'
- GPIO_2A = '2A'
- GPIO_2B = '2B'
- GPIO_2C = '2C'
- SW_1 = 'SW1'
- SW_2 = 'SW2'
- DO1 = 'DO1'
- DO2 = 'DO2'
- DO3 = 'DO3'
- DO4 = 'DO4'
- DI1 = 'DI1'
- DI2 = 'DI2'
- DI3 = 'DI3'
- DI4 = 'DI4'
- DI5 = 'DI5'
- AI1 = 'AI1'
- AI2 = 'AI2'
- AO1 = 'AO1'
- AO2 = 'AO2'
I/Os - Objects
- class pyniryo2.io.objects.DigitalPinObject(name, mode, value)
Object used to store information on digital pins
- class pyniryo2.io.objects.AnalogPinObject(name, mode, value)
Object used to store information on digital pins