robot_upstart: Nodes using third party libraries are ignored [Python]
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 import
ing 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
rospy.init_node('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 = rospy.Time.now()
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
pub.publish(msg)
rate.sleep()
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...
Thanks. What do you mean by "ports" ?
Also check
PYTHONPATH
of the user that runs the service and see the directory of your python file is included.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 thatrobot_upstart
starts the scripts...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.