Factor-Robotics / odrive_ros2_control

ODrive driver for ros2_control
Apache License 2.0
250 stars 82 forks source link

fail to run controller_manager #18

Open henryliuliuliu opened 2 years ago

henryliuliuliu commented 2 years ago

THIS IS my controller.yaml file

controller_manager:
  ros__parameters:
    update_rate: 100 # Hz

    joint_state_broadcaster:
      type: joint_state_broadcaster/JointStateBroadcaster

    joint0_position_controller:
      type: position_controllers/JointGroupPositionController

    joint0_velocity_controller:
      type: velocity_controllers/JointGroupVelocityController

    joint0_effort_controller:
      type: effort_controllers/JointGroupEffortController

    joint1_position_controller:
      type: position_controllers/JointGroupPositionController

    joint1_velocity_controller:
      type: velocity_controllers/JointGroupVelocityController

    joint1_effort_controller:
      type: effort_controllers/JointGroupEffortController

    group_position_controller:
      type: position_controllers/JointGroupPositionController

    group_velocity_controller:
      type: velocity_controllers/JointGroupVelocityController

    group_effort_controller:
      type: effort_controllers/JointGroupEffortController

joint0_position_controller:
  ros__parameters:
    joints:
      - joint0

joint0_velocity_controller:
  ros__parameters:
    joints:
      - joint0

joint0_effort_controller:
  ros__parameters:
    joints:
      - joint0

joint1_position_controller:
  ros__parameters:
    joints:
      - joint1

joint1_velocity_controller:
  ros__parameters:
    joints:
      - joint1

joint1_effort_controller:
  ros__parameters:
    joints:
      - joint1

group_position_controller:
  ros__parameters:
    joints:
      - joint0
      - joint1

group_velocity_controller:
  ros__parameters:
    joints:
      - joint0
      - joint1

group_effort_controller:
  ros__parameters:
    joints:
      - joint0
      - joint1

This is my launch file

# Copyright 2021 Factor Robotics
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.conditions import IfCondition
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare

def generate_launch_description():
    declared_arguments = []

    declared_arguments.append(
        DeclareLaunchArgument(
            "enable_joint0",
            default_value="true",
        )
    )

    declared_arguments.append(
        DeclareLaunchArgument(
            "enable_joint1",
            default_value="true",
        )
    )

    declared_arguments.append(
        DeclareLaunchArgument(
            "joint0_controller",
            default_value="joint0_position_controller",
        )
    )
    declared_arguments.append(
        DeclareLaunchArgument(
            "joint1_controller",
            default_value="joint1_position_controller",
        )
    )

    enable_joint0 = LaunchConfiguration("enable_joint0")
    enable_joint1 = LaunchConfiguration("enable_joint1")
    joint0_controller = LaunchConfiguration("joint0_controller")
    joint1_controller = LaunchConfiguration("joint1_controller")

    robot_description_content = Command(
        [
            PathJoinSubstitution([FindExecutable(name="xacro")]),
            " ",
            PathJoinSubstitution(
                [
                    FindPackageShare("odrive_description"),
                    "urdf",
                    "odrive.urdf.xacro",
                ]
            ),
            " ",
            "enable_joint0:=",
            enable_joint0,
            " ",
            "enable_joint1:=",
            enable_joint1,
        ]
    )
    robot_description = {"robot_description": robot_description_content}

    robot_controllers = PathJoinSubstitution(
        [
            FindPackageShare("odrive_bringup"),
            "config",
            "odrive_controllers.yaml",
        ]
    )

    control_node = Node(
        package="controller_manager",
        executable="ros2_control_node",
        parameters=[robot_description, robot_controllers],
        output={
            "stdout": "screen",
            "stderr": "screen",
        },
    )

    robot_state_pub_node = Node(
        package="robot_state_publisher",
        executable="robot_state_publisher",
        output="both",
        parameters=[robot_description],
    )

    joint_state_broadcaster_spawner = Node(
        package="controller_manager",
        executable="spawner.py",
        arguments=["joint_state_broadcaster", "--controller-manager", "/controller_manager"],
    )

    joint0_controller_spawner = Node(
        package="controller_manager",
        executable="spawner.py",
        arguments=[joint0_controller, "-c", "/controller_manager"],
        condition=IfCondition(enable_joint0),
    )

    joint1_controller_spawner = Node(
        package="controller_manager",
        executable="spawner.py",
        arguments=[joint1_controller, "-c", "/controller_manager"],
        condition=IfCondition(enable_joint1),
    )

    nodes = [
        control_node,
        robot_state_pub_node,
        joint_state_broadcaster_spawner,
        joint0_controller_spawner,
        joint1_controller_spawner,
    ]

    return LaunchDescription(declared_arguments + nodes)

[ERROR] [ros2_control_node-1]: process has died [pid 28410, exit code -6, cmd '/opt/ros/foxy/lib/controller_manager/ros2_control_node --ros-args --params-file /tmp/launch_params_0nfwf8mm --params-file /home/khadas/workspace/install/odrive_bringup/share/odrive_bringup/config/odrive_controllers.yaml']. Could any one tell me the reason why it fails?

borongyuan commented 2 years ago

Hi, Your configuration looks fine, there should be other problems. Is there any other error message before this one? Other issues like communication failures can cause this error.

ReginaldSourn commented 2 years ago

I've used default configurations with jetson nano and version ROS foxy. I'm a beginner with ROS2 I don't know the real problem, please acknowledge the problem. I don't know the real problem.

INFO] [launch]: Default logging verbosity is set to INFO [INFO] [ros2_control_node-1]: process started with pid [7383] [INFO] [robot_state_publisher-2]: process started with pid [7385] [INFO] [spawner.py-3]: process started with pid [7387] [INFO] [spawner.py-4]: process started with pid [7389] [robot_state_publisher-2] Parsing robot urdf xml string. [robot_state_publisher-2] Link link0 had 0 children [robot_state_publisher-2] [INFO] [1655720483.823214464] [robot_state_publisher]: got segment link0 [robot_state_publisher-2] [INFO] [1655720483.823509470] [robot_state_publisher]: got segment world [spawner.py-3] Traceback (most recent call last): [spawner.py-3] File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 204, in <module> [spawner.py-3] sys.exit(main()) [spawner.py-3] File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 123, in main [spawner.py-3] if is_controller_loaded(node, controller_manager_name, controller_name): [spawner.py-3] File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 65, in is_controller_loaded [spawner.py-3] controllers = list_controllers(node, controller_manager).controller [spawner.py-3] File "/opt/ros/foxy/lib/python3.8/site-packages/controller_manager/controller_manager_services.py", line 49, in list_controllers [spawner.py-3] return service_caller(node, f'{controller_manager_name}/list_controllers', [spawner.py-3] File "/opt/ros/foxy/lib/python3.8/site-packages/controller_manager/controller_manager_services.py", line 29, in service_caller [spawner.py-3] raise RuntimeError(f'Could not contact service {service_name}') [spawner.py-3] RuntimeError: Could not contact service /controller_manager/list_controllers [spawner.py-4] Traceback (most recent call last): [spawner.py-4] File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 204, in <module> [spawner.py-4] sys.exit(main()) [spawner.py-4] File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 123, in main [spawner.py-4] if is_controller_loaded(node, controller_manager_name, controller_name): [spawner.py-4] File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 65, in is_controller_loaded [spawner.py-4] controllers = list_controllers(node, controller_manager).controller [spawner.py-4] File "/opt/ros/foxy/lib/python3.8/site-packages/controller_manager/controller_manager_services.py", line 49, in list_controllers [spawner.py-4] return service_caller(node, f'{controller_manager_name}/list_controllers', [spawner.py-4] File "/opt/ros/foxy/lib/python3.8/site-packages/controller_manager/controller_manager_services.py", line 29, in service_caller [spawner.py-4] raise RuntimeError(f'Could not contact service {service_name}') [spawner.py-4] RuntimeError: Could not contact service /controller_manager/list_controllers [ERROR] [spawner.py-4]: process has died [pid 7389, exit code 1, cmd '/opt/ros/foxy/lib/controller_manager/spawner.py joint0_velocity_controller -c /controller_manager --ros-args']. [ERROR] [spawner.py-3]: process has died [pid 7387, exit code 1, cmd '/opt/ros/foxy/lib/controller_manager/spawner.py joint_state_broadcaster --controller-manager /controller_manager --ros-args'].

rgruberski commented 2 years ago

I've used default configurations with jetson nano and version ROS foxy. I'm a beginner with ROS2 I don't know the real problem, please acknowledge the problem. I don't know the real problem.

INFO] [launch]: Default logging verbosity is set to INFO [INFO] [ros2_control_node-1]: process started with pid [7383] [INFO] [robot_state_publisher-2]: process started with pid [7385] [INFO] [spawner.py-3]: process started with pid [7387] [INFO] [spawner.py-4]: process started with pid [7389] [robot_state_publisher-2] Parsing robot urdf xml string. [robot_state_publisher-2] Link link0 had 0 children [robot_state_publisher-2] [INFO] [1655720483.823214464] [robot_state_publisher]: got segment link0 [robot_state_publisher-2] [INFO] [1655720483.823509470] [robot_state_publisher]: got segment world [spawner.py-3] Traceback (most recent call last): [spawner.py-3] File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 204, in <module> [spawner.py-3] sys.exit(main()) [spawner.py-3] File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 123, in main [spawner.py-3] if is_controller_loaded(node, controller_manager_name, controller_name): [spawner.py-3] File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 65, in is_controller_loaded [spawner.py-3] controllers = list_controllers(node, controller_manager).controller [spawner.py-3] File "/opt/ros/foxy/lib/python3.8/site-packages/controller_manager/controller_manager_services.py", line 49, in list_controllers [spawner.py-3] return service_caller(node, f'{controller_manager_name}/list_controllers', [spawner.py-3] File "/opt/ros/foxy/lib/python3.8/site-packages/controller_manager/controller_manager_services.py", line 29, in service_caller [spawner.py-3] raise RuntimeError(f'Could not contact service {service_name}') [spawner.py-3] RuntimeError: Could not contact service /controller_manager/list_controllers [spawner.py-4] Traceback (most recent call last): [spawner.py-4] File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 204, in <module> [spawner.py-4] sys.exit(main()) [spawner.py-4] File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 123, in main [spawner.py-4] if is_controller_loaded(node, controller_manager_name, controller_name): [spawner.py-4] File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 65, in is_controller_loaded [spawner.py-4] controllers = list_controllers(node, controller_manager).controller [spawner.py-4] File "/opt/ros/foxy/lib/python3.8/site-packages/controller_manager/controller_manager_services.py", line 49, in list_controllers [spawner.py-4] return service_caller(node, f'{controller_manager_name}/list_controllers', [spawner.py-4] File "/opt/ros/foxy/lib/python3.8/site-packages/controller_manager/controller_manager_services.py", line 29, in service_caller [spawner.py-4] raise RuntimeError(f'Could not contact service {service_name}') [spawner.py-4] RuntimeError: Could not contact service /controller_manager/list_controllers [ERROR] [spawner.py-4]: process has died [pid 7389, exit code 1, cmd '/opt/ros/foxy/lib/controller_manager/spawner.py joint0_velocity_controller -c /controller_manager --ros-args']. [ERROR] [spawner.py-3]: process has died [pid 7387, exit code 1, cmd '/opt/ros/foxy/lib/controller_manager/spawner.py joint_state_broadcaster --controller-manager /controller_manager --ros-args'].

Hi @ReginaldSourn,

Just check that you have selected the correct branch, must be the same as your odrive firmware version. I had the same problem with the RPi board, after the branch change, everything works great.

ReginaldSourn commented 2 years ago

Thank @rgruberski!! the solutions Still not working. I try to dig to get some clues. For now, I have questions for @borongyuan why the spawner /controller_manager/list_controller can't find joint_state_broadcaster? is it the bug from hardware_interface ? Thanks for the answers @borongyuan. _My Remote is JETSONNANO and I using Ros Foxy Thanks!!!

ReginaldSourn commented 2 years ago

@rgruberski you're right !! what I was missing is I changed only the Odrivetool version and branch version switching from fw-v0.5.3 to fw-v0.5.1. I haven't changed firmware by usingodrivetool dfu and downgrading versions of the firmware Odrive. So, to change firmware we need to go Odrive Firmware Release and then download the correct firmware matching with the branch we want to use. I am using fw-v0.5.3 firmware to upload it :

libsub also can create trouble in compiling also please make sure we use libusb-1.0.0 not libusb-0.1-4. after that, we need configurations odrive hardware with python scripts before running testing axis0 spinning.

Thank @borongyuan for giving me the answer.

Mohamed-Abduljawad commented 3 months ago

@ReginaldSourn I did all the steps you mentioned, flashed the firmware, removed libusb-0.1-4 so it won't mess up with the driver yet it's not working.

What are the odrive hardware configuration you mentioned?

The first error when I run ros2 launch odrive_demo_bringup odrive_multi_interface.launch.py is [ros2_control_node-1] [ERROR] [1715076370.189590262] [ODriveHardwareInterface]: LIBUSB_ERROR_NO_DEVICE

full output below:

[INFO] [launch]: All log files can be found below /home/dfl-nuc/.ros/log/2024-05-07-14-06-09-950979-DFL-MOTF-22578
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [ros2_control_node-1]: process started with pid [22582]
[INFO] [robot_state_publisher-2]: process started with pid [22584]
[INFO] [spawner-3]: process started with pid [22586]
[INFO] [spawner-4]: process started with pid [22588]
[robot_state_publisher-2] [INFO] [1715076370.182560119] [robot_state_publisher]: got segment link0
[robot_state_publisher-2] [INFO] [1715076370.182638221] [robot_state_publisher]: got segment world
[ros2_control_node-1] [WARN] [1715076370.186820647] [controller_manager]: [Deprecated] Passing the robot description parameter directly to the control_manager node is deprecated. Use '~/robot_description' topic from 'robot_state_publisher' instead.
[ros2_control_node-1] [INFO] [1715076370.186915140] [resource_manager]: Loading hardware 'odrive_ros2_control' 
[ros2_control_node-1] [INFO] [1715076370.187525758] [resource_manager]: Initialize hardware 'odrive_ros2_control' 
[ros2_control_node-1] [ERROR] [1715076370.189590262] [ODriveHardwareInterface]: LIBUSB_ERROR_NO_DEVICE
[ros2_control_node-1] [INFO] [1715076370.189603841] [resource_manager]: Failed to initialize hardware 'odrive_ros2_control'
[ros2_control_node-1] [WARN] [1715076370.189607697] [resource_manager]: System hardware component 'odrive_ros2_control' from plugin 'odrive_hardware_interface/ODriveHardwareInterface' failed to initialize.
[ros2_control_node-1] [WARN] [1715076370.189625666] [resource_manager]: hardware 'odrive_ros2_control' is in finalized state and can be only destroyed.
[ros2_control_node-1] [INFO] [1715076370.191904261] [controller_manager]: update rate is 100 Hz
[ros2_control_node-1] [INFO] [1715076370.191994197] [controller_manager]: RT kernel is recommended for better performance
[ros2_control_node-1] [INFO] [1715076370.402773813] [controller_manager]: Loading controller 'joint_state_broadcaster'
[ros2_control_node-1] [INFO] [1715076370.412368534] [controller_manager]: Loading controller 'joint0_velocity_controller'
[spawner-3] [INFO] [1715076370.424242899] [spawner_joint_state_broadcaster]: Loaded joint_state_broadcaster
[ros2_control_node-1] [INFO] [1715076370.424803717] [controller_manager]: Configuring controller 'joint_state_broadcaster'
[ros2_control_node-1] [INFO] [1715076370.424905361] [joint_state_broadcaster]: 'joints' or 'interfaces' parameter is empty. All available state interfaces will be published
[spawner-4] [INFO] [1715076370.434386577] [spawner_joint0_velocity_controller]: Loaded joint0_velocity_controller
[ros2_control_node-1] [ERROR] [1715076370.442102062] [joint_state_broadcaster]: None of requested interfaces exist. Controller will not run.
[ros2_control_node-1] [WARN] [1715076370.442127560] [joint_state_broadcaster]: Error occurred while doing error handling.
[ros2_control_node-1] [ERROR] [1715076370.442147261] [controller_manager]: After activation, controller 'joint_state_broadcaster' is in state 'unconfigured' (1), expected 'active' (3).
[ros2_control_node-1] [INFO] [1715076370.452367817] [controller_manager]: Configuring controller 'joint0_velocity_controller'
[spawner-3] [INFO] [1715076370.452858144] [spawner_joint_state_broadcaster]: Configured and activated joint_state_broadcaster
[ros2_control_node-1] [INFO] [1715076370.453291732] [joint0_velocity_controller]: configure successful
[ros2_control_node-1] [ERROR] [1715076370.463196457] [resource_manager]: Not acceptable command interfaces combination: 
[ros2_control_node-1] Start interfaces: 
[ros2_control_node-1] [
[ros2_control_node-1]   joint0/velocity
[ros2_control_node-1] ]
[ros2_control_node-1] Stop interfaces: 
[ros2_control_node-1] [
[ros2_control_node-1] ]
[ros2_control_node-1] Not existing: 
[ros2_control_node-1] [
[ros2_control_node-1]  joint0/velocity
[ros2_control_node-1] 
[ros2_control_node-1] [ERROR] [1715076370.463218180] [controller_manager]: Could not switch controllers since prepare command mode switch was rejected.
[spawner-4] [ERROR] [1715076370.463688470] [spawner_joint0_velocity_controller]: Failed to activate controller
[INFO] [spawner-3]: process has finished cleanly [pid 22586]
[ERROR] [spawner-4]: process has died [pid 22588, exit code 1, cmd '/opt/ros/humble/lib/controller_manager/spawner joint0_velocity_controller -c /controller_manager --ros-args'].
^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)
[robot_state_publisher-2] [INFO] [1715076543.361967167] [rclcpp]: signal_handler(signum=2)
[ros2_control_node-1] [INFO] [1715076543.361978167] [rclcpp]: signal_handler(signum=2)
[INFO] [robot_state_publisher-2]: process has finished cleanly [pid 22584]
[INFO] [ros2_control_node-1]: process has finished cleanly [pid 22582]

My setup is ubuntu 22.04.4, Odrive 3.6 24v. FW 0.5.3

Mohamed-Abduljawad commented 3 months ago

Found the solution. Odrivetool was blocking the USB port, I had to quit it so the driver can access it