YRK ROS API¶
The ROS script, message and service files are found in the catkin workspace subfolder catwin_ws/src/yrk_ros
.
This can be quickly accessed from a terminal using the following ROS command:
roscd yrk_ros
yrk_ros.adc_publisher¶
Reads the values from the 8-port ADC and publish as a rostopic.
To run:
rosrun yrk_ros adc_publisher.py
yrk_ros.button_publisher¶
Reads the values from the buttons and switches and publishes as a rostopic.
To run:
rosrun yrk_ros button_publisher.py
yrk_ros.display_server¶
The display_server.py
script contains the code for the display_service ROS service in the yrk-ros library.
This provides the functionality to display text, warnings and to clear the I2C OLED module, using functions from the yrk.display
core module.
The service message is defined in the file Display.srv and contains 5 input fields, shown in the table below, and one response field (bool success).
Type |
Name |
Notes |
---|---|---|
string |
message_1 |
|
string |
message_2 |
Only used when number_of_lines==2 and warning==false |
unit8 |
number_of_lines |
Range 0-2, 0=clear display |
bool |
wrap_text |
Shrinks font, wraps text over 2 lines if needed |
bool |
warning |
Displays ~10 chars text [message_1] with warning icon |
The Display service message is processed using the following logic:
If number_of_lines>2 exit with failure
If number_of_lines =0 clear display
If warning is true, display message_1 as a warning (ignore number_of_lines, wrap_text, message_2)
Otherwise call 1- or 2- line wrapped or normal functions based on settings
To run outside of launch file:
rosrun yrk_ros adc_publisher.py
Usage Example:
rosservice call /display_service "{message_1: '', message_2: '', number_of_lines: 0, wrap_text: false, warning: false}"
Note
Use tab completion on rosservice call /display_service to prepare above macro, works elsewhere too!
yrk_ros.led_server¶
Controls the colour, mode and brightness of the RGB LEDs on the YRK. The message expects 3 arguments: uint8 index : Colour index uint8 brightness: Brightness value [0-15]
Output is a ‘name’ string describing LED colour or animation mode
To run:
rosrun yrk_ros led_server.py
yrk_ros.motor_server¶
Sets the speed and brake mode [highlow impedance] for the motors on the York Robotics Kit. The message expects 3 arguments: uint8 motor_index : Motor index [0-3] float32 speed: Motor speed [-1.0 to 1.0, 0=brake or coast] bool brake_mode: If speed=0.0 and brake_mode=true, will force low-impedance brake
Returns: bool success
Output is a ‘name’ string describing LED colour or animation mode
To run:
rosrun yrk_ros led_server.py
yrk_ros.power_monitor¶
Reads the values from the Atmega328 microcontroller on the YRL039 power supply board and publishes as a ROS topic using the yrk_ros.msg.power_status message format.
To run:
rosrun yrk_ros power_monitor.py
yrk_ros.switched_output_server¶
Enablesdisables the 5V and 12V switched outputs.
To run:
rosrun yrk_ros switched_output_server.py