mismatch effort_controllers/commands and /joint_states when using gazebo

asked 2023-02-20 13:10:38 -0500

nino gravatar image

updated 2023-02-20 13:13:36 -0500

I'm using ROS2 Foxy Gazebo 11

In my project, i use effort controller to control my robot. when i run my test, effort_controllers/commands and /joint_states are not the same value i send torque to joint 2 through effort_controllers/commands but in /joint_states joint 4 rcv i try to change my urdf file but nothing change. my /effort_controller/commands

name:
- joint_1
- joint_2
- joint_4
- joint_5
- joint_3
- joint_6
- joint_7
position:
- -1.178107414362552
- 1.4812393690180716
- 3.13999404107763
- 0.8967537553126199
- 3.140815354598864
- -0.1518385107602871
- -1.7504313387899852
velocity:
- 0.007313363959996982
- 0.030346796390004288
- -0.022291851686100962
- -0.01782478252102926
- 0.0031208610492774944
- -0.03211991856186212
- -0.1562150827750543
effort:
- 0.0
- 0.0
- 0.0
- 100.0
- 300.0
- 0.0
- 0.0

my /joint_states:

layout:
  dim: []
  data_offset: 0
data:
- 0.0
- 0.0
- 300.0
- 0.0
- 100.0
- 0.0
- 0.0
edit retag flag offensive close merge delete

Comments

I suspect your ros2_control configuration may be inconsistent if things are out of order. Hard to say without seeing the URDF and YAML. my guess is that the order of joints specified to the joint_state_broadcaster and effort_controller are different. As a sanity check, you could monitor the effort being applied to your joints in the Gazebo Client GUI (example use of the plotting utility here) to confirm whether different joints are getting the expected commands or not. If that doesn't help, i'd suggest editing your question to include a copy of the <ros2_control> block of your URDF and the .yaml controller config file you are using.

shonigmann gravatar image shonigmann  ( 2023-02-23 17:26:32 -0500 )edit

here is my yaml

 controller_manager:
  ros__parameters:
    update_rate: 1000
    joint_state_broadcaster:
      type: joint_state_broadcaster/JointStateBroadcaster

    effort_controllers:
      type: effort_controllers/JointGroupEffortController

effort_controllers:
  ros__parameters:
    joints:
      - joint_1
      - joint_2
      - joint_3
      - joint_4
      - joint_5
      - joint_6
      - joint_7

    command_interfaces:
      - effort
    state_interfaces:
      - position
      - velocity
      - effort

    state_publish_rate: 1000.0
    action_monitor_rate: 1000.0
nino gravatar image nino  ( 2023-02-26 08:17:47 -0500 )edit

and here is my block <ros2_control>

    <ros2_control name="GazeboSystem" type="system">
    <hardware>
      <plugin>gazebo_ros2_control/GazeboSystem</plugin>
    </hardware>

    <joint name="joint_1">
      <command_interface name="effort">
        <param name="min">-2500</param>
        <param name="max">2500</param>
      </command_interface>
      <state_interface name="position"/>
      <state_interface name="velocity"/>
      <state_interface name="effort"/> 
    </joint>

....

    <joint name="joint_7">
      <command_interface name="effort">
        <param name="min">-2500</param>
        <param name="max">2500</param>
      </command_interface>
      <state_interface name="position"/>
      <state_interface name="velocity"/>
      <state_interface name="effort"/> 
    </joint>
</ros2_control>
nino gravatar image nino  ( 2023-02-26 08:20:36 -0500 )edit