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

feat(simple_planning_simulator): add mechanical actuaion sim model #9252

Closed

Conversation

kosuke55
Copy link
Contributor

@kosuke55 kosuke55 commented Nov 7, 2024

Description

Add new simulator model.

The vehicle side software assumes that it has limiters, PID controllers, power steering, etc. for the input.
The conversion in the power steering is approximated by a polynomial.
Steering Dynamics is a model that represents the motion of the tire angle when the Steering Torque is input. It is represented by the following formula.

image

system identification result is following. I tested real driving data and compare obeserved and simulated steering angle error (focusing on low steer angle)
Results are mecanical > second order > first order in that order for train and test data.

  • mechanical model
python3 steering_system_rosbag.py  --csv_file odaiba.csv  -m simulate  -p low_angle_0.01.json
Total Error: 18.8549
Simulation completed in 0.4162 seconds.


{
    "parameters": {
        "kp": 385.32623432169896,
        "ki": 5.470220188865222,
        "kd": 0,
        "ff_gain": 0.030497566164202503,
        "angle_limit": 10.0,
        "rate_limit": 3.0,
        "dead_zone_threshold": 0.007076432767148246,
        "a": 0.17791229486165056,
        "b": -0.17173397419765798,
        "c": 1.5599789889825484,
        "d": 0.0025322564364858176,
        "e": -0.04499096271188731,
        "f": 0.20114575254773887,
        "g": -0.07439510952992096,
        "h": 0.19998353912585695,
        "inertia": 25.17888049060484,
        "damping": 116.69225778407515,
        "stiffness": 0.1758244980428317,
        "friction": 0.6563489952292717,
        "delay_time": 0.0
    },
    "cost": 191.41139399730702
}

image

image

image

  • First order model (same to current model)
python3 steering_system_rosbag.py  --csv_file odaiba.csv -m simulate -t simple -p ./annealing_simple_20241021_091713/params/simple_low_angle_0.01_223.7725.json
Total Error: 22.3770
Simulation completed in 0.0679 seconds.

{
    "parameters": {
        "steer_time_delay": 0.18919629045102362,
        "steer_time_constant": 0.19977909286592008,
        "steer_dead_band": 0.0003349704841227525
    },
    "cost": 223.7725409755146
}

image

if tuning for deadzone

image

  • second order model (not in simple planning simulator and this PR, but I tested)
$ python3 steering_system_rosbag.py  --csv_file odaiba.csv  -m simulate -t simple_second_order -p second_order_low_angle_0.01_211.7917.json
/home/kosuke55/.local/lib/python3.10/site-packages/matplotlib/projections/__init__.py:63: UserWarning: Unable to import Axes3D. This may be due to multiple versions of Matplotlib being installed (e.g. as a system package and as a pip package). As a result, the 3D projection is not available.
  warnings.warn("Unable to import Axes3D. This may be due to multiple versions of "
params: {'steer_time_delay': 0.0007710570453590305, 'mass': 10.864864924637185, 'damping': 30.190196862802175, 'stiffness': 58.34026384572137, 'steer_dead_band': 0.00030095624595404767}
Running simulation with initial parameters...
straight_error: 21.987723516478454
curve_error: 99.00222563388706
angle_rate_error: 0.03344426919210258
error_between_observed_and_input: 106.79344233642182
error_between_output_and_observed: 139.0445551692286
error_between_output_and_input: 201.27649476784683
Total Error: 21.9877
Simulation completed in 0.0601 seconds.

{
    "parameters": {
        "steer_time_delay": 0.0007710570453590305,
        "mass": 10.864864924637185,
        "damping": 30.190196862802175,
        "stiffness": 58.34026384572137,
        "steer_dead_band": 0.00030095624595404767
    },
    "cost": 211.79172486868381
}

image

Related links

Parent Issue:

  • Link

How was this PR tested?

  • psim

image

  • add unit test

Notes for reviewers

None.

Interface changes

None.

Effects on system behavior

None.

@github-actions github-actions bot added the component:simulation Virtual environment setups and simulations. (auto-assigned) label Nov 7, 2024
Copy link

github-actions bot commented Nov 7, 2024

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

@kosuke55 kosuke55 force-pushed the feat/steering_simulator branch 3 times, most recently from 5defad3 to 0af73ff Compare November 7, 2024 13:24
@github-actions github-actions bot added the type:documentation Creating or refining documentation. (auto-assigned) label Nov 7, 2024
@kosuke55 kosuke55 force-pushed the feat/steering_simulator branch 2 times, most recently from 81e09bb to 8fc6815 Compare November 7, 2024 13:31
@kosuke55 kosuke55 marked this pull request as ready for review November 7, 2024 13:45
@kosuke55 kosuke55 added the tag:run-build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Nov 7, 2024
Copy link

codecov bot commented Nov 7, 2024

Codecov Report

Attention: Patch coverage is 88.27362% with 36 lines in your changes missing coverage. Please review.

Project coverage is 29.38%. Comparing base (70b6f19) to head (f948fcd).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
...planning_simulator/utils/mechanical_controller.cpp 86.06% 19 Missing and 4 partials ⚠️
...nning_simulator/simple_planning_simulator_core.cpp 84.61% 5 Missing and 3 partials ⚠️
...imulator/vehicle_model/sim_model_actuation_cmd.cpp 94.11% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9252      +/-   ##
==========================================
+ Coverage   29.24%   29.38%   +0.13%     
==========================================
  Files        1335     1339       +4     
  Lines      102954   103218     +264     
  Branches    39937    40013      +76     
==========================================
+ Hits        30114    30329     +215     
- Misses      69920    69967      +47     
- Partials     2920     2922       +2     
Flag Coverage Δ *Carryforward flag
differential 27.92% <88.27%> (?)
total 29.21% <ø> (-0.04%) ⬇️ Carriedforward from 70b6f19

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +374 to +386
/**
* @brief update vehicle states
* @param [in] dt delta time [s]
*/
void update(const double & dt) override;

/**
* @brief update vehicle states with controller
* @details In updateRungeKutta, calcModel is called four times, but the internal state of PID and
* Dynamics should not be updated. Therefore, a method is prepared to update the internal state
* only once at the end without using the updateRungeKutta of the interface.
*/
void updateRungeKuttaWithController(const double dt, const Eigen::VectorXd & input);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I override update() and make own updateRungeKuttaWithController not to update internal state in PID and Mechanical Dynamics during rungge kutta.

  /**
   * @brief update vehicle states with controller
   * @details In updateRungeKutta, calcModel is called four times, but the internal state of PID and
   * Dynamics should not be updated. Therefore, a method is prepared to update the internal state
   * only once at the end without using the updateRungeKutta of the interface.
   */

@kosuke55 kosuke55 force-pushed the feat/steering_simulator branch 5 times, most recently from 413d1cd to 7ab4298 Compare November 12, 2024 09:25
@kosuke55 kosuke55 added the tag:deploy-docs Mark for deploy-docs action generation. (used-by-ci) label Nov 12, 2024
@kosuke55
Copy link
Contributor Author

move to #9300
(commit can be refrected and PR can not be reopened for some reason, I recreate PR again)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:simulation Virtual environment setups and simulations. (auto-assigned) tag:deploy-docs Mark for deploy-docs action generation. (used-by-ci) tag:run-build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) type:documentation Creating or refining documentation. (auto-assigned)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants