Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Implement the Simple Vehicle Dynamics Interface in C++ #330
base: main
Are you sure you want to change the base?
Implement the Simple Vehicle Dynamics Interface in C++ #330
Changes from all commits
0f55fe9
8d119d4
0b5cd85
c19d6bc
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know c++ had default args, this is cool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are these class variables? If possible, make them local to the update function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BlakeFreer For the
CalculateTCScaleFactor
function I assumed that the OS is handled by main.cc, and will call thesimp_vd_interface
update function at a regular interval. Time_ms will then represent time elapsed, and the TC scale factor will be returned based on that. Let me know if this is the right approach.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also had a couple more questions:
simp_vd_interface
Simulink subsystem? It looks like it just scales the input by 10, am I right to assume that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it looks like a multiply by ten, but that doesn't logically make sense since that implies 1000% torque. I'm guessing that it was a hack because the running average block stores 10 values.
We will implement it differently for the C++ implementation. You should use the LookupTable from
shared/util/mappers/lookup_table
. See this file for an example on creating a lookup table. Your table should only have two key-values: 0,0 and 100,100. This means it doesn't actually modify the input, but in the future we will want the ability to modify this curve.Replace the entire Running Average block with MovingAverage from
shared/util/moving_average
. See this file for an example.I'm not sure how to test simulink, but I don't really trust the model anyways. You should come up with test cases manually. For example, if driver_torque_request=0 then the output torque request should be zero. Don't worry too much about them rn. Just make some simple tests so that we have something to build on later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mostly correct.
time_ms
will be the absolute current time, not elapsed. If you want elapsed then make astatic
variable in your function (static variables don't get reset on successive function calls). Idk if your code actually needs the time, but it's there just in case.