-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from nasa-jpl/bowkett-prof-vel-init-tweak
Add minimum dt to trap_update_vel
- Loading branch information
Showing
3 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include "fastcat/trap.h" | ||
|
||
namespace | ||
{ | ||
class TrapTest : public ::testing::Test | ||
{ | ||
protected: | ||
void SetUp() override { | ||
} | ||
|
||
trap_t trap_1_; | ||
}; | ||
|
||
TEST_F(TrapTest, TrapVelocityReInit){ | ||
|
||
double time_initial = 0.0; | ||
double position_initial = 0.0; | ||
double velocity_initial = 0.0; | ||
double velocity_final = 1.0; | ||
double acceleration = 1.0; | ||
double max_time = 10.0; | ||
|
||
// Generate the first version of the trap | ||
trap_generate_vel(&trap_1_, | ||
time_initial, | ||
position_initial, | ||
velocity_initial, | ||
velocity_final, | ||
acceleration, | ||
max_time); | ||
|
||
double dt = 0.01; | ||
|
||
double tracking_time = time_initial; | ||
double tracking_position = position_initial; | ||
double tracking_velocity = velocity_initial; | ||
|
||
for (int i=0; i<1000; i++) { | ||
// Update trap before any change in time has occurred | ||
trap_update_vel(&trap_1_, tracking_time, | ||
&tracking_position, | ||
&tracking_velocity); | ||
|
||
// Increment time | ||
tracking_time += dt; | ||
|
||
// Regenerate trap to simulate incoming updated setpoint | ||
trap_generate_vel(&trap_1_, tracking_time, | ||
tracking_position, | ||
tracking_velocity, | ||
velocity_final, | ||
acceleration, | ||
max_time); | ||
} | ||
|
||
// The minimum dt used in track vel should guarantee that | ||
// motion occurs despite regeneration happening every cycle | ||
EXPECT_TRUE(tracking_position > position_initial); | ||
} | ||
|
||
} |