ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

How to implement a JointPositionController

asked 2022-03-24 08:25:54 -0500

joff gravatar image

Hi,

I want to implement a JointPositionController so I can conveniently tune PID-values with rqt_gui (Tell me if there is a better method). I have a working JointTrajectoryController which I tried changing to be a position controller. I want to change it because I don't know what values to publish to just move the joints, while with the JointPositionController I can simply publish a float and the robot should move to the position.

My ros_controllers.yaml looks like this:

irb4600_40_255_arm_controller:
  type: effort_controllers/JointPositionController
  joints:
    - joint_1
    - joint_2
    - joint_3
    - joint_4
    - joint_5
    - joint_6
  gains:    # manually tuned
     joint_1: { p: 2000.0, d: 500.0, i: 50.0, i_clamp: 10000 }
     joint_2: { p: 100000.0, d: 100000.0, i: 2000, i_clamp: 10000 }
     joint_3: { p: 10000.0, d: 800.0, i: 500.0, i_clamp: 1000 }
     joint_4: { p: 18000, d: 200, i: 0.01, i_clamp: 10000 }
     joint_5: { p: 100, d: 0, i: 0, i_clamp: 0}
     joint_6: { p: 8, d: 0, i: 0, i_clamp: 0}

I exchanged the effort_controllers/JointTrajectoryController of my working controller with effort_controllers/JointPositionController.

In my ros_controllers.launch file I have:

<?xml version="1.0"?>
<launch>

  <!-- Load joint controller configurations from YAML file to parameter server -->
  <rosparam file="$(find irb4600_40_255_moveit_config)/config/ros_controllers.yaml" command="load"/>

  <!-- Load the controllers -->
  <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
    output="screen" args="irb4600_40_255_arm_controller "/>    
</launch>

This launch file get's called in my launch file starting gazebo like this:

<!-- Load joint controller parameters for Gazebo -->
  <rosparam file="$(find irb4600_40_255_moveit_config)/config/gazebo_controllers.yaml" />
  <!-- Spawn Gazebo ROS controllers -->
  <node name="gazebo_controller_spawner" pkg="controller_manager" type="spawner" respawn="false" output="screen" args="joint_state_controller" />
  <!-- Load ROS controllers -->
  <include file="$(dirname)/ros_controllers.launch"/>

Now when I try roslaunch irb4600_40_255_moveit_config sim.launch, which launches my gazebo launch file as well, i get:

[ERROR] [1648127146.564436320, 0.012000000]: No joint given (namespace: /irb4600_40_255_arm_controller)
[ERROR] [1648127146.564570962, 0.013000000]: Failed to initialize the controller
[ERROR] [1648127146.564650287, 0.013000000]: Initializing controller 'irb4600_40_255_arm_controller' failed

This does not happen for EXACT SAME code, with the controller type switched from JointPositionController to JointTrajectoryController.

I aswell tried implementing it after the example of the rrbot.

The ros_controllers.launch

<?xml version="1.0"?>
<launch>

  <!-- Load joint controller configurations from YAML file to parameter server -->
  <rosparam file="$(find irb4600_40_255_moveit_config)/config/ros_controllers.yaml" command="load"/>

  <!-- Load the controllers -->    
  <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
    output="screen" ns="/abb_irb4600_40_255" 
    args="joint_states_controller
          joint1_position_controller 
          joint2_position_controller
          joint3_position_controller
          joint4_position_controller
          joint5_position_controller
          joint6_position_controller "/>

</launch>

The ros_controllers.yaml:

irb4600_40_255_arm_controller:

  # Publish all joint states -----------------------------------
  joint_states_controller:
      type: joint_state_controller/JointStateController
      publish_rate: 25

  # Position Controllers ---------------------------------------
  joint1_position_controller:
      type: effort_controllers/JointPositionController
      joint: joint_1
      pid: {p: 100.0, i: 0.01, d: 10.0}

  joint2_position_controller:
      type: effort_controllers/JointPositionController
      joint: joint_2
      pid: {p: 100.0, i: 0.01, d: 10.0} 

  joint3_position_controller:
      type: effort_controllers/JointPositionController
      joint: joint_3
      pid: {p: 100.0, i: 0.01, d: 10.0} 

  joint4_position_controller:
      type: effort_controllers/JointPositionController
      joint: joint_4
      pid: {p: 100.0, i: 0.01 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-03-29 10:43:54 -0500

joff gravatar image

updated 2022-03-29 10:45:27 -0500

Hey,

with the help of a friend I was able to figure out the problems.

I ended up creating an extra file for the controller: joint_state_controller.yaml

  # Publish all joint states -----------------------------------
  joint_state_controller:
      type: joint_state_controller/JointStateController
      publish_rate: 25

  # Position Controllers ---------------------------------------
  joint1_position_controller:
      type: effort_controllers/JointPositionController
      joint: joint_1
      pid: { p: 8000.0, d: 1000.0, i: 100.0, i_clamp: 0 } 

  joint2_position_controller:
      type: effort_controllers/JointPositionController
      joint: joint_2
      pid: { p: 100000.0, d: 100000.0, i: 2000, i_clamp: 0 }

  joint3_position_controller:
      type: effort_controllers/JointPositionController
      joint: joint_3
      pid: { p: 10000.0, d: 800.0, i: 500.0, i_clamp: 0 }

  joint4_position_controller:
      type: effort_controllers/JointPositionController
      joint: joint_4
      pid: { p: 18000, d: 200, i: 0.01, i_clamp: 0 }

  joint5_position_controller:
      type: effort_controllers/JointPositionController
      joint: joint_5
      pid: { p: 100, d: 0, i: 0, i_clamp: 0}

  joint6_position_controller:
      type: effort_controllers/JointPositionController
      joint: joint_6
      pid: { p: 8, d: 0, i: 0, i_clamp: 0}

I think the main difference here is that I don't have irb4600_40_255_arm_controller as a namespace in the first line of the file.

Now I call this file in my ros_controllers.launch as this:

  <rosparam file="$(find irb4600_40_255_moveit_config)/config/joint_state_controller.yaml" command="load"/>
  <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
    output="screen"
    args="joint_state_controller
          joint1_position_controller 
          joint2_position_controller
          joint3_position_controller
          joint4_position_controller
          joint5_position_controller
          joint6_position_controller "/>

I think it was somehow a problem with the namespace, so I ended up using none.

Some further tips which helped me:

  • Look in rostopics list if you controllers are publishing, to make sure they get loaded

  • Don't set you PID values too low in the new controller, as I had simply p = 100 which was not ennough to move the robot even a little bit.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2022-03-24 08:25:54 -0500

Seen: 965 times

Last updated: Mar 29 '22