electronic_io package from electronic-io repoelectronic_io electronic_io_msgs |
|
Package Summary
Tags | No category tags. |
Version | 1.0.3 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/ctu-vras/electronic-io.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2023-07-03 |
Dev Status | DEVELOPED |
CI status |
|
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Martin Pecka
Authors
- Martin Pecka
electronic_io
Convenience library for interaction with analog and digital inputs and outputs.
This package provides a generalized approach for integration of various electronic input and output devices into ROS.
The three basic concepts in this package are:
- Pins: They correspond either to physical input or output pins of a CPU or MCU, or to virtualized pins that e.g. internally decode a protocol like 1-Wire and expose the measurements. Multiple pins together form an I/O board.
- Virtual Pins: These are pins that have no physical manifestations, but instead use one or more real pins to compute their value. This can be used e.g. for adjusting or combining the values returned by the real pins.
- Devices: Each device operates on one or more pins or virtual pins and interprets their values. Input devices produce ROS topics with the readings. Output devices provide a ROS service that can be used to change value of the device (and its pins).
The idea is that each of these could be representing a different real-world entity:
- The set of real pins can describe a particular I/O board, like Raspberry Pi.
- The set of virtual pins translates datasheets of the connected components into sensible numbers (e.g. ADC -> Voltage).
- The set of devices interprets the pins and virtual pins in terms of high-level devices.
These also specify the two ROS nodes that are expected to be running: a board node (exposing the pins), and a devices node (handling the virtual pins and devices).
See the examples
folder for inspiration how the nodes and configs can be used and configured.
Configuration of the devices is pretty easy. To add a relay that can power on/off the motors, configure it as simply as:
power_switch_motors:
topic: "power_switch/motors"
type: electronic_io.PowerSwitch
output_pins:
- 'Output7'
This configuration provides topic power_switch/motors
with the state of the switch, and services
power_switch/motors/set
and power_switch/motors/toggle
that can change the state of the relay.
The only thing that needs to be coded is the I/O board driver that can actually read and write to pin Output7
.
Digital pins can also easily be inverted for usage in devices. That can be achieved via advanced pin syntax. Instead of:
output_pins:
- 'Output7'
write
output_pins:
- pin: 'Output7'
inverted: True
Devices available in this package
- Ampere Meter (type
electronic_io.AmpereMeter
) - Battery (type
electronic_io.Battery
) - Dimmable LED (type
electronic_io.DimmableLED
) - Output Group (type
electronic_io.OutputGroup
) - Power Switch (type
electronic_io.PowerSwitch
) - Thermometer (type
electronic_io.Thermometer
) - Voltmeter (type
electronic_io.Voltmeter
)
Virtual pins available in this package
- Binary PWM (type
electronic_io.BinaryPWM
) - Digital Pin Combo (type
electronic_io.DigitalPinCombo
) - Linear ADC Pin (type
electronic_io.LinearADCPin
)
Adding a new device type
These steps are generally required when you want to specify a new device type (inside or outside this package):
- Add the class that implements the device to an installed Python module, i.e. you need to have
catkin_python_setup()
in CMakeLists.txt, a setup.py file and the device’s package has to be installed. - Add the following to package.xml
<export>
section:<electronic_io device="my_package.MyDevice" />
.
Specifically when adding a device to this package, do not forget to:
- Add it to
src/electronic_io/__init__.py
. - Add it to this readme.
- Add it to
doc/devices.rst
so that it gets documented. - Add it to the list of catkin-linted files in
CMakeLists.txt
.
Adding a new virtual pin
These steps are generally required when you want to specify a new virtual pin (inside or outside this package):
- Add the class that implements the pin to an installed Python module, i.e. you need to have
catkin_python_setup()
in CMakeLists.txt, a setup.py file and the device’s package has to be installed. - Add the following to package.xml
<export>
section:<electronic_io virtual_pin="my_package.MyPin" />
.
Specifically when adding a virtual pin to this package, do not forget to:
- Add it to
src/electronic_io/__init__.py
. - Add it to this readme.
- Add it to
doc/virtual_pins.rst
so that it gets documented. - Add it to the list of catkin-linted files in
CMakeLists.txt
.
Changelog for package electronic_io
1.0.3 (2023-07-03)
- Fixed build and docs
- Contributors: Martin Pecka
1.0.2 (2023-06-30)
1.0.1 (2023-06-19)
- Added support for simplified specification of pins in config.
- Added BinaryPWM virtual pin.
- Added virtual pins.
- It topic is set to empty, the topics and services will not be created.
- Added Battery device.
- Export the provided devices.
- Allow setting queue_size and latching for output devices.
- Added support for output groups.
- Robustified IO board client.
- Initial commit
- Contributors: Martin Pecka
Wiki Tutorials
Package Dependencies
Deps | Name |
---|---|
catkin | |
cras_msgs | |
electronic_io_msgs | |
rospy | |
sensor_msgs | |
std_srvs | |
cras_docs_common | |
rosdoc_lite | |
roslint |
System Dependencies
Dependant Packages
Launch files
- examples/tradr_ft232h.launch
- SPDX-License-Identifier: BSD-3-Clause SPDX-FileCopyrightText: Czech Technical University in Prague Example launch file using the fake virtual I/O board.
-
- examples/tradr_spinel.launch
- SPDX-License-Identifier: BSD-3-Clause SPDX-FileCopyrightText: Czech Technical University in Prague Example launch file using the fake virtual I/O board.
-
- examples/smart_battery.launch
- SPDX-License-Identifier: BSD-3-Clause SPDX-FileCopyrightText: Czech Technical University in Prague Example launch file using the fake virtual I/O board.
-