Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion profile.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
#include "profile.h"
#include <cmath>

const double Profile::GetTime() {
return 0.0;
//part one
float goal = this->goal_.position;//this is current position
float current = this->current_.position;
float delta_x = goal - current;
double t = sqrt(2*delta_x/kMaxAcceleration);

//part two
double velocity = this->current_.velocity;//intital velocity
double t1 = (kMaxVelocity-velocity)/kMaxAcceleration;// equasion is (vf-vi)/a
double s1 = t1*(kMaxVelocity/2);
double remainting_distance = goal-s1;
double t2 = s1/kMaxVelocity; //seccond period of time
double final_time = t1 + t2; //final time

//calculations
double distance = s1 * 2 + remainting_distance;
double everything = t1 + t2 + t1; //last thing
return everything;
}
4 changes: 2 additions & 2 deletions profile.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef PROFILE_H_
#define PROFILE_H_

constexpr kMaxVelocity = 1.0;
constexpr kMaxAcceleration = 1.0;
constexpr int kMaxVelocity = 1.0;
constexpr int kMaxAcceleration = 1.0;

class Profile {
public:
Expand Down