- ev3dev-stretch-rpi2-generic image.
- RaspberryPi 3 model B + BrickPi 3
I have installed ROS using your tutorial and I met with followed problems:
I have RemoteControlsSubscriber.py node:
#!/usr/bin/env python
from __future__ import print_function
import roslib
roslib.load_manifest('learn_network')
import sys
import rospy
from learn_network.msg import RemoteControls
from SteeringController import SteeringController
class RemoteControlsSubscriber:
def __init__(self, topic_name, steeringController):
self.subscriber = rospy.Subscriber(topic_name, ImageSteering ,self.get_controls)
self.steeringController = steeringController
def run_subscribe(self, subscriber_name):
rospy.init_node(subscriber_name, anonymous=True)
rospy.spin()
def get_controls(self, remote_controls):
self.steeringController.run_to_abs_pos_range(remote_controls.rigth_stick_horizontal_axis)
sleep(0.2)
if __name__ == '__main__':
try:
steeringController = SteeringController('C', 125, 900)
remoteControlsSubscriber = RemoteControlsSubscriber('remote_controls_topic')
remoteControlsSubscriber.run_subscribe('remote_controls_subscriber_node')
except rospy.ROSInterruptException:
pass
And SteeringController.py file
#!/usr/bin/env python3
from ev3dev.brickpi import *
class SteeringController:
def __init__(self, motor_port, max_angle, speed_sp):
self.motor = LargeMotor(motor_port)
self.zero_position = self.motor.position
self.max_angle = max_angle
self.speed_sp = speed_sp
self.stop_action = "hold"
def __del__ (self):
self.motor.stop()
self.motor.reset()
self.print_motor_info()
def print_motor_info(self):
print("position: " + str(self.motor.position))
print("is_holding: " + str(self.motor.is_holding))
print("is_overloaded: " + str(self.motor.is_overloaded))
print("is_ramping: " + str(self.motor.is_ramping))
print("is_running: " + str(self.motor.is_running))
print("is_stalled: " + str(self.motor.is_stalled))
def run_to_rel_pos(self, position_sp):
if self.motor.position + position_sp > self.zero_position + self.max_angle:
raise Exception("Too big steering angle")
if self.motor.position + position_sp < self.zero_position - self.max_angle:
raise Exception("Too small steering angle")
self.motor.run_to_rel_pos(position_sp=position_sp, speed_sp=self.speed_sp, stop_action=self.stop_action)
def run_to_abs_pos(self, position_sp):
if position_sp > self.max_angle:
raise Exception("Too big steering angle")
if position_sp < -self.max_angle:
raise Exception("Too small steering angle")
self.motor.run_to_abs_pos(position_sp=position_sp, speed_sp=self.speed_sp, stop_action=self.stop_action)
def run_to_abs_pos_range(self, range):
self.run_to_abs_pos(self.max_angle*range)
def run_to_zero_pos(self):
self.motor.run_to_abs_pos(position_sp=self.zero_position, speed_sp=self.speed_sp, stop_action=self.stop_action)
RemoteControlsSubscriber.py node import SteeringController.py file.
When I run node: rosrun learn_network RemoteControlsSubscriber.py
I get:
terminate called after throwing an instance of 'rospack::Exception'
what(): error parsing manifest of package class_loader at /opt/ros/melodic/share/class_loader/package.xml
find: '': No such file or directory
Traceback (most recent call last):
File "/home/robot/Tesla/CatkinWorkspaces/src/learn_network/scripts/RemoteControlsSubscriber.py", line 8, in <module>
from SteeringController import SteeringController
File "/home/robot/Tesla/CatkinWorkspaces/src/learn_network/scripts/SteeringController.py", line 4, in <module>
from ev3dev.brickpi import *
ImportError: No module named brickpi
I have another file (SteeringScript.py) whitch also import SteeringController.py.
When I run python3 SteeringScript.py everything work fine.
When I run python SteeringScript.py i get same error:
Traceback (most recent call last):
File "SteeringScript.py", line 1, in <module>
from SteeringController import SteeringController
File "/home/robot/Tesla/Beta/SteeringController.py", line 4, in <module>
from ev3dev.brickpi import *
ImportError: No module named brickpi
So rospy run nodes trough python2, is any way of runing nodes trough python3? It is very crucial for me, because a can't use ev3dev library through ROS : /
I have installed ROS using your tutorial and I met with followed problems:
I have
RemoteControlsSubscriber.pynode:And
SteeringController.pyfileRemoteControlsSubscriber.pynode importSteeringController.pyfile.When I run node:
rosrun learn_network RemoteControlsSubscriber.pyI get:
I have another file (
SteeringScript.py) whitch also importSteeringController.py.When I run
python3 SteeringScript.pyeverything work fine.When I run
python SteeringScript.pyi get same error:So rospy run nodes trough python2, is any way of runing nodes trough python3? It is very crucial for me, because a can't use ev3dev library through ROS : /