MaisJamal / carla_apollo_bridge

This project provides a bridge for communication between the autonomous driving platform Apollo and Carla simulator. Receiving data from Carla, Apollo controls the autonomous vehicle.
Apache License 2.0
50 stars 11 forks source link

About some control problems: poor steering performance #9

Closed PhilWallace closed 11 months ago

PhilWallace commented 1 year ago

Hello there. I'm still struggling to fix the control problem of the vehicle.. (https://github.com/MaisJamal/carla_apollo_bridge/issues/6)

I have tuned the _controlconf.pb.txt (also the calibration table and some other parameters), and tried two different control algorithms (LQR+PID and MPC), but the vehicle still struggles to make turns (although it looks good when going straight).

You said that you have modified the car physics in Carla, I assume it is the following code in _runbridge.py:

Screenshot from 2023-08-12 02-37-44

However, these codes do not seem to address the steering problem.

I'm writing to ask because I saw your uploaded video shows that the car can make turn perfectly: https://www.youtube.com/watch?v=kS7OC7q0v3c. Particularly, I noticed that in last few seconds, the car is steering perfectly according to the planning output. I am curious whether this is the actual result of the control problem, or the apply_control is false and the car is perfectly following the planning trajectory without executing the control command.

Do you have any more insight on fixing the steer problem? Many thanks!

MaisJamal commented 1 year ago

Hello, I meant a different thing by "modifying the car physics". The code you have showed is related to transferring the data in the bridge among Carla and Apollo. Changing the car physics can mainly be done in scenario launching file "manual_control_13.py" or any similar file, by the following code:

https://github.com/MaisJamal/carla_apollo_bridge/blob/f6d803aae82c296a5bb9de6ef0a7f66908f16aba/examples/manual_control_13.py#L667C5-L682C17

by changing damping rate and other parameters in physics_control of the actor, you fix the issue with brakes, and this will fix the turn of the car. The problem with steering cannot be solved without adjusting the control of longitudinal movement.

PhilWallace commented 11 months ago

Hello, I meant a different thing by "modifying the car physics". The code you have showed is related to transferring the data in the bridge among Carla and Apollo. Changing the car physics can mainly be done in scenario launching file "manual_control_13.py" or any similar file, by the following code:

https://github.com/MaisJamal/carla_apollo_bridge/blob/f6d803aae82c296a5bb9de6ef0a7f66908f16aba/examples/manual_control_13.py#L667C5-L682C17

by changing damping rate and other parameters in physics_control of the actor, you fix the issue with brakes, and this will fix the turn of the car. The problem with steering cannot be solved without adjusting the control of longitudinal movement.

Many thanks for the reply. I have added similar code to the bridge and the control module now works more promptly.

FYI, I have discovered several control-related bugs that would affect the control performance. These bugs exist in the control configuration, controller code, and other modules. I've initiated some issues to report these bugs (maybe they can be helpful for you):

https://github.com/ApolloAuto/apollo/issues/15144 https://github.com/guardstrikelab/carla_apollo_bridge/issues/159

However, even after I have tried to fix these bugs, the control module is indeed better but still far from being perfect. What a challenge!

howicc commented 11 months ago

Why is the steer target being inverted in this code? (-1 * data.steering_target /100)

MaisJamal commented 11 months ago

Due to the difference in car relative coordination systems between Apollo and Carla.

Screenshot from 2023-10-11 12-33-47

o Z means it is going out of the plane, while + Z means it's going inside the plane, if you are familiar with the Right-hand rule. Yaw or the steering would be the rotation around Z.

howicc commented 11 months ago

Thank you so much. I'm having trouble with the steering performance using this bridge. But observing the steering commands, the problem might be coming from Apollo Control itself. The steering target has very steep changes at each new Control command. I wonder if the difference between the Control Rate (100Hz) and the Carla Rate providing the Sensor updates (GPS and IMU) at a much lower rate is causing the issue by affecting the Localization update that is used by the Controller. Do you have a stable steering? If yes, What is the Localization Rate?

PhilWallace commented 11 months ago

Thank you so much. I'm having trouble with the steering performance using this bridge. But observing the steering commands, the problem might be coming from Apollo Control itself. The steering target has very steep changes at each new Control command. I wonder if the difference between the Control Rate (100Hz) and the Carla Rate providing the Sensor updates (GPS and IMU) at a much lower rate is causing the issue by affecting the Localization update that is used by the Controller. Do you have a stable steering? If yes, What is the Localization Rate?

Tuning the control module is challenging, and I have been doing this and reported some bugs (if you are interested: https://github.com/guardstrikelab/carla_apollo_bridge/issues/159). Bad control can be due to many factors, including problems from planning module.

Your guess is correct. The control rate is 100Hz but the car state update rate is 20Hz, in which case the control module will keep calculating control command based on low-rate car state. But this is just one very small factor leading to the bad control performance......

howicc commented 11 months ago

@PhilWallace Thank you. Can you share the fixes in the Control code that you mentioned in that thread and also the configuration file? Any other changes you tried in the configuration settings apart from the calibration table from longitudinal movement?

PhilWallace commented 11 months ago

@PhilWallace Thank you. Can you share the fixes in the Control code that you mentioned in that thread and also the configuration file? Any other changes you tried in the configuration settings apart from the calibration table from longitudinal movement?

I modified the car physics as referenced by https://github.com/MaisJamal/carla_apollo_bridge/issues/9#issuecomment-1697120713.

I did some modifications on the control code, but the performance is still not satisfying. Current I think the configuration is the biggest problem. I am still working on it and will share it later when I tune it better. : )

howicc commented 11 months ago

Have you tried using Carla's Controller instead of Apollo's? (using the bridge to provide Trajectory data, and keeping Apollo Controller shutdown)

PhilWallace commented 11 months ago

Have you tried using Carla's Controller instead of Apollo's? (using the bridge to provide Trajectory data, and keeping Apollo Controller shutdown)

I haven't try this yet. Carla itself indeed offered some basic control algorithm (using PID to follow the next trajectory point, if I remember it correctly). You can have a try.

MaisJamal commented 10 months ago

End-to-end video tutorial, how to install, configure and use this Carla-Apollo-Bridge, with Carla simulator (v0.9.13) and Apollo driving software (v8.0.0): https://youtu.be/2dQC3ToJGJU?si=6mZMHP1RRZHPRggX