Repository navigation
Explain motion model equations and discretization in State (#99) - #333
Apocalypse10110 wants to merge 2 commits into
Conversation
ShisatoYano
left a comment
There was a problem hiding this comment.
Thank you for picking up #99, @Apocalypse10110! Writing the update equations next to A and B, and saying which column multiplies which state, is exactly what the issue asked for. I checked the equations against the code: for 1,000 random states and inputs, your four equations and State.motion_model agree to 1e-15. The existing tests that use State pass as well (27 passed).
Before we can merge, there are two things to fix:
-
The
PR_Evidencecheck. It fails for two reasons:- The check needs you to be assigned to the issue the PR refers to. Please comment
/claimon #99; since it is agood first issuewith nobody assigned, you will be assigned automatically. Assigning doesn't rerun the check, so please edit the PR description afterwards to run it again. Next time, please claim the issue before opening the PR (see Claim an issue before you start). - In the same edit, please replace "None." under "Images" with the reason, e.g. "Only docstrings and comments change, so there is no behavior to show." I will then add the
no images neededlabel.
- The check needs you to be assigned to the issue the PR refers to. Please comment
-
The discretization is not a forward Euler step. The code keeps the heading
yaw_tand the accelerationa_tconstant during the step and integrates the speed exactly, which is where the0.5 * a_t * dt^2terms come from. A plain forward Euler step would bex_t + v_t * cos(yaw_t) * dtwithout that term (for v = 5 m/s, a = 2 m/s², dt = 0.1 s the code gives x = 0.51 m, Euler gives 0.50 m). Also, the yaw rate doesn't act on the position during the step, because the heading is frozen atyaw_t. Section 3.3 of the book describes it the same way ("a slightly better version" of Euler). Something like this would match the code:Kinematic bicycle model, discretized over one step of length dt = time_s. During the step the heading yaw_t and the acceleration a_t are kept constant, so the vehicle moves on a straight segment of length v_t * dt + 0.5 * a_t * dt^2 (a plain forward Euler step would drop the 0.5 * a_t * dt^2 term):
Suggestions:
- The model here takes the yaw rate
omegaas input instead of the steering angledelta(omega = v * tan(delta) / L, Section 3.2 of the book). One line saying so would save a beginner from looking forLanddeltain this function. - Please link the book page instead of the file path, as other docstrings do (e.g.
pure_pursuit_controller.py):https://shisatoyano.github.io/AutonomousVehicleControlBeginnersGuide/vehicle_model/index.html(Section 3.3).
Minor:
- The description says "Tests not run (no command execution available)", while the AI disclosure says "I reviewed and tested the changes myself". Could you make them consistent? It's fine if you didn't run the tests; just say so.
Thanks again, this will make the motion model much easier to follow!
🤖 Generated with Claude Code
e1e89fe to
83b5ed1
Compare
83b5ed1 to
ca4adbf
Compare
|
Thanks for the detailed review, and for checking the equations against the code! I commented /claim on #99, but the bot hasn't assigned me yet. Could you assign me if it doesn't pick it up? |
|
Let me know what you think of these changes! |
|
Thanks for the quick update, @Apocalypse10110! I'll look at the new commit once you're assigned. About 🤖 Generated with Claude Code |
okay i commented /claim. Let me know if you need anytthing else |
|
Thanks for the update and for claiming #99, @Apocalypse10110! I checked the new commit:
I added the One small thing left in the PR description (not the code). Editing it is enough:
I'll merge once the description is updated and CI is green. Thanks again, this makes the motion model much easier to follow! 🤖 Generated with Claude Code |
Updated the description: the summary now describes the discretization the way the docstring does, and the testing note matches the disclosure. Thanks for the thorough review! |
Summary
Adds the kinematic bicycle model equations, the discretization (heading and acceleration held constant over one step), and the meaning of the A and B matrices to the docstring and comments of
State.motion_model, with a reference to Rajamani, Vehicle Dynamics and Control (2012). No code logic changed.How I checked it works
Compared each matrix entry in
AandBagainst the written update equations for x, y, yaw and v. Only comments and docstrings changed, so behaviour is identical. I reviewed the changes myself; I didn't run the tests.Images
Only docstrings and comments change, so there is no behavior to show.
Book
Fixes #99.
AI disclosure: drafted with Claude Code; I reviewed and tested the changes myself.