Ask Your Question

robot_upstart: Nodes using third party libraries are ignored [Python]

asked 2018-01-10 07:22:43 -0500

mohsen gravatar image

updated 2018-01-10 08:01:19 -0500

mgruhler gravatar image

I'm using ROS on raspberry pi 3. I'm using two third party libraries, one for reading sensor registers from I2C (FaBo9AXIS-MPU9250-Python) and one for generating PWM signal on pins (pigpio).
Any node importing one won't start by ros_upstart as if it doesn't exist in the launch file (also no log file is generated). What's wrong?
Here's one of the nodes:

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 retag flag offensive close merge delete


Well, it is hard to say. But as you are trying this with HW, this ist most often an issue with permissions. Check the documentation and consider setting the ports you are using to world read/writeable...

mgruhler gravatar image mgruhler  ( 2018-01-10 08:05:18 -0500 )edit

Thanks. What do you mean by "ports" ?

mohsen gravatar image mohsen  ( 2018-01-10 08:55:38 -0500 )edit

Also check PYTHONPATH of the user that runs the service and see the directory of your python file is included.

130s gravatar image 130s  ( 2018-01-10 09:06:42 -0500 )edit

By port I mean the GPIO device and the I2C device. Typically (well, on Ubuntu, Ubuntu Mate, ...) you Need to be in the group dialout to get access to those devices. As the docu states, you don't have the group membership when at the point of time that robot_upstart starts the scripts...

mgruhler gravatar image mgruhler  ( 2018-01-10 09:52:28 -0500 )edit

So as I understand,root starts the service and the unprivileged user executes the launch file. I have to make sure the user has access to GPIO.

mohsen gravatar image mohsen  ( 2018-01-10 10:45:39 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-01-10 15:45:43 -0500

mohsen gravatar image

updated 2018-01-10 15:46:25 -0500

I tracked down the problem to these two lines in the libraries:

import pigpio


bus = smbus.SMBus(1)

Running this command solved the first problem

sudo chown root.gpio /dev/gpiomem && sudo chmod a+x /dev/gpiomem

To fix the second one, I had to modify 99-com.rules .


It was only necessary to change the mode corresponding to i2c-dev to 0777 (read/write for all).

SUBSYSTEM=="i2c-dev", GROUP="i2c", MODE="0777"

Come to think of it, I could do the same for the gpio line and probably fix both issues using this file.

edit flag offensive delete link more



That's what I'm talking about :-) There are several ways to fix the Group permissions. Using udev is IMO the best one.

mgruhler gravatar image mgruhler  ( 2018-01-11 01:07:50 -0500 )edit

Thanks for 130s and your support. It was my first time ever hearing about udev :) so it took a while to get there.

mohsen gravatar image mohsen  ( 2018-01-11 01:47:58 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2018-01-10 07:22:43 -0500

Seen: 624 times

Last updated: Jan 10 '18