Skip to content

Add basic motion profiling with/without max velocity#5

Open
DavidCarlip wants to merge 6 commits intojishnusen:masterfrom
DavidCarlip:master
Open

Add basic motion profiling with/without max velocity#5
DavidCarlip wants to merge 6 commits intojishnusen:masterfrom
DavidCarlip:master

Conversation

@DavidCarlip
Copy link

No description provided.

main.cc Outdated
@@ -1,4 +1,4 @@
#include "profile.h"
#include "profile.cc"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excuse me what

Copy link
Author

@DavidCarlip DavidCarlip May 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your code doesn't compile for me. i have to have it as profile.h. are you using bazel?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't assume v_f

#define PROFILE_H_

constexpr kMaxVelocity = 1.0;
constexpr kMaxAcceleration = 1.0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double !!

profile.cc Outdated
if (ignore_max_velocity) {
return std::sqrt((2*goal_.position) / kMaxVelocity);
} else {
double time_accelerating = (kMaxVelocity + current_.velocity) / kMaxAcceleration;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is negative?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants