IoT bridge

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.

  • ROS is an extremely powerful open source set of libraries and tools that help you build robot applications – providing drivers and state-of-the-art algorithms for vision, movement, etc. See the official website [1] for more info.
  • OpenHAB is an open source system that connects to virtually any intelligent device, such as smoke detectors, motion detectors, temperature sensors, Amazon Alexa, security systems, TV/audio, Chromecast, fingerprint scanners, lighting, 1-Wire, Bluetooth, MQTT, Z-Wave, telephony, weather sensors, and web services such as Twitter, etc. OpenHAB also provides a basic Web GUI and iPhone / Android app for setting and dynamically viewing values. To access the full list of supported features go to [2] for more info.

Use Cases

  • A motion detector in OpenHAB triggers and ROS dispatches the robot to the location.
  • ROS facial recognition recognises a face at the door, and OpenHAB turns on the lights and unlocks the door.
  • A Washing Machine indicates to OpenHAB that the load is complete and ROS dispatches a robot to move the laundry to the dryer.
  • A user gives a voice smart home command to Alexa. Using the OpenHAB/Amazon Alexa integration then forwarded to ROS via the iot_bridge.
  • The OpenHAB MQTT location binding indicates that Sarah will be home soon and a sensor indicates that the temperature is hot. ROS dispatches the robot to bring Sarah's favourite beer. OpenHAB turns on her favourite rock music and lowers the house temperature.
  • A user clicks on the OpenHAB GUI on an IPAD and selects a new room location for the robot. The message is forwarded by the iot_bridge to ROS, and ROS dispatches the robot [3].

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:

  • go to Github website [7] and find the GIT clone address,
  • in the ROS console type and run:
  cd catkin_ws/src
  git clone address-from-above
  cd ..
  catkin_make
  • edit iot_bridge/config/items.yaml:
    • update host address and port to match your OpenHAB server;
  • edit OpenHAB's item file:
    • create the ROS group: Group ROS (All);
    • add the ROS group to each item that should send status updates to ROS.
Note that the items must be directly in a (ROS) group, not in a sub-group of the (ROS) group. Note, this is only needed for status updates to go from OpenHAB to ROS – you can send commands from ROS to any OpenHAB item regardless of what group it is in [8].
  • add 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)
Note: you must have two or more items defined in the ROS group.

Running

Run the iot-bridge using:

roslaunch iot_bridge iot.launch

Testing

Follow steps to check to receive from OpenHAB.

  • In your browser, go to [9].
  • We can see an XML response with the state of the items you have put in the ROS group.
  • In the console, type:
 rostopic echo /iot_updates
  • Bring up the OpenHAB demo site in your browser and change an item in the ROS group.
  • Now we can see the new state in the rostopic echo console.

Follow next steps to check sending to OpenHAB:

 cd catkin_ws/src/iot_bridge/scripts
    ./iot_test  item_name item_value
 
  • You should see the message logged where you did the roslaunch.
  • If you have the OpenHAB demo site in your browser, you should see the item you named changed to your specified value.
  • The value must be valid for that device (number, or ON/OFF, or OPEN/CLOSED). See openhab/items for a summary of valid values.

Statistics

  • You can place the ROS_Status item in your OpenHAB sitemap. It will display the time of the last update (to the nearest minute) and counts of messages and errors.
  • Place the following in demo.sitemap:
 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:

  • message type: diagnostic_msgs/KeyValue,
  • key: “facedetection” – key must match OpenHAB's .items file,
  • value: “Sarah” (string).

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

  • message type: diagnostic_msgs/KeyValue,
  • key: office_motion – key matches OpenHAB's .items file,
  • value: 1 (string).
Note: device states are ONLY published to ROS when they change (or when iot_bridge is started). If you need the current state for ALL items in the ROS group, use the Request Refresh interface [10] .

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.

en/iot-open/emerging_iot_technologies/robot_operating_system_ros_for_iot/ros_communication_tcp-ip_mqtt_blockchain.txt · Last modified: 2020/07/20 09:00 by 127.0.0.1
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0