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

ackermann_steering_controller with gazebo classic #660

Closed
space192 opened this issue Jun 12, 2023 · 17 comments · Fixed by #1125
Closed

ackermann_steering_controller with gazebo classic #660

space192 opened this issue Jun 12, 2023 · 17 comments · Fixed by #1125
Labels

Comments

@space192
Copy link

space192 commented Jun 12, 2023

Hi !
I was wondering if there is a command interfaces built in gazebo for ackermann_steering_controller, or do I need to code it myself ? Because right now with the following code

    <ros2_control name="GazeboSystem" type="system">
        <hardware>
            <plugin>gazebo_ros2_control/GazeboSystem</plugin>
        </hardware>
        <joint name="fleft_steering_hinge_joint">
            <command_interface name="position" />
            <state_interface name="position"/>
        </joint>
        <joint name="fright_steering_hinge_joint">
            <command_interface name="position" />
            <state_interface name="position"/>
        </joint>
        <joint name="rleft_wheel_joint">
            <command_interface name="velocity"/>
            <state_interface name="position"/>
            <state_interface name="velocity"/>
        </joint>
        <joint name="rright_wheel_joint">
            <command_interface name="velocity"/>
            <state_interface name="position"/>
            <state_interface name="velocity"/>
        </joint>
    </ros2_control>
    <gazebo>
        <plugin name="gazebo_ros2_control" filename="libgazebo_ros2_control.so">
            <parameters>$(find arece_compet_python)/config/controllers.yaml</parameters>
        </plugin>
    </gazebo>

and here is my controllers.yaml file:

controller_manager:
  ros__parameters:
    update_rate: 100
    use_sim_time: true
    joint_broad:
      type: joint_state_broadcaster/JointStateBroadcaster
    ack_man:
      type: ackermann_steering_controller/AckermannSteeringController
ack_man:
  ros__parameters:
    rear_wheels_names: ["rleft_wheel_joint", "rright_wheel_joint"]
    front_wheels_names: ["fleft_steering_hinge_joint", "fright_steering_hinge_joint"]
    front_steering: true
    open_loop: false
    velocity_rolling_window_size: 10
    position_feedback: true
    use_stamped_vel: true
    wheel_separation: 1.23
    wheel_radius: 0.2525
    wheel_base: 0.2
    pivot_distance: 0.803
    max_steering_speed: 1.5707963267948966
    max_steering_angle: 0.42
    odom_frame_id: odom
    base_frame_id: base_link
    enable_odom_tf: true
    wheelbase: 1.530
    front_wheel_track: 1.23
    rear_wheel_track: 1.23
    front_wheel_radius: 0.2525
    rear_wheel_radius: 0.2525

I get:
image

@space192 space192 added the bug label Jun 12, 2023
@bmagyar bmagyar added question and removed bug labels Jun 12, 2023
@bmagyar
Copy link
Member

bmagyar commented Jun 12, 2023

... and what are you expecting to get? it seems to me that you've got an ackermann vehicle and you've correctly configured and activated an ackermann controller.

The unavailable/unclaimed interfaces are probably not needed.

@space192
Copy link
Author

the thing is when I'm trying to send a TwistStamped message on the topic my wheels just reset to 0.0 0.0 0.0 of the gazebo world 🤔 so I thought that the two hardware that were unavailable was the problem

@space192
Copy link
Author

So I just checked and when I send TwistStamped command with teleop_twist_keyboard or rqt_robot_steering, I get on the /ack_man/controller_state .inf in linear_velocity_command and -pi/2 or pi/2 wathever the command I send 🤔 do you have any idea what could be the problem ?

@space192
Copy link
Author

Hey @bmagyar sorry to bother you again, I shot a quick video (20 sec) to show the problem on my gazebo, I don't really know what's going on and verbose mode doesn't give anything :/ https://youtu.be/5mGF9LVwPs0

@christophfroehlich
Copy link
Contributor

@space192 could you probably provide a full working example of your setup? That would be easier then to reproduce your issue.

@Franklein20
Copy link

Hello
Any update on this topic?
i got the same behaviour

@christophfroehlich
Copy link
Contributor

Hello Any update on this topic? i got the same behaviour

Hi! same again, could you provide a full example of your setup?

@Franklein20
Copy link

Franklein20 commented Dec 3, 2023

controller_manager:
  ros__parameters:
    update_rate: 1000
    use_sim_time: true

    joint_state_broadcaster:
      type: joint_state_broadcaster/JointStateBroadcaster
   

    ackermann_drive:
      type: ackermann_steering_controller/AckermannSteeringController


ackermann_drive:
  ros__parameters:

    publish_rate: 500.0  

    
    front_wheels_names: [left_wheel_steering_joint, right_wheel_steering_joint,right_back_wheel_steering_joint,left_back_wheel_steering_joint]
    rear_wheels_names: [left_wheel_joint,right_wheel_joint,wheel_back_right_joint, wheel_back_left_joint]
    #left_wheel_names: ["left_wheel_joint"]
    #right_wheel_names: ["right_wheel_joint"]
    #left_steering_name: ["left_wheel_steering_joint"]
    #right_steering_name: ["right_wheel_steering_joint"]
    front_steering: true
    velocity_rolling_window_size: 10
    position_feedback: true
    in_chained_mode: false


    wheel_separation: 0.297
    wheel_radius: 0.05

    use_stamped_vel: true

    wheel_base: 0.335    
    pivot_distance: 0.2  #0.803 

    max_steering_speed: 1.5707963267948966
    
    max_steering_angle: 0.7853981633974483

    wheel_separation_multiplier: 1.0
    left_wheel_radius_multiplier: 1.0
    right_wheel_radius_multiplier: 1.0

    publish_rate: 500.0
    odom_frame_id: odom
    base_frame_id: base_link
    pose_covariance_diagonal : [0.001, 0.001, 0.0, 0.0, 0.0, 0.01]
    twist_covariance_diagonal: [0.001, 0.0, 0.0, 0.0, 0.0, 0.01]

    open_loop: false
    enable_odom_tf: true

    cmd_vel_timeout: 0.5

    front_wheel_track: 0.297
    rear_wheel_track: 0.297
    front_wheel_radius: 0.5
    rear_wheel_radius: 0.5



joint_state_broadcaster:
  ros__parameters:
    update_rate: 1000  # Hz
    use_sim_time: true
    

here my config fil

@Franklein20
Copy link

and here my ros2_control config

<ros2_control name="GazeboSystem" type="system">
    <hardware>
        <plugin>gazebo_ros2_control/GazeboSystem</plugin>
    </hardware>
    <joint name="left_wheel_joint">
        <command_interface name="velocity">
            <param name="min">-10</param>
            <param name="max">10</param>
        </command_interface>
       
        <state_interface name="position" />
        <state_interface name="velocity" />
    </joint>

    <joint name="right_wheel_joint">
        <command_interface name="velocity">
            <param name="min">-10</param>
            <param name="max">10</param>
        </command_interface>
        
        <state_interface name="velocity" />
        <state_interface name="position" />
    </joint>

    <joint name="wheel_back_right_joint">
        <command_interface name="velocity">
            <param name="min">-10</param>
            <param name="max">10</param>
        </command_interface>
        
        <state_interface name="velocity" />
        <state_interface name="position" />
    </joint>

    <joint name="wheel_back_left_joint">
        <command_interface name="velocity">
            <param name="min">-10</param>
            <param name="max">10</param>
        </command_interface>
        
        <state_interface name="velocity" />
        <state_interface name="position" />
    </joint>

    <joint name="left_wheel_steering_joint">
        <command_interface name="position"/>
        <state_interface name="position" />
        <state_interface name="velocity" />
    </joint>

    <joint name="right_wheel_steering_joint">
        <command_interface name="position"/>
        <state_interface name="position" />
        <state_interface name="velocity" />
    </joint>

    <joint name="right_back_wheel_steering_joint">
        <command_interface name="position"/>
        <state_interface name="position" />
        <state_interface name="velocity" />
    </joint>

    <joint name="left_back_wheel_steering_joint">
        <command_interface name="position"/>
        <state_interface name="position" />
        <state_interface name="velocity" />
    </joint>


</ros2_control>


<gazebo>
    <plugin name="gazebo_ros2_control" filename="libgazebo_ros2_control.so">
        <robot_param>robot_description</robot_param>
        <robot_param_node>robot_state_publisher</robot_param_node>
        <ros><remapping>/ackermann_drive/odometry:=odom</remapping> 
        <remapping>/ackermann_drive/tf_odometry:=tf</remapping> </ros>
        <parameters>$(find my_bot)/config/my_controllers.yaml</parameters>
    </plugin>
</gazebo>




<gazebo reference="base_link">
   <material>Gazebo/Blue</material>
</gazebo>



<gazebo reference="right_wheel">
    <material>Gazebo/White</material>
</gazebo>


<gazebo reference="left_wheel">
    <material>Gazebo/White</material>
</gazebo>

 <gazebo reference="wheel_back_right">
    <material>Gazebo/White</material>
</gazebo>

<gazebo reference="wheel_back_left">
    <material>Gazebo/White</material>
</gazebo>

@christophfroehlich
Copy link
Contributor

Without the full URDF, gazebo classic won't launch. It would be of greater help if you create a package for us to download, and describe the exact commands to reproduce your behavior. For example, you could make a public repository or upload a zip into this issue.

@Franklein20
Copy link

my_bot.zip
This zip content my package
To launch the simulation ,
ros2 launch my_bot launch_sim.launch.py

@PierRob101
Copy link

Hi anything new on this topic i'm facing the same issue
Thx in advance :)

@christophfroehlich
Copy link
Contributor

christophfroehlich commented May 18, 2024

my_bot.zip This zip content my package To launch the simulation , ros2 launch my_bot launch_sim.launch.py

@Franklein20 Sorry for the late reply. You misspelled several parameters (wheel_base instead of wheelbase etc). I added a check recently, now the controller does not start if there isn't a nonzero parameter set. Please check the docs or the yaml file defining the parameters.

Furthermore, the ackermann_steering_controller assumes that the two wheels in front are steerable, and the two in the back are traction wheels. It seems that your robot has a steering joint an all wheels. The following configuration

    front_wheels_names: [left_wheel_steering_joint, right_wheel_steering_joint]
    rear_wheels_names: [wheel_back_left_joint, wheel_back_right_joint, ]

kind of works, but fails in simulation because the back wheels are not actuated.

@space192 I see also some misspelled parameters. Have you managed to fix your configuration in the meantime?
@PierRob101 does this information help you as well?

@PierRob101
Copy link

PierRob101 commented May 21, 2024

@christophfroehlich Thank you for your Reply :) I checked my config and URDF files for the things you mentioned, but it seems my problem is caused by something else if you want to help me fuhrer investigating you can have a look at my Setup here:
rover_description.zip

my best guess so far is that i have to adjust my damping and friction joint parameters or the link masses but after Hours of trying different combinations i'm a bit lost :/

@christophfroehlich
Copy link
Contributor

@christophfroehlich Thank you for your Reply :) I checked my config and URDF files for the things you mentioned, but it seems my problem is caused by something else if you want to help me fuhrer investigating you can have a look at my Setup here: rover_description.zip

my best guess so far is that i have to adjust my damping and friction joint parameters or the link masses but after Hours of trying different combinations i'm a bit lost :/

back_wheel_track -> rear_wheel_track
front_wheel_radius -> front_wheels_radius
back_wheel_radius -> back_wheels_radius

now the controller at least loads successfully. But the model is not functional in gazebo yet. Try setting proper collision bodies (you have spheres now instead of cylinders for the wheels), revise inertia and masses, and tune friction parameters if necessary.

@christophfroehlich
Copy link
Contributor

I'll close this here because it seems that every issue was caused by wrong parameters (the check got released to all distros).

If you still encounter issues, please see my comment above about tuning gazebo physics. If you have problems with that, post a question into RSE or the gz repositories.
There are some bugs with the steering library still, follow #1118 and #1150.

@PierRob101
Copy link

Thank you :) i'm feeling dumb for not recognizing the s's in my config i managed to get everything working now 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants