@moonwalkeraz wrote:
Hello I’m working on a project for school. I’m using Sense Hat on Raspberry pi 3 B to display pixels on led matrix and IMU to get yaw. But the problem is that I’m trying to run IMU when Ubuntu Mate starts (on boot) in ROS. So I made a service that runs python script on boot. But I get an error from service:
If I run script manually everything works fine, but if I run the service I get the same error.
dec 28 01:25:57 pi-mate picobot-start[870]: File “/home/pi/catkin_ws/src/Picobot/picobot_imu/src/picobot_imu.py”, line 22, in gyroData
dec 28 01:25:57 pi-mate picobot-start[870]: sense.set_imu_config(False, True, True)
dec 28 01:25:57 pi-mate picobot-start[870]: File “/usr/lib/python2.7/dist-packages/sense_hat/sense_hat.py”, line 660, in set_imu_config
dec 28 01:25:57 pi-mate picobot-start[870]: self._init_imu() # Ensure imu is initialised
dec 28 01:25:57 pi-mate picobot-start[870]: File “/usr/lib/python2.7/dist-packages/sense_hat/sense_hat.py”, line 648, in _init_imu
dec 28 01:25:57 pi-mate picobot-start[870]: raise OSError(‘IMU Init Failed’)
dec 28 01:25:57 pi-mate picobot-start[870]: OSError: IMU Init Failed
dec 28 01:25:58 pi-mate picobot-start[870]: No handlers could be found for logger “roslaunch”
dec 28 01:25:58 pi-mate picobot-start[870]: [picobot_imu-6] process has died [pid 1515, exit code 1, cmd /home/pi/catkin_ws/src/Picobot/picobotHere is my code:
#!/usr/bin/env python import rospy from sense_hat import SenseHat import time from random import randint from std_msgs.msg import Float32 sense = SenseHat() def randomColor(): red_random = randint(0,255) blue_random = randint(0,255) green_random = randint(0,255) return (red_random,green_random,blue_random) def gyroData(): pub = rospy.Publisher('gyro', Float32, queue_size=10) rospy.init_node('picobot_imu') rate = rospy.Rate(10) # 10hz sense.set_imu_config(False, True, True) while not rospy.is_shutdown(): o = sense.get_orientation() #pitch = o["pitch"] #roll = o["roll"] yaw = o["yaw"] #rospy.loginfo(yaw) pub.publish(yaw) rate.sleep() def main(): sense.clear((0, 0, 0)) sense.low_light = True g =(0,153,153) bl = (0,153,0) b = (0,0,0) picobot_pixels = [ g,g,b,g,b,g,g,b, g,g,b,g,b,g,b,b, g,b,b,g,b,g,g,b, b,b,b,b,b,b,b,b, g,g,g,b,bl,b,bl,b, g,b,g,b,b,bl,b,b, g,g,g,b,bl,bl,bl,b, b,b,b,b,b,b,b,b ] sense.set_pixels(picobot_pixels) gyroData() if __name__ == '__main__': main()
Posts: 3
Participants: 2