-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Implementation of model_delay with dynamic parameter #6066
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -60,10 +60,12 @@ class MotionModel | |||||
| * @param control_constraints Constraints on control | ||||||
| * @param model_dt duration of a time step | ||||||
| */ | ||||||
| void initialize(const models::ControlConstraints & control_constraints, float model_dt) | ||||||
| void initialize(const models::ControlConstraints & control_constraints, float model_dt, | ||||||
| float model_delay) | ||||||
| { | ||||||
| control_constraints_ = control_constraints; | ||||||
| model_dt_ = model_dt; | ||||||
| model_delay_ = model_delay; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
|
|
@@ -116,6 +118,25 @@ class MotionModel | |||||
| state.vy.col(i) = state.cvy.col(i - 1); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // Apply model delay | ||||||
| if(model_delay_ == 0.0) {return;} | ||||||
| unsigned int offset = std::floor((model_delay_ / model_dt_) + 0.5); | ||||||
| auto state_copy = state; | ||||||
| for (unsigned int i = 0; i != state.vx.shape(0); i++) { | ||||||
| for (unsigned int j = 1; j != state.vx.shape(1); j++) { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll probably take care of this for you but leaving a note for myself: These loops may be eigenized for vectorized operations. |
||||||
| // Keep the first value before delay (because we cannot do better) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Making plural in case large. |
||||||
| if (j < offset) { | ||||||
| state.vx(i, j) = state_copy.vx(i, 0); | ||||||
| state.wz(i, j) = state_copy.wz(i, 0); | ||||||
| if (is_holo) {state.vy(i, j) = state_copy.vy(i, 0);} | ||||||
| } else { // move the command to express delay | ||||||
| state.vx(i, j) = state_copy.vx(i, j - offset); | ||||||
| state.wz(i, j) = state_copy.wz(i, j - offset); | ||||||
| if (is_holo) {state.vy(i, j) = state_copy.vy(i, j - offset);} | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
|
|
@@ -132,6 +153,7 @@ class MotionModel | |||||
|
|
||||||
| protected: | ||||||
| float model_dt_{0.0}; | ||||||
| float model_delay_{0.0}; | ||||||
| models::ControlConstraints control_constraints_{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, | ||||||
| 0.0f, 0.0f}; | ||||||
| }; | ||||||
|
|
||||||
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.
Would it make sense if less than
model_dt_to skip? Or I suppose by the current math< 0.5 * model_dt_would be the same since the offset would be floored to0in which case.But more architecturally, if hte offset is less than one cycle's DT, does it make sense to apply any lag?