-
Notifications
You must be signed in to change notification settings - Fork 122
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
Motion Computation CTRV prediction is wrong #2398
Closed
Labels
anomaly
Something isn't working
Comments
This was referenced Jun 5, 2024
MishkaMN
added a commit
to usdot-fhwa-stol/carma-utils
that referenced
this issue
Jun 6, 2024
<!-- Thanks for the contribution, this is awesome. --> # PR Details ## Description Fixes the equation in CTRV model. The new equation comes from solving the matrix here https://www.mathworks.com/help/fusion/ug/motion-model-state-and-process-noise.html OR when solved: ![image](https://github.com/usdot-fhwa-stol/carma-utils/assets/20613282/89477304-ae18-4ef8-b3ec-be1d667e37c5) AND also fixes typo in CV mode, which probably was benign error <!--- Describe your changes in detail --> The original paper that had a typo: http://fusion.isif.org/proceedings/fusion08CD/papers/1569107835.pdf ## Related GitHub Issue usdot-fhwa-stol/carma-platform#2398 <!--- This project only accepts pull requests related to open GitHub issues or Jira Keys --> <!--- If suggesting a new feature or change, please discuss it in an issue first --> <!--- If fixing a bug, there should be an issue describing it with steps to reproduce --> <!--- Please DO NOT name partially fixed issues, instead open an issue specific to this fix --> <!--- Please link to the issue here: --> ## Related Jira Key https://usdot-carma.atlassian.net/browse/CAR-6057 <!-- e.g. CAR-123 --> ## Motivation and Context HASS demo 06/11/2024. Also discovered during VOICES demo Pilot 2(?) <!--- Why is this change required? What problem does it solve? --> ## How Has This Been Tested? - unit tested - From integration testing with Adrew, this actually did not fix the issue. However, I am pretty sure the new equation is correct. <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [X] Defect fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that cause existing functionality to change) ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [X] I have added any new packages to the sonar-scanner.properties file - [X] My change requires a change to the documentation. - [X] I have updated the documentation accordingly. - [X] I have read the [**CONTRIBUTING**](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/Contributing.md) document. - [X] I have added tests to cover my changes. - [X] All new and existing tests passed.
9 tasks
MishkaMN
added a commit
to usdot-fhwa-stol/carma-utils
that referenced
this issue
Jun 14, 2024
<!-- Thanks for the contribution, this is awesome. --> # PR Details ## Description <!--- Describe your changes in detail --> This PR fixes the issue where predicted states of CTRV motion model is showing opposite direction (often flips back and forth). This is seriously impacting yielding behavior of carma due to bad prediction. So I put an example scenario where heavy vehicle is red, carma is green (you can see the camera view on right) and predicted states are showing as transforms. Truck is actually travelling lower left corner of the intersection as you can see from the truck's front being shown in the camera, but it is predicted backwards. Before: Because velocity is already in the map frame, if we add that angle to orientation like the old code, it will flip the direction to the opposite: ![image](https://github.com/usdot-fhwa-stol/carma-utils/assets/20613282/3bbe2fa2-5ed4-4d22-a9e9-a96d3d28dd43) This is because old code assumed velocity was in base_link frame (which often just non-zero x value without noise which is the direction of travel) and pose orientation was the mostly the main yaw in CTRV. However, in simulation, all objects reported and used in carma's world model are already in map frame velocity, so it was "double counting". atan fix: previously the function was only getting the angle from y value and not accounting x, which means angle in 3rd quadrant will be in 4th erroneously: ![image](https://github.com/usdot-fhwa-stol/carma-utils/assets/20613282/827b8229-cb70-4233-aa86-ad25a6dc1bfc) after atan and frame fix: ![image](https://github.com/usdot-fhwa-stol/carma-utils/assets/20613282/04c96e9e-f5d7-4a3f-b24e-901492b08550) I think technically the original code is correct, however, without this fix the current logic will not work. I have documented why we needed this "workaround" at the moment in the code and in here: usdot-fhwa-stol/carma-platform#2401 ## Related GitHub Issue fixes: usdot-fhwa-stol/carma-platform#2398 <!--- This project only accepts pull requests related to open GitHub issues or Jira Keys --> <!--- If suggesting a new feature or change, please discuss it in an issue first --> <!--- If fixing a bug, there should be an issue describing it with steps to reproduce --> <!--- Please DO NOT name partially fixed issues, instead open an issue specific to this fix --> <!--- Please link to the issue here: --> ## Related Jira Key https://usdot-carma.atlassian.net/browse/CAR-6058 <!-- e.g. CAR-123 --> ## Motivation and Context During HASS and VOICE demo, it was discovered that vehicles's prediction would flip back and forith going opposite direction <!--- Why is this change required? What problem does it solve? --> ## How Has This Been Tested? sim pc 2, made scenario-runner heavy vehicle to travel lower left of the intersection and observed the prediction. And also tested successfully on VOICES with simulated carma detecting real life carma's trajectory correctly using CTRV <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [X] Defect fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that cause existing functionality to change) ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [X] I have added any new packages to the sonar-scanner.properties file - [ ] My change requires a change to the documentation. - [X] I have updated the documentation accordingly. - [X] I have read the [**CONTRIBUTING**](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/Contributing.md) document. - [X] I have added tests to cover my changes. - [X] All new and existing tests passed.
Resolved with above PR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
During testing of VOICES with live vehicle driving before carma vehicle, carma vehicle yields based on the CTRV model of the observed vehicle. However, it was noticed that sometimes the prediction would go backwards:
Where a live vehicle is driving north on the right lane and carma is on the left driving north as well. Here, the red line indicates the predicted trajectory of vehicle which incorrectly shows south. This prediction switches back and forth a lot, which significantly decreases yielding capability of carma.
Background on the CTRV Model
The CTRV model assumes that the object moves with a constant velocity and a constant yaw rate (turn rate). The equations of motion for the object's position and orientation are derived from these assumptions.
Original (Incorrect) Equations
These equations improperly handle the trigonometric relationships for the new position, resulting in incorrect predictions.
Corrected Equations
Actual equation derivations:
https://www.mathworks.com/help/fusion/ug/motion-model-state-and-process-noise.html
Version
4.5.0 (Current)
Expected Behavior
See above
Actual Behavior
See above
Steps to Reproduce the Actual Behavior
it was discovered in simulation.
Related Work
No response
The text was updated successfully, but these errors were encountered: