ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Does ROS include I2C Driver for Odroid/Ubuntu?

asked 2018-04-22 00:10:42 -0600

eds_worker_drone gravatar image

I am just beginning to explore whether ROS is even feasible to adopt on my platform. For that matter, I am still trying to sort out just what it is that ROS even brings to the party to simplify software development. No, I have not yet attempted to install ROS so the apparently required ros distro tag is just a wild guess.

I currently have a partially operational C++ based hydronic control automation project under development using Ubuntu 16.04 installed on an Odroid-C2 platform. This project seems to me like a good candidate for getting familiar with ROS before I tackle my next (and more ambitious) autonomous robotic application.

Specifically, my current project must gather data from several temperature sensor ICs using the I2C interface. The ROS Wiki intro paragraph indicates device drivers are part of the ROS landscape. But it is unclear whether a device driver for the I2C interface is included. If not, does ROS documentation provide guidelines for integrating custom driver code?

edit retag flag offensive close merge delete


ROS "drivers" are really nodes that form the interface between a ROS application (ie: a set of nodes forming a computation graph) and the 'rest' of your system. Conceptually, they are in the same spot as "OS device drivers", but they are not implemented as kernel modules or something like that.

gvdhoorn gravatar image gvdhoorn  ( 2018-04-22 04:16:42 -0600 )edit

So driver nodes typically read/write data from/to OS device drivers, not directly from/to the hw. So asking whether ROS includes "I2C drivers for X on Y" really comes down to: is there a node that can use the OS/platform driver to communicate with some device. I'm pretty sure there are, but ..

gvdhoorn gravatar image gvdhoorn  ( 2018-04-22 04:18:24 -0600 )edit

.. I hope you see the difference with a proper driver for, say, Linux Kernel a.b.c: this is all user space programs. Nothing fancy.

So any C/C++ lib that can read out (using the OS' I2C infrastructure) your temperature sensor would do. A ROS node could wrap that, and publish Temperature msgs.

gvdhoorn gravatar image gvdhoorn  ( 2018-04-22 04:21:08 -0600 )edit

I hope this it is a bit clearer now that:

But it is unclear whether a device driver for the I2C interface is included

is not really a question that can be asked in the context of ROS. At that level, the underlying OS itself must support the hw. Then ROS can use that.

gvdhoorn gravatar image gvdhoorn  ( 2018-04-22 04:23:44 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2018-04-23 10:31:42 -0600

eds_worker_drone gravatar image

Your answers and clarifications are most appreciated. It now appears that I should expect to continue adopting the I2C driver code I currently use. Looks like maybe the ROS framework benefits kick in at higher levels of abstraction. So my next step will be to actually install an ROS distribution and port it into my existing code as a way to really explore its capabilities.

Thanks again.

edit flag offensive delete link more

answered 2018-04-22 11:59:36 -0600

mohsen gravatar image

updated 2018-04-22 12:21:52 -0600

To add to gvdhoorn's comments:
1- The code that you already use to read sensor data can be implemented as a "node" in ROS, with few minor tweaks. I will provide an example code below.

2- As to what ROS brings to the table: The way I see it, ROS is at its simplest a platform for process communication. Most of the work required for the communication part is done by ROS, so you can focus on writing the processes (AKA nodes).
For example, in your project you might have a node that reads sensor data -let's call it read_temp- and another that processes it (process_temp). You write the code for each node independently and set them up such that the read_temp sends data to process_temp: ROS facilitates modularity.

This node reads gyro and accelerometer data from a MPU9250 sensor. I'm using a library called FaBo9Axis_MPU9250 written for raspberry pi to do exactly that. Note that the library itself has nothing to do with ROS-it's simply an interface to the sensor.

#!/usr/bin/env python
from math import pi
import rospy
import FaBo9Axis_MPU9250
from sensor_msgs.msg import Imu

mpu9250 = FaBo9Axis_MPU9250.MPU9250()

pub = rospy.Publisher('imu/data_raw',Imu, queue_size = 1)

msg = Imu()
msg.orientation_covariance[0] = -1
msg.header.frame_id = 'imu'
rate = rospy.Rate(100)

while not rospy.is_shutdown():
    accel = mpu9250.readAccel()
    gyro = mpu9250.readGyro()

    msg.header.stamp =

    msg.linear_acceleration.x = accel['x']*9.81
    msg.linear_acceleration.y = accel['y']*9.81
    msg.linear_acceleration.z = accel['z']*9.81

    msg.angular_velocity.x = (gyro['x'] - 0.9)*0.01745329251
    msg.angular_velocity.y = (gyro['y'] - 0.5)*0.01745329251
    msg.angular_velocity.z = gyro['z']*0.01745329251
edit flag offensive delete link more

Question Tools


Asked: 2018-04-22 00:10:42 -0600

Seen: 1,906 times

Last updated: Apr 23 '18