Robotics StackExchange | Archived questions

ROS2 humble, controller wont connect to service

Hello, Running ROS2 humble, Ubuntu 22.04.1LTS.

I have a model which is spawned in gazebo 11, and another node which is publishing data on '/forwardpositioncontroller/commands', and the model is supposed to movie in space.

My problem is running the controller.

I have a yaml:

controller_manager:
 ros__parameters:
  update_rate: 100

  joint_trajectory_controller:
    type: joint_trajectory_controller/JointTrajectoryController

  #broadcaste the state
  joint_state_broadcaster:
    type: joint_state_broadcaster/JointStateBroadcaster

  #joint_trajectory_controller:
  #  type: joint_trajectory_controller/JointTrajectoryController

  forward_position_controller:
    type: forward_command_controller/ForwardCommandController
  forward_vilocity_controller:
    type: forward_command_controller/ForwardCommandController


forward_position_controller:
  ros__parameters:
   joints:
    - crutch_joint__imu_position #joint the controller will control
   interface_name: position       #same name as defined in the sdf/urdf file
   command_interfaces:
     - position                   # 
  state_interfaces:
    - position
    - velocity

forward_vilocity_controller:
  ros__parameters:
   joints:
    - crutch_joint__imu_position
    interface_name: velocity
    command_interfaces:
     - velocity
   state_interfaces:
    - velocity

and in my launch I run the controller

     ExecuteProcess(
        cmd=['ros2', 'control', 'load_controller', '--set-state', 'active', "forward_position_controller"],
        name="forward_position_controller",
        output='screen'),

    #Start controller
    ExecuteProcess(
        cmd=['ros2', 'control', 'load_controller', '--set-state', 'active', "forward_velocity_controller"],
        name="forward_velocity_controller",
        output='screen'),

but I always get the same error: "Could not contact service /controllermanager/loadcontroller"

A friend of mine running ros2 galactic is having the same issue Another friend is running ros1 and having similar issue. (its done little bit different but same error)

Is there any other way to move a model which is spawned in gazebo11 from a node that publishes data, any data. All i need for now is just to move the model....

BR, Anis

Asked by Anis_Shakkour on 2023-02-19 05:58:42 UTC

Comments

Not (necessarily) the cause, but just wanted to draw attention to the forward_vilocity_controller vs forward_velocity_controller ..

Asked by gvdhoorn on 2023-02-19 12:15:50 UTC

Yeah I noticed it, but not fixing the problem.

Asked by Anis_Shakkour on 2023-02-20 09:19:06 UTC

Answers

Hello, You need to add the controller_manager node to your launch file to be able to load controllers. Also, you will not need to load the controllers manually with the ExecuteProcess command. However, you will need your robots URDF to be able to launch the ros2_control hardware components. You can replace your ExecuteProcess with this :

Node(
    package="controller_manager",
    executable="ros2_control_node",
    parameters=[<your_robots_urdf>, <your_controllers_yaml_file_path>]
)

Asked by Sam_Prt on 2023-02-20 14:15:35 UTC

Comments