ros-controls / ros2_controllers

Generic robotic controllers to accompany ros2_control
https://control.ros.org
Apache License 2.0
357 stars 320 forks source link

ackermann_steering_controller with gazebo classic #660

Closed space192 closed 4 months ago

space192 commented 1 year ago

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

bmagyar commented 1 year ago

... 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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

Franklein20 commented 10 months ago

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

christophfroehlich commented 10 months ago

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

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

Franklein20 commented 10 months ago
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 commented 10 months ago

and here my ros2_control config

<?xml version="1.0"?>

gazebo_ros2_control/GazeboSystem -10 10 -10 10 -10 10 -10 10 robot_description robot_state_publisher /ackermann_drive/odometry:=odom /ackermann_drive/tf_odometry:=tf $(find my_bot)/config/my_controllers.yaml Gazebo/Blue Gazebo/White Gazebo/White Gazebo/White Gazebo/White
christophfroehlich commented 10 months ago

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 commented 10 months ago

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

PierRob101 commented 4 months ago

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

christophfroehlich commented 4 months ago

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 commented 4 months ago

@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 commented 4 months ago

@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 commented 4 months ago

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 commented 4 months ago

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