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

Adding cartesian_force_controller to controller_manager in ros2 #61

Closed
cschempp opened this issue Jun 15, 2022 · 14 comments
Closed

Adding cartesian_force_controller to controller_manager in ros2 #61

cschempp opened this issue Jun 15, 2022 · 14 comments
Labels
ROS2 solution proposed A solution has been proposed inside the issue

Comments

@cschempp
Copy link

Hello,

i tried adding the cartesian_force_controller from the ros2 branch into the ur_control.launch.py of the UR ROS2 Driver package.
Therefore i cloned this repo and build the packages cartesian_controller_base and cartesian_force_controller in my workspace.
I then added

cartesian_force_controller_spawner_stopped = Node(
     package="controller_manager",
     executable="spawner",
     arguments=["cartesian_force_controller", "-c", "/controller_manager", "--stopped"],
    )

to the launch_setup in ur_control.launch.py and cartesian_force_controller_spawner_stopped in the nodes_to_start = [ .... ].

In the ur_controllers.yaml where the controllers are defined, i added

cartesian_force_controller:
  ros__parameters:
    end_effector_link: "tool0"
    robot_base_link: "base_link"
    ft_sensor_ref_link: "sensor_link"
    joints:
      - shoulder_pan_joint
      - shoulder_lift_joint
      - elbow_joint
      - wrist_1_joint
      - wrist_2_joint
      - wrist_3_joint
      
    pd_gains:
        trans_x: {p: 0.05}
        trans_y: {p: 0.05}
        trans_z: {p: 0.05}
        rot_x: {p: 0.01}
        rot_y: {p: 0.01}
        rot_z: {p: 0.01}

and under controller_manager: ros__parameters: i added the line

cartesian_force_controller:
      type: position_controllers/CartesianForceController

If i list the controller types with ros2 control list_controller_types, the cartesian_force_controller/CartesianForceController is there.
But loading the controller with ros2 control load_controller cartesian_force_controller yields the error message:
Error loading controller, check controller_manager logs. The logs say "Loader for controller 'cartesian_force_controller' not found".

What is the correct way to register a new controller to the controller_manager started in an existing .launch file?

Any help would be really appreciated.

@cschempp cschempp changed the title Adding cartesian_force_controller to controller_manager Adding cartesian_force_controller to controller_manager in ros2 Jun 15, 2022
@stefanscherzinger
Copy link
Contributor

Hi @cschempp

The port to ROS2 is currently under development. Please use the ros2-devel branch for the meantime.
You can build the complete cartesian_controllers package inside a ROS2 workspace with colcon. Unported packages are colcon-ignored.

But loading the controller with ros2 control load_controller cartesian_force_controller yields the error message:

Yes, the controller's type changed to cartesian_force_controller/CartesianForceController. That would now be:

controller_manager:
  ros__parameters:

...

    cartesian_force_controller:
      type: cartesian_force_controller/CartesianForceController

... 

Also note that the controller gains might need some smaller adaptation to ROS2. This is currently experimental. Anything you can share about your experience on your system (+ use case an good controller parameters) is greatly appreciated!

@cschempp
Copy link
Author

Hi @stefanscherzinger ,

thank you for the quick reply. Ok, i will use the ros2-devel branch.
We are going to use an UR5e and other industrial manipulators for automated assembly.
Therefore i'm highly interested in getting the cartesian controllers ported to ros2.
Of course, i will be happy to help in regards of testing on real-hardware.

@TheFalcoGuy
Copy link

Hi, I am also using a UR5e robot for force control. I followed @cschempp 's steps to run the controller along with @stefanscherzinger 's suggestions. I ran the launch command

ros2 launch ur_bringup ur_control.launch.py ur_type:=ur5e robot_ip:=192.168.0.88 launch_rviz:=false
However, I get the following error:
[ros2_control_node-1] [INFO] [1656640062.114959053] [cartesian_force_controller]: Forward dynamics solver initialized [ros2_control_node-1] [INFO] [1656640062.114976674] [cartesian_force_controller]: Forward dynamics solver has control over 6 joints [ros2_control_node-1] [ERROR] [1656640062.115359766] [cartesian_force_controller]: No command_interfaces specified [ros2_control_node-1] [ERROR] [1656640062.115416897] [controller_manager]: After configuring, controller 'cartesian_force_controller' is in state 'finalized' , expected inactive. [spawner.py-13] [INFO] [1656640062.115944629] [spawner_cartesian_force_controller]: Failed to configure controller
The controller successfully loaded, but failed to be configure and was unable to start. I am wondering what the solution for this issue is? Below is the full error message (FYI I am porting the compliance controller to ROS 2). Thanks.
[INFO] [launch]: All log files can be found below /home/d-lab/.ros/log/2022-06-30-21-47-39-364486-dlab-Alienware-m15-R6-393766 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [dashboard_client-2]: process started with pid [393772] [INFO] [controller_stopper_node-3]: process started with pid [393774] [INFO] [ros2_control_node-1]: process started with pid [393770] [INFO] [robot_state_publisher-4]: process started with pid [393776] [INFO] [spawner.py-5]: process started with pid [393778] [INFO] [spawner.py-6]: process started with pid [393780] [INFO] [spawner.py-7]: process started with pid [393782] [INFO] [spawner.py-8]: process started with pid [393784] [INFO] [spawner.py-9]: process started with pid [393786] [INFO] [torque_broadcaster-10]: process started with pid [393788] [INFO] [gripper-11]: process started with pid [393790] [INFO] [spawner.py-12]: process started with pid [393792] [INFO] [spawner.py-13]: process started with pid [393794] [dashboard_client-2] [INFO] [1656640059.657408369] [UR_Client_Library]: Connected: Universal Robots Dashboard Server [dashboard_client-2] [robot_state_publisher-4] Parsing robot urdf xml string. [controller_stopper_node-3] [INFO] [1656640059.664828509] [Controller stopper]: Waiting for switch controller service to come up on controller_manager/switch_controller [robot_state_publisher-4] Link base had 0 children [robot_state_publisher-4] Link base_link_inertia had 1 children [robot_state_publisher-4] Link shoulder_link had 1 children [robot_state_publisher-4] Link upper_arm_link had 1 children [robot_state_publisher-4] Link forearm_link had 1 children [robot_state_publisher-4] Link wrist_1_link had 1 children [robot_state_publisher-4] Link wrist_2_link had 1 children [robot_state_publisher-4] Link wrist_3_link had 1 children [robot_state_publisher-4] Link flange had 1 children [robot_state_publisher-4] Link tool0 had 0 children [robot_state_publisher-4] [INFO] [1656640059.665007402] [robot_state_publisher]: got segment base [robot_state_publisher-4] [INFO] [1656640059.665082223] [robot_state_publisher]: got segment base_link [robot_state_publisher-4] [INFO] [1656640059.665091114] [robot_state_publisher]: got segment base_link_inertia [robot_state_publisher-4] [INFO] [1656640059.665096295] [robot_state_publisher]: got segment flange [robot_state_publisher-4] [INFO] [1656640059.665101301] [robot_state_publisher]: got segment forearm_link [robot_state_publisher-4] [INFO] [1656640059.665106679] [robot_state_publisher]: got segment shoulder_link [robot_state_publisher-4] [INFO] [1656640059.665112080] [robot_state_publisher]: got segment tool0 [robot_state_publisher-4] [INFO] [1656640059.665117462] [robot_state_publisher]: got segment upper_arm_link [robot_state_publisher-4] [INFO] [1656640059.665122835] [robot_state_publisher]: got segment wrist_1_link [robot_state_publisher-4] [INFO] [1656640059.665128531] [robot_state_publisher]: got segment wrist_2_link [robot_state_publisher-4] [INFO] [1656640059.665134235] [robot_state_publisher]: got segment wrist_3_link [ros2_control_node-1] [INFO] [1656640059.677263551] [URPositionHardwareInterface]: Starting ...please wait... [ros2_control_node-1] [INFO] [1656640059.677317411] [URPositionHardwareInterface]: Initializing driver... [ros2_control_node-1] [WARN] [1656640059.678489939] [UR_Client_Library]: No realtime capabilities found. Consider using a realtime system for better performance [ros2_control_node-1] [INFO] [1656640059.763582347] [UR_Client_Library]: Negotiated RTDE protocol version to 2. [ros2_control_node-1] [INFO] [1656640059.764214414] [UR_Client_Library]: Setting up RTDE communication with frequency 500.000000 [spawner.py-7] [INFO] [1656640059.789348221] [spawner_speed_scaling_state_broadcaster]: Waiting for /controller_manager services [spawner.py-12] [INFO] [1656640059.792310462] [spawner_cartesian_compliance_controller]: Waiting for /controller_manager services [spawner.py-8] [INFO] [1656640059.792652087] [spawner_force_torque_sensor_broadcaster]: Waiting for /controller_manager services [spawner.py-9] [INFO] [1656640059.793529044] [spawner_joint_trajectory_controller]: Waiting for /controller_manager services [spawner.py-6] [INFO] [1656640059.808376670] [spawner_io_and_status_controller]: Waiting for /controller_manager services [spawner.py-5] [INFO] [1656640059.817649824] [spawner_joint_state_broadcaster]: Waiting for /controller_manager services [spawner.py-13] [INFO] [1656640059.819119828] [spawner_cartesian_force_controller]: Waiting for /controller_manager services [gripper-11] [INFO] [1656640059.913314102] [gripper_control]: Ip address: 192.168.0.88 [gripper-11] [INFO] [1656640059.913532096] [gripper_control]: Connecting to ur... [gripper-11] [INFO] [1656640059.914285928] [gripper_control]: Successfully connected to ur [ros2_control_node-1] [INFO] [1656640060.804223067] [URPositionHardwareInterface]: Calibration checksum: 'calib_12788084448423163542'. [ros2_control_node-1] [WARN] [1656640060.804867007] [UR_Client_Library]: No realtime capabilities found. Consider using a realtime system for better performance [ros2_control_node-1] [ERROR] [1656640061.829180924] [URPositionHardwareInterface]: The calibration parameters of the connected robot don't match the ones from the given kinematics config file. Please be aware that this can lead to critical inaccuracies of tcp positions. Use the ur_calibration tool to extract the correct calibration from the robot and pass that into the description. See [https://github.com/UniversalRobots/Universal_Robots_ROS_Driver#extract-calibration-information] for details. [ros2_control_node-1] [WARN] [1656640061.829327513] [UR_Client_Library]: No realtime capabilities found. Consider using a realtime system for better performance [ros2_control_node-1] [INFO] [1656640061.829965280] [URPositionHardwareInterface]: System successfully started! [controller_stopper_node-3] [INFO] [1656640061.833310498] [Controller stopper]: Service available [controller_stopper_node-3] [INFO] [1656640061.833331125] [Controller stopper]: Waiting for list controllers service to come up on controller_manager/list_controllers [controller_stopper_node-3] [INFO] [1656640061.833342386] [Controller stopper]: Service available [ros2_control_node-1] [INFO] [1656640061.833596265] [controller_manager]: update rate is 600 Hz [ros2_control_node-1] [INFO] [1656640061.994937573] [controller_manager]: Loading controller 'speed_scaling_state_broadcaster' [spawner.py-7] [INFO] [1656640061.999811164] [spawner_speed_scaling_state_broadcaster]: Loaded speed_scaling_state_broadcaster [ros2_control_node-1] [INFO] [1656640062.000924466] [controller_manager]: Loading controller 'joint_trajectory_controller' [ros2_control_node-1] [INFO] [1656640062.005578421] [controller_manager]: Loading controller 'cartesian_compliance_controller' [spawner.py-9] [INFO] [1656640062.005950828] [spawner_joint_trajectory_controller]: Loaded joint_trajectory_controller [ros2_control_node-1] [INFO] [1656640062.011479185] [controller_manager]: Loading controller 'force_torque_sensor_broadcaster' [spawner.py-12] [INFO] [1656640062.012002284] [spawner_cartesian_compliance_controller]: Loaded cartesian_compliance_controller [ros2_control_node-1] [INFO] [1656640062.015654832] [controller_manager]: Configuring controller 'speed_scaling_state_broadcaster' [ros2_control_node-1] [INFO] [1656640062.015701749] [speed_scaling_state_broadcaster]: Publisher rate set to : 100.0 Hz [ros2_control_node-1] [INFO] [1656640062.016074244] [controller_manager]: Configuring controller 'joint_trajectory_controller' [ros2_control_node-1] [INFO] [1656640062.016126975] [joint_trajectory_controller]: Command interfaces are [position] and and state interfaces are [position velocity]. [spawner.py-8] [INFO] [1656640062.016192319] [spawner_force_torque_sensor_broadcaster]: Loaded force_torque_sensor_broadcaster [ros2_control_node-1] [INFO] [1656640062.016579782] [joint_trajectory_controller]: Controller state will be published at 100.00 Hz. [ros2_control_node-1] [INFO] [1656640062.017165672] [joint_trajectory_controller]: Action status changes will be monitored at 20.00 Hz. [ros2_control_node-1] [INFO] [1656640062.018594825] [controller_manager]: Loading controller 'io_and_status_controller' [ros2_control_node-1] [INFO] [1656640062.023572215] [controller_manager]: Configuring controller 'cartesian_compliance_controller' [spawner.py-6] [INFO] [1656640062.023909050] [spawner_io_and_status_controller]: Loaded io_and_status_controller [ros2_control_node-1] Parsing robot urdf xml string. [ros2_control_node-1] Link base had 0 children [ros2_control_node-1] Link base_link_inertia had 1 children [ros2_control_node-1] Link shoulder_link had 1 children [ros2_control_node-1] Link upper_arm_link had 1 children [ros2_control_node-1] Link forearm_link had 1 children [ros2_control_node-1] Link wrist_1_link had 1 children [ros2_control_node-1] Link wrist_2_link had 1 children [ros2_control_node-1] Link wrist_3_link had 1 children [ros2_control_node-1] Link flange had 1 children [ros2_control_node-1] Link tool0 had 0 children [ros2_control_node-1] [INFO] [1656640062.026308993] [cartesian_compliance_controller]: Forward dynamics solver initialized [ros2_control_node-1] [INFO] [1656640062.026326548] [cartesian_compliance_controller]: Forward dynamics solver has control over 6 joints [ros2_control_node-1] [ERROR] [1656640062.026567616] [cartesian_compliance_controller]: No command_interfaces specified [ros2_control_node-1] [ERROR] [1656640062.026674745] [controller_manager]: After configuring, controller 'cartesian_compliance_controller' is in state 'finalized' , expected inactive. [ros2_control_node-1] [INFO] [1656640062.026717689] [controller_manager]: Loading controller 'cartesian_force_controller' [spawner.py-12] [INFO] [1656640062.027232622] [spawner_cartesian_compliance_controller]: Failed to configure controller [ros2_control_node-1] [INFO] [1656640062.031513031] [controller_manager]: Loading controller 'joint_state_broadcaster' [spawner.py-13] [INFO] [1656640062.032148049] [spawner_cartesian_force_controller]: Loaded cartesian_force_controller [ros2_control_node-1] [INFO] [1656640062.037526039] [controller_manager]: Configuring controller 'io_and_status_controller' [spawner.py-5] [INFO] [1656640062.037974867] [spawner_joint_state_broadcaster]: Loaded joint_state_broadcaster [ros2_control_node-1] [INFO] [1656640062.041586902] [controller_manager]: Configuring controller 'joint_state_broadcaster' [spawner.py-9] [INFO] [1656640062.042035919] [spawner_joint_trajectory_controller]: Configured and started joint_trajectory_controller [ERROR] [spawner.py-12]: process has died [pid 393792, exit code 1, cmd '/home/d-lab/workspace/ros_ur_driver/install/controller_manager/lib/controller_manager/spawner.py cartesian_compliance_controller -c /controller_manager --stopped --ros-args']. [spawner.py-6] [INFO] [1656640062.045998585] [spawner_io_and_status_controller]: Configured and started io_and_status_controller [spawner.py-5] [INFO] [1656640062.050037134] [spawner_joint_state_broadcaster]: Configured and started joint_state_broadcaster [INFO] [spawner.py-9]: process has finished cleanly [pid 393786] [INFO] [spawner.py-6]: process has finished cleanly [pid 393780] [INFO] [spawner.py-5]: process has finished cleanly [pid 393778] [ros2_control_node-1] [INFO] [1656640062.098764049] [controller_manager]: Configuring controller 'force_torque_sensor_broadcaster' [spawner.py-7] [INFO] [1656640062.101898579] [spawner_speed_scaling_state_broadcaster]: Configured and started speed_scaling_state_broadcaster [spawner.py-8] [INFO] [1656640062.105758531] [spawner_force_torque_sensor_broadcaster]: Configured and started force_torque_sensor_broadcaster [ros2_control_node-1] [INFO] [1656640062.113570794] [controller_manager]: Configuring controller 'cartesian_force_controller' [ros2_control_node-1] Parsing robot urdf xml string. [ros2_control_node-1] Link base had 0 children [ros2_control_node-1] Link base_link_inertia had 1 children [ros2_control_node-1] Link shoulder_link had 1 children [ros2_control_node-1] Link upper_arm_link had 1 children [ros2_control_node-1] Link forearm_link had 1 children [ros2_control_node-1] Link wrist_1_link had 1 children [ros2_control_node-1] Link wrist_2_link had 1 children [ros2_control_node-1] Link wrist_3_link had 1 children [ros2_control_node-1] Link flange had 1 children [ros2_control_node-1] Link tool0 had 0 children [ros2_control_node-1] [INFO] [1656640062.114959053] [cartesian_force_controller]: Forward dynamics solver initialized [ros2_control_node-1] [INFO] [1656640062.114976674] [cartesian_force_controller]: Forward dynamics solver has control over 6 joints [ros2_control_node-1] [ERROR] [1656640062.115359766] [cartesian_force_controller]: No command_interfaces specified [ros2_control_node-1] [ERROR] [1656640062.115416897] [controller_manager]: After configuring, controller 'cartesian_force_controller' is in state 'finalized' , expected inactive. [spawner.py-13] [INFO] [1656640062.115944629] [spawner_cartesian_force_controller]: Failed to configure controller [INFO] [spawner.py-7]: process has finished cleanly [pid 393782] [INFO] [spawner.py-8]: process has finished cleanly [pid 393784] [ERROR] [spawner.py-13]: process has died [pid 393794, exit code 1, cmd '/home/d-lab/workspace/ros_ur_driver/install/controller_manager/lib/controller_manager/spawner.py cartesian_force_controller -c /controller_manager --stopped --ros-args'].

@stefanscherzinger
Copy link
Contributor

Hi @TheFalcoGuy

(FYI I am porting the compliance controller to ROS 2)

Fortunately, that one got ported recently. Please contribute new features of your port with a PR :)

Concerning the error messages:

No command_interfaces specified

Comes from the controllers' base class if we don't specify the parameter hardware_interfaces in the controller_manager's config file:

cartesian_compliance_controller:
  ros__parameters:
    end_effector_link: "tool0"
    robot_base_link: "base_link"
    ft_sensor_ref_link: "tool0"
    compliance_ref_link: "tool0"
    joints:
      - joint1
      - joint2
      - joint3
      - joint4
      - joint5
      - joint6

    # Choose: position or velocity.
    command_interfaces:
      - position
        #- velocity

    stiffness:
        trans_x: 11.0
        trans_y: 22.0
        trans_z: 33.0
        rot_x: 44.0
        rot_y: 55.0
        rot_z: 66.0

    pd_gains:
        trans_x: {p: 0.05}
        trans_y: {p: 0.05}
        trans_z: {p: 0.05}
        rot_x: {p: 0.01}
        rot_y: {p: 0.01}
        rot_z: {p: 0.01}

You can take a look at the cartesian_controller_simulation config example. This parameter is a list. It supports position, velocity, or both at the same time. However, not all hardware will support both.

@stefanscherzinger stefanscherzinger added the solution proposed A solution has been proposed inside the issue label Jul 1, 2022
@TheFalcoGuy
Copy link

TheFalcoGuy commented Jul 1, 2022

Thanks for porting the compliance controller. I decided to use your controller over mine since it would be more consistent with the codebase. I cloned the latest commit, followed your solution and got the following error message when trying to load the cartesian_force_controller:
[ros2_control_node-1] [INFO] [1656694768.145045636] [controller_manager]: Loading controller 'cartesian_force_controller'
[INFO] [spawner.py-5]: process has finished cleanly [pid 49279]
[INFO] [spawner.py-8]: process has finished cleanly [pid 49285]
[INFO] [spawner.py-7]: process has finished cleanly [pid 49283]
[ERROR] [ros2_control_node-1]: process has died [pid 49271, exit code -11, cmd '/home/d-lab/workspace/ros_ur_driver/install/controller_manager/lib/controller_manager/ros2_control_node --ros-args --params-file /tmp/launch_params_enwh6276 --params-file /home/d-lab/workspace/ros_ur_driver/install/ur_bringup/share/ur_bringup/config/ur_controllers.yaml'].
Below is the full error message:
[INFO] [launch]: All log files can be found below /home/d-lab/.ros/log/2022-07-01-13-08-48-141725-dlab-Alienware-m15-R6-75908
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [dashboard_client-2]: process started with pid [75914]
[INFO] [controller_stopper_node-3]: process started with pid [75916]
[INFO] [ros2_control_node-1]: process started with pid [75912]
[INFO] [robot_state_publisher-4]: process started with pid [75918]
[INFO] [spawner.py-5]: process started with pid [75920]
[INFO] [spawner.py-6]: process started with pid [75922]
[INFO] [spawner.py-7]: process started with pid [75924]
[INFO] [spawner.py-8]: process started with pid [75926]
[INFO] [spawner.py-9]: process started with pid [75928]
[INFO] [torque_broadcaster-10]: process started with pid [75930]
[INFO] [spawner.py-11]: process started with pid [75932]
[dashboard_client-2] [INFO] [1656695328.436149071] [UR_Client_Library]: Connected: Universal Robots Dashboard Server
[dashboard_client-2]
[robot_state_publisher-4] Parsing robot urdf xml string.
[controller_stopper_node-3] [INFO] [1656695328.436978682] [Controller stopper]: Waiting for switch controller service to come up on controller_manager/switch_controller
[robot_state_publisher-4] Link base had 0 children
[robot_state_publisher-4] Link base_link_inertia had 1 children
[robot_state_publisher-4] Link shoulder_link had 1 children
[robot_state_publisher-4] Link upper_arm_link had 1 children
[robot_state_publisher-4] Link forearm_link had 1 children
[robot_state_publisher-4] Link wrist_1_link had 1 children
[robot_state_publisher-4] Link wrist_2_link had 1 children
[robot_state_publisher-4] Link wrist_3_link had 1 children
[robot_state_publisher-4] Link flange had 1 children
[robot_state_publisher-4] Link tool0 had 0 children
[robot_state_publisher-4] [INFO] [1656695328.437867826] [robot_state_publisher]: got segment base
[robot_state_publisher-4] [INFO] [1656695328.437923306] [robot_state_publisher]: got segment base_link
[robot_state_publisher-4] [INFO] [1656695328.437928111] [robot_state_publisher]: got segment base_link_inertia
[robot_state_publisher-4] [INFO] [1656695328.437931316] [robot_state_publisher]: got segment flange
[robot_state_publisher-4] [INFO] [1656695328.437934542] [robot_state_publisher]: got segment forearm_link
[robot_state_publisher-4] [INFO] [1656695328.437937376] [robot_state_publisher]: got segment shoulder_link
[robot_state_publisher-4] [INFO] [1656695328.437940179] [robot_state_publisher]: got segment tool0
[robot_state_publisher-4] [INFO] [1656695328.437942979] [robot_state_publisher]: got segment upper_arm_link
[robot_state_publisher-4] [INFO] [1656695328.437945807] [robot_state_publisher]: got segment wrist_1_link
[robot_state_publisher-4] [INFO] [1656695328.437948606] [robot_state_publisher]: got segment wrist_2_link
[robot_state_publisher-4] [INFO] [1656695328.437951296] [robot_state_publisher]: got segment wrist_3_link
[ros2_control_node-1] [INFO] [1656695328.449509175] [URPositionHardwareInterface]: Starting ...please wait...
[ros2_control_node-1] [INFO] [1656695328.449563648] [URPositionHardwareInterface]: Initializing driver...
[ros2_control_node-1] [WARN] [1656695328.451809081] [UR_Client_Library]: No realtime capabilities found. Consider using a realtime system for better performance
[spawner.py-8] [INFO] [1656695328.562151568] [spawner_force_torque_sensor_broadcaster]: Waiting for /controller_manager services
[spawner.py-11] [INFO] [1656695328.576562140] [spawner_cartesian_force_controller]: Waiting for /controller_manager services
[spawner.py-6] [INFO] [1656695328.579832484] [spawner_io_and_status_controller]: Waiting for /controller_manager services
[ros2_control_node-1] [INFO] [1656695328.853888761] [UR_Client_Library]: Negotiated RTDE protocol version to 2.
[ros2_control_node-1] [INFO] [1656695328.854974748] [UR_Client_Library]: Setting up RTDE communication with frequency 500.000000
[ros2_control_node-1] [INFO] [1656695329.879835111] [URPositionHardwareInterface]: Calibration checksum: 'calib_12788084448423163542'.
[ros2_control_node-1] [WARN] [1656695329.881105544] [UR_Client_Library]: No realtime capabilities found. Consider using a realtime system for better performance
[ros2_control_node-1] [ERROR] [1656695330.898251170] [URPositionHardwareInterface]: The calibration parameters of the connected robot don't match the ones from the given kinematics config file. Please be aware that this can lead to critical inaccuracies of tcp positions. Use the ur_calibration tool to extract the correct calibration from the robot and pass that into the description. See [https://github.com/UniversalRobots/Universal_Robots_ROS_Driver#extract-calibration-information] for details.
[ros2_control_node-1] [WARN] [1656695330.898567913] [UR_Client_Library]: No realtime capabilities found. Consider using a realtime system for better performance
[ros2_control_node-1] [INFO] [1656695330.899750408] [URPositionHardwareInterface]: System successfully started!
[controller_stopper_node-3] [INFO] [1656695330.907994209] [Controller stopper]: Service available
[controller_stopper_node-3] [INFO] [1656695330.908012467] [Controller stopper]: Waiting for list controllers service to come up on controller_manager/list_controllers
[controller_stopper_node-3] [INFO] [1656695330.908020894] [Controller stopper]: Service available
[ros2_control_node-1] [INFO] [1656695330.908290776] [controller_manager]: update rate is 600 Hz
[ros2_control_node-1] [INFO] [1656695331.021498341] [controller_manager]: Loading controller 'force_torque_sensor_broadcaster'
[spawner.py-8] [INFO] [1656695331.026220821] [spawner_force_torque_sensor_broadcaster]: Loaded force_torque_sensor_broadcaster
[ros2_control_node-1] [INFO] [1656695331.026703915] [controller_manager]: Configuring controller 'force_torque_sensor_broadcaster'
[spawner.py-8] [INFO] [1656695331.030279845] [spawner_force_torque_sensor_broadcaster]: Configured and started force_torque_sensor_broadcaster
[ros2_control_node-1] [INFO] [1656695331.034948071] [controller_manager]: Loading controller 'cartesian_force_controller'
[INFO] [spawner.py-8]: process has finished cleanly [pid 75926]
[ERROR] [ros2_control_node-1]: process has died [pid 75912, exit code -11, cmd '/home/d-lab/workspace/ros_ur_driver/install/controller_manager/lib/controller_manager/ros2_control_node --ros-args --params-file /tmp/launch_params_8izro9gy --params-file /home/d-lab/workspace/ros_ur_driver/install/ur_bringup/share/ur_bringup/config/ur_controllers.yaml'].
`

I suspect this is a result of the commit you made to the base class as I was able to load the force controller using the previous commit.

I also tried using your version of the compliance controller. An error happens when I try building the compliance controller on line 83 of cartesian_compliance_controller.cpp:
error: ‘on_init’ is not a member of ‘cartesian_compliance_controller::CartesianComplianceController::MotionBase’ {aka ‘cartesian_motion_controller::CartesianMotionController’} 83 | if (MotionBase::on_init() != TYPE::SUCCESS || ForceBase::on_init() != TYPE::SUCCESS)
I changed the line to be this instead:
if (MotionBase::init(controller_name) != TYPE::SUCCESS || ForceBase::init(controller_name) != TYPE::SUCCESS)

After making that change, I get the same error as the cartesian force controller.

I was wondering if you can give some advice on 1) how to debug the cartesian_force_controller error with the latest commit and 2) whether the cartesian_compliance_controller bug fix is correct? Thanks.

@stefanscherzinger
Copy link
Contributor

@TheFalcoGuy

An error happens when I try building the compliance controller on line 83 of cartesian_compliance_controller.cpp

Thanks, that pointed me to something important. The ros2-devel branch is ROS2 Galactic only at the moment.
I had the CI-pipeline deactivated for Foxy and missed that implementation change with init -> on_init.
Unfortunately, that's not the only change.

I'll try to support Foxy this evening and get back to you soon. (That includes your change for 2), which is correct).

Concerning your point 1): I'll personally like using gdb inside a screen session. Note the line with the prefix:

    control_node = Node(
        package="controller_manager",
        executable="ros2_control_node",
        parameters=[robot_description, robot_controllers],
        #prefix="screen -d -m gdb -command=/home/scherzin/.ros/my_debug_log --ex run --args",
        output={
            "stdout": "screen",
            "stderr": "screen",
        },
    )

After picking up the gdb session with screen -r, I inspect the backtrace inside gdb with bt. (I also like to have some breakpoints ready in /home/scherzin/.ros/my_debug_log that help me stop at the right spots while debugging.) That should give some insights. But let's fix the support for Foxy first before digging deeper.

@stefanscherzinger
Copy link
Contributor

@TheFalcoGuy

I updated the ros2-devel branch with the latest fixes for the Foxy support. You might want to check that out and try again.

@TheFalcoGuy
Copy link

TheFalcoGuy commented Jul 2, 2022

Thanks for being so quick. I tried running the compliance controller with my ur5e. I noticed that I am facing a similar issue in #15 where the cartesian compliance controller is getting information from the incorrect topic. Unlike ROS1, however, parameter remapping from the launch file is slightly trickier as there is no global parameter anymore. I tried remapping by directly changing line 101 in cartesian force controller. After doing that and running the setup as before, I got motion, though I am not entirely sure if this is expected behavior. Below is my yaml file and a video recording of the controller:

My yaml file is as follows:
`cartesian_compliance_controller:
ros__parameters:
end_effector_link: "tool0"
robot_base_link: "base_link"
ft_sensor_ref_link: "tool0"
joints:
- shoulder_pan_joint
- shoulder_lift_joint
- elbow_joint
- wrist_1_joint
- wrist_2_joint
- wrist_3_joint

pd_gains:
    trans_x: {p: 0.05}
    trans_y: {p: 0.05}
    trans_z: {p: 0.05}
    rot_x: {p: 0.01}
    rot_y: {p: 0.01}
    rot_z: {p: 0.01}

stiffness:  # w.r.t. compliance_ref_link
    trans_x: 50.0
    trans_y: 50.0
    trans_z: 50.0
    rot_x: 10.0
    rot_y: 10.0
    rot_z: 10.0

command_interfaces:
  - position
state_interfaces:
  - position
  - velocity
state_publish_rate: 100.0
action_monitor_rate: 20.0
allow_partial_joints_goal: false


constraints:
  stopped_velocity_tolerance: 0.0
  goal_time: 0.0`

IMG-3198.zip

My goal is to use the compliance controller as an admittance controller. How would I go about tuning this to get that behavior? Thanks

@stefanscherzinger
Copy link
Contributor

stefanscherzinger commented Jul 3, 2022

@TheFalcoGuy

Unlike ROS1, however, parameter remapping from the launch file is slightly trickier as there is no global parameter anymore.

At runtime, ROS2 controllers are part of the controller_manager. So, remapping seems to work for that node. For instance:

    control_node = Node(
        package="controller_manager",
        executable="ros2_control_node",
        parameters=[robot_description, robot_controllers],
        #prefix="screen -d -m gdb -command=/home/scherzin/.ros/my_debug_log --ex run --args",
        output={
            "stdout": "screen",
            "stderr": "screen",
        },
        remappings=[
            ('m_ft_sensor_wrench', 'the_measured_ur_sensor_wrench'),
            ]
    )

remaps the cartesian_compliance_controller's m_ft_sensor_wrench to the_measured_ur_sensor_wrench (I'm not sure right now how that's called on the real system).

I got motion, though I am not entirely sure if this is expected behavior

Thanks for sharing the video! That's not expected behavior. For some axes, the robot moves towards the directions where forces are applied. I assume that this is because the compliance_ref_link parameter is missing in the controller's specification. Try add this to your controller:

cartesian_compliance_controller:
  ros__parameters:
    end_effector_link: "tool0"
    robot_base_link: "base_link"
    ft_sensor_ref_link: "tool0"
    compliance_ref_link: "tool0"  # This one is important
    ...

You might also remove the following parameters form the cartesian_compliance_controller:

state_interfaces:
  - position
  - velocity
state_publish_rate: 100.0
action_monitor_rate: 20.0
allow_partial_joints_goal: false

constraints:
  stopped_velocity_tolerance: 0.0
  goal_time: 0.0`

Those parameters won't be used. I don't know where you got them from.

I also noticed that your controller is very responsive. That won't be stable in contact with stiff surfaces. Keep in mind that you might need to tweak the controller's p gains a little (for instance increase the rotational gains quite a bit in comparison to the translational ones). The error_scale parameter is still used in ROS2, e.g. with

cartesian_compliance_controller:
  ros__parameters:
  ...

  solver:
    error_scale: 0.1

My goal is to use the compliance controller as an admittance controller. How would I go about tuning this to get that behavior?

Could you be more specific what you mean by that?

@TheFalcoGuy
Copy link

TheFalcoGuy commented Jul 8, 2022

Hi @stefanscherzinger, sorry for the late reply. I took your advice and have started tuning my controller.

After adding the compliace reference link, the issue you pointed out still remains. When I inverted the proportional gains, however, the robot behaves as expected. The error scaling you mentioned helped adjusting the controller's sensitivity. During the tuning process, I noticed that applying a large amount of force on the arm results in the arm drifiting in the direction of where the force was applied. I tried adding a k_i term as I thought this was a result of some steady state error, but it didn't seem to help the situation. I was wondering if you had any experience with dealing with this issue? Thanks again for the advice!

@stefanscherzinger
Copy link
Contributor

@TheFalcoGuy

When I inverted the proportional gains, however, the robot behaves as expected

You mean like trans_x = -0.05? I believe that's not the right way. Let's check again if the kinematic setup is correct.
Could you try base instead of base_link in your controller's config?

cartesian_compliance_controller:
  ros__parameters:
    end_effector_link: "tool0"
    robot_base_link: "base"  # The force sensor reference frame for the UR driver in Foxy
    ft_sensor_ref_link: "tool0"
    compliance_ref_link: "tool0"
    ...

I remember that the UR driver used base for its force torque sensor signals.

I tried adding a k_i term as I thought this was a result of some steady state error

That's not required. The control law has an integrator already when integrating the simulated accelerations to velocities and positions.

I noticed that applying a large amount of force on the arm results in the arm drifiting in the direction of where the force was applied.

After fixing the kinematics config from above, is that still the case?

@lcbw
Copy link

lcbw commented Jul 12, 2022

ubuntu 20.04 | fzi cart_force_controller on branch foxy | universal robots ros2 driver on branch foxy |
trying to implement the cartesian_force_controller:
I am also encountering this issue and changing my robot_base_link to base instead of base_link did work - thank you!

For continued development and work in foxy, (using the force and compliance controllers) which branch(es) do you suggest?
Initially, you suggested ros2 but there's extra commits on cleanup-ros2 and ros2-devel that are pertinent to foxy work with the force and compliance controllers.
Thanks!

@stefanscherzinger
Copy link
Contributor

Hi @lcbw

Sorry, I didn't check your post after your edit and missed your question. I suggest using the ros2-devel branch for now. That has most features and also fixed some deficiencies when switching controllers. After merging some cleanup, everything goes into the ros2 branch.

@shrutichakraborty
Copy link

shrutichakraborty commented Jan 31, 2024

cartesian_force_controller_spawner_stopped = Node(
package="controller_manager",
executable="spawner",
arguments=["cartesian_force_controller", "-c", "/controller_manager", "--stopped"],
)

Hello, I'm following this response to setup the cartesian force controller on a UR10e on ros2 and am a bit confused with the terminology. What is the significance of the "stopped" in cartesian_force_controller_spawner_stopped = Node( package="controller_manager", executable="spawner", arguments=["cartesian_force_controller", "-c", "/controller_manager", "--stopped"], ) ?

Aditionally, I followed the steps mentioned in the comment, but I am also wondering whether the cartesian_force_controller_spawner_stopped is to be included in nodes_to_start list? How is this linking with the with the cartesian_force_controller in the cartesian_controllers package? Or am I missing some steps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ROS2 solution proposed A solution has been proposed inside the issue
Projects
None yet
Development

No branches or pull requests

5 participants