Open mdurrani808 opened 8 months ago
I assume that in the launch file you are able to include multiple nodes and specify a different name and nodeid, have you tried to modify the launch file?
I tested this and this launch file appears to work
launch:
- node:
pkg: "odrive_can"
exec: "odrive_can_node"
name: "can_node"
namespace: "odrive_axis0"
param:
-
name: "node_id"
value: 0
-
name: "interface"
value: "can0"
- node:
pkg: "odrive_can"
exec: "odrive_can_node"
name: "can_node"
namespace: "odrive_axis1"
param:
-
name: "node_id"
value: 1
-
name: "interface"
value: "can0"
Here is what the launch looks like
admin@ros2:/workspaces/isaac_ros-dev$ ros2 launch odrive_can example_launch.yaml
[INFO] [launch]: All log files can be found below /home/admin/.ros/log/2024-01-17-21-59-05-119069-ros2-9297
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [odrive_can_node-1]: process started with pid [9300]
[INFO] [odrive_can_node-2]: process started with pid [9302]
[odrive_can_node-1] [INFO] [1705553945.699522427] [odrive_axis0.can_node]: node_id: 0
[odrive_can_node-1] [INFO] [1705553945.699841638] [odrive_axis0.can_node]: interface: can0
[odrive_can_node-2] [INFO] [1705553945.699699777] [odrive_axis1.can_node]: node_id: 1
[odrive_can_node-2] [INFO] [1705553945.699973003] [odrive_axis1.can_node]: interface: can0
and the topics
admin@ros2:/workspaces/isaac_ros-dev$ ros2 topic list
/odrive_axis0/control_message
/odrive_axis0/controller_status
/odrive_axis0/odrive_status
/odrive_axis1/control_message
/odrive_axis1/controller_status
/odrive_axis1/odrive_status
/parameter_events
/rosout
Got it, that is helpful. One last question, would I then need to edit main.cpp and instantiate/initialize a ODriveCanNode per motor? Thanks!
https://github.com/odriverobotics/odrive_can/blob/main/src/main.cpp#L9-L11
I don't believe you will need to modify that. The launch file is essentially launching a new copy for you. It appears to work just fine. Let me know if you see differently.
Hi, can anyone provide an example launch file / python or C++ code for using multiple ODrive controllers? I'm mainly confused how I would refer to different nodes in code vs in the launch file. Thank you!