Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect two odrive boards #25

Open
MoonWalkerAZ opened this issue Dec 30, 2021 · 2 comments
Open

Connect two odrive boards #25

MoonWalkerAZ opened this issue Dec 30, 2021 · 2 comments

Comments

@MoonWalkerAZ
Copy link

MoonWalkerAZ commented Dec 30, 2021

How can I connect two odrive boards, so that I would be able to control four motors ?

I tried this:

odrv0 = odrive.find_any(serial_number="my_serial")
self.driver = ODriveInterfaceAPI(active_odrive=odrv0, logger=ROSLogger())

But the problem is if one onedrive gets disconected. Then it is unable to reconnect.

@MoonWalkerAZ
Copy link
Author

If you want to connect odrive by its serial number do the following:
In file odrive_interface.py change connect function:
from

def connect(self, port=None, right_axis=0, timeout=30):
...
self.driver = odrive.find_any(timeout=timeout, logger=self.logger)

to

def connect(self, port=None, right_axis=0, timeout=30, serial_number=None): 
...
self.driver = odrive.find_any(timeout=timeout, serial_number=serial_number, logger=self.logger)

And in file: odrive_node.py change:
from
if not self.driver.connect(right_axis=self.axis_for_right):
to
if not self.driver.connect(serial_number= "my_serial",right_axis=self.axis_for_right):

If you want to run both boards at the same time you should run two separate nodes ?

@MoonWalkerAZ
Copy link
Author

I tried running two odrive nodes at the same time, but when I send zero velocities to both odrive boards:
rostopic pub /cmd_vel geometry_msgs/Twist '{linear: {x: 0.0, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}' -r 10

I get this error:

[ERROR] [1641035058.119541]: ODrive USB connection failure in fast_timer.Traceback (most recent call last):
  File "/home/pi/catkin_ws/src/odrive_ros/src/odrive_ros/odrive_node.py", line 304, in fast_timer
    error_string = self.driver.get_errors()
fibre.protocol.ChannelBrokenException

[ERROR] [1641035058.132330]: Error in timer: Traceback (most recent call last):
  File "/home/pi/catkin_ws/src/odrive_ros/src/odrive_ros/odrive_interface.py", line 102, in disconnect
    self.release()
  File "/home/pi/catkin_ws/src/odrive_ros/src/odrive_ros/odrive_interface.py", line 255, in release
    axis.requested_state = AXIS_STATE_IDLE
  File "/usr/local/lib/python3.8/dist-packages/fibre/remote_object.py", line 258, in __setattr__
    raise AttributeError("Attribute {} not found".format(name))
AttributeError: Attribute requested_state not found

Result is that one odrive board disconnects itself.
When I send any other velocities that move the wheels I don't get this error. The problem only shows it self when I try to keep motors at fixed position. Also if I only launch one odrive board and send velocities 0 I don't get an error. I don't know why.

Can someone help ? @neomanic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant