Add basic motion profiling with/without max velocity#5
Add basic motion profiling with/without max velocity#5DavidCarlip wants to merge 6 commits intojishnusen:masterfrom
Conversation
main.cc
Outdated
| @@ -1,4 +1,4 @@ | |||
| #include "profile.h" | |||
| #include "profile.cc" | |||
There was a problem hiding this comment.
I don't know if I'm forgetting something obvious, but when I only include the h file it doesn't compile
/usr/bin/ld: /tmp/ccqgADwJ.o: in function 'main': main.cc:(.text+0x8a): undefined reference to 'Profile::GetTime(bool)' /usr/bin/ld: main.cc:(.text+0xbc): undefined reference to 'Profile::GetTime(bool)' collect2: error: ld returned 1 exit status
There was a problem hiding this comment.
your code doesn't compile for me. i have to have it as profile.h. are you using bazel?
There was a problem hiding this comment.
I had been using g++ because I somehow missed the BUILD file, setting up tools and building now works with profile.h, will change
profile.cc
Outdated
| return std::sqrt((2*goal_.position) / kMaxVelocity); | ||
| } else { | ||
| int time_accelerating = (kMaxVelocity + current_.velocity) / kMaxAcceleration; | ||
| int time_constant = ((goal_.position - (time_accelerating * kMaxVelocity)) / kMaxVelocity); |
There was a problem hiding this comment.
Should check if constant velocity is needed. You may end up following a triangle not a trapezoid. Also double not int
profile.cc
Outdated
| } else { | ||
| int time_accelerating = (kMaxVelocity + current_.velocity) / kMaxAcceleration; | ||
| int time_constant = ((goal_.position - (time_accelerating * kMaxVelocity)) / kMaxVelocity); | ||
| return (2 * time_accelerating) + time_constant; |
| #define PROFILE_H_ | ||
|
|
||
| constexpr kMaxVelocity = 1.0; | ||
| constexpr kMaxAcceleration = 1.0; |
profile.cc
Outdated
| if (ignore_max_velocity) { | ||
| return std::sqrt((2*goal_.position) / kMaxVelocity); | ||
| } else { | ||
| double time_accelerating = (kMaxVelocity + current_.velocity) / kMaxAcceleration; |
There was a problem hiding this comment.
should be kMaxVelocity - current_.velocity
profile.cc
Outdated
| } else { | ||
| double time_accelerating = (kMaxVelocity + current_.velocity) / kMaxAcceleration; | ||
| double time_decelerating = (kMaxVelocity + goal_.velocity) / kMaxAcceleration; | ||
| double time_constant = ((goal_.position - (0.5*(time_accelerating * kMaxVelocity) + 0.5*(time_decelerating * kMaxVelocity))) / kMaxVelocity); |
No description provided.