The iot_bridge provides a connection between ROS and any smart device of the control system. Since 2017, the package offers to bridge with OpenHAB, one of the most actively developed and used a framework for home automation.
Use Cases
Using iot-bridge technology, any OpenHAB device can be easily set up to publish updates to the iot_updates topic in ROS, giving a ROS robot knowledge of any Home Automation device. ROS can publish to the iot_set topic (or iot_command), and the device in OpenHAB will be set to the new value (or act on the specified command).
Installing iot_bridge
At first, we should install and configure OpenHAB, for details and guides see [4]. Many people find that the simplest way to experiment with OpenHAB is to get a Raspberry Pi and install openHABian – the “hassle-free openHAB setup”. While openHABian offers a streamlined and simplified way to get up and running quickly, it is a complete OpenHAB home automation system capable of automating your entire home [5].
Just in a few steps, let's present the OpenHAB installation.
Configure the repository in your Ubuntu OS:
wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | sudo apt-key add - echo "deb http://dl.bintray.com/openhab/apt-repo stable main" | sudo tee /etc/apt/sources.list.d/openhab.list sudo apt-get update
After this, we can install the runtime:
sudo apt-get install openhab-runtime
After installation, you should configure the runtime. See the following guide [6].
Now, we should install iot-bridge on the ROS system:
cd catkin_ws/src git clone address-from-above cd .. catkin_make
iot_bridge/config/items.yaml
:Group ROS (All)
; ROS_Status
to OpenHAB's item file;Sample Open_HAB item definition:
Group ROS (All) String ROS_Status "ROS [%s]" Switch Light_GF_Corridor_Ceiling "Ceiling" (GF_Corridor, Lights, ROS) Switch Light_GF_Bathroom (GF_Bathroom, Lights, ROS)
Running
Run the iot-bridge using:
roslaunch iot_bridge iot.launch
Testing
Follow steps to check to receive from OpenHAB.
rostopic echo /iot_updates
Follow next steps to check sending to OpenHAB:
cd catkin_ws/src/iot_bridge/scripts ./iot_test item_name item_value
Statistics
Text item=ROS_Status label="ROS [%s]"
Set Status for an OpenHAB Item
ROS topic subscribed by iot_bridge:
//iot_set (diagnostic_msgs/KeyValue)//
When the iot_bridge receives a name/value pair from the ROS iot_set topic, it publishes those to OpenHAB, and OpenHAB updates the status for the item specified (e.g. indicate that a switch is now ON). For instance: A ROS program running Facial Detection detects that Sarah is present. It publishes the following to the iot_set topic:
This will set the facedetection item in OpenHAB to person Sarah, indicating Sarah has been detected. See the sample code in iot_test.
Receive Item Updates From OpenHAB
ROS topic published by iot_bridge: iot_updates (diagnostic_msgs/KeyValue)
The IoT bridge receives updates from OpenHAB and publishes those as name/value pairs to the iot_updates ROS topic.
To see updates from the command line, type:
rostopic echo iot_updates
For example, a motion detector is triggered in OpenHAB. The OpenHAB bridge will publish the following to the iot_updates
topic in ROS
diagnostic_msgs/KeyValue
,office_motion
– key matches OpenHAB's .items
file,1
(string).
OpenHAB will send the current status of every item in the ROS group to the iot_updates
topic. The following status will continue to send only when they change.