The IOTA ROS (Robot Operating System) Project

In my last article “Why ROS is perfect for IOTA” I wrote about the Robot Operating System and tried to explain why it is perfect for IOTA. The article got a lot more attention than i had expected, so I decided to give a small introduction to my work. It will be a little more technical and I’ll show you some code (python), but hopefully I can explain it well enough for everyone to understand it.


The Robot Operating System (ROS)

The Robot Operating System is, as mentioned in my last article, an Operating System for nearly every kind of device in the Robotics. It can be applied on a Robot itself for controlling purposes, but also as a System for pure data collection in a car. It is super slim, so it can be used on low-powered devices like a Raspberry Pi or a Rock64.

What Are Messages, Topics and Nodes?

In order to understand this blogpost properly, I’ll briefly explain ROS nodes, messages and topics.

A node is able to process different tasks. For example you can have a node for calculating a current position out of acceleration measurements or, in this case, to proceed an IOTA transaction. Furthermore, a node is able to communicate with others by subscribing or publishing to a specific ‘’topic’’. A ‘’topic’’ is needed for nodes that they can get data for calculations or to provide data for other nodes. It’s like a noticeboard. If you need data, you can look which data is provided in a topic or you can leave a note for others so that everyone (every node) who is interested will be able to get the information you have left.


What I’ve Done so Far

I recently created a node which subscribes and publishes different topics. With these topics you are able to monitor an address for incoming transactions and you are able to send transactions by publishing into a specific topic.

In order to make all this a little more clear, I created a small showcase for this article. In this showcase a quadcopter (not a real one, just a simulation) will be paid for providing me with some data (in this case its position, but it could also be the engine temperatureor sth. else).

CurrentState of Development

The last few weeks, I did not have that much time to code due to my bachelor thesis, but I set myself the following goals for the IOTA ROS package:

  1. monitor incoming transactions.
  2. send a transaction when a message is published into the /iota/send_transaction topic
  3. publish the data from incoming transactions
  4. monitor confirmation status of transactions
  5. adding more features like MAM

I recently reached the goal #1,#2 and #3. Goal #4 is nearly ready, but there are some small bugs which i need yet to solve.

The Showcase

This showcase shall only serve as a small example of how easy it is to create a small showcase with the IOTA ROS implementation. Every time I pay the Quadcopter a small amount of IOTAs, the Quadcopter should send a message to an specific address. For this showcase I’ve used the ‘’Gazebo’’ simulation. This simulation provides a real time simulation environment for Quadcopters and allows you to monitor e.g. the current position (picture below (r.)) .

Gazebo Quadcopter simulation (l.) and the published position(r.)

The Code

In the picture below, you can see the code I used for the showcase. It’s not that complicated and I think most people who are familiar with ROS and Python are able to read it properly. For those of you who are not that familiar with it, please read the following explanation ofwhat the code does:

First, it does some initialization stuff like creating the node or creating a publisher. Then, the listener() function is called where the subscriber is being initialized. After that, it stays in the listener() function till a message is published into the ‘’mavros/local_position/pose’’ or the ‘’/iota/transaction_info’’ topic. If a message is published into the ‘’mavros/local_position/pose topic’’, the callback function “sub2” will be called. This function creates a string with the current position. It is necessary to always have the last published position in the string. If a transaction is received to the monitored topic (which can be set in a config file),the callback function ‘’sub1'’ will be called. In this callback function, it proves if the value is greater than 0. Is it greater than 0, a transaction is created with the current position and sent to the transmitted address.

The Result

It’s very easy to use when the package is implemented. You only have to send a small amount, in this case >0i , to the specified address and have to transmit your address via the message box.

For example: 
Value: 50 i
Send to: DONTSENDANYAMOUNTTOTHISADDRESS…
Message: THISADDRESSWILLRECEIVETHEANSWEAR…

And that’s it. This is the message I received in my Trinity Wallet.

Conclusion

I think this package is a good solution for every ROS programmer. It is currently providingthe most important features and should be sufficient for most of the use cases. And as you have seen in this example, you are able to create a small showcase even with only 50 lines of code which shows how simple it is to use IOTA with the IOTA_ROS_PKG.

Future Plans

First of all, I want to find all bugs that the package contains. For now, I want to reread the code and make it a little bit more simple and clearer. After that, I’ll complete the documentation and write a small wiki so that everyone will be able to use it properly. Furthermore feel free to contribute to this project, every help is appreciated!

My Ecosystem Project:
https://ecosystem.iota.org/projects/iota-ros-implementation

I hope you enjoyed this blogpost and If you like my project, please consider to leave me a donation :)

RDIFGGRTPOKUIOZXIPGKSJJJ9CDJYMNELFNVFW9JJEMZBWTYAULSNOFASPREPGDLXVPGRPGROBBDVMHJWBZOKFIXNX


References:

Git Repository: https://github.com/MichiKuhl/iota_ros_pkg

My other Article: https://medium.com/@MichiKuhl/why-ros-is-perfect-for-iota-913b343526b4

My social media accounts:

Twitter: https://twitter.com/MichiKuhl

Discord: Michi#8255