-
Notifications
You must be signed in to change notification settings - Fork 10
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
Fixed horizon and other bugs in examples #100
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c1e14a8
Fixed horizon bug in hermite parametrization
scharalambous3 7def47d
Fixed issue due to updated constructor
scharalambous3 26d0e8d
Fixed another issue due to updated constructor
scharalambous3 c39830c
Fixed build errors for these examples
scharalambous3 3f57462
Improved documentation
scharalambous3 30d8475
Resolved review comments
scharalambous3 fbbf32f
use linear algebra for clean cubic spline computation
varunagrawal 7a5765c
replace typedef with using
varunagrawal 5fdc093
Changed Eigen comma-initializer syntax
scharalambous3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -52,26 +52,25 @@ int main(int argc, char** argv) { | |
double theta_T = M_PI, dtheta_T = 0, ddtheta_T = 0; | ||
|
||
// Create trajectory factor graph. | ||
auto graph_builder = DynamicsGraph(); | ||
auto graph_builder = DynamicsGraph(gravity, planar_axis); | ||
auto graph = graph_builder.trajectoryFG( | ||
ip, t_steps, dt, DynamicsGraph::CollocationScheme::Trapezoidal, gravity, | ||
planar_axis); | ||
ip, t_steps, dt, DynamicsGraph::CollocationScheme::Trapezoidal); | ||
|
||
// Add initial conditions to trajectory factor graph. | ||
graph.addPrior(JointAngleKey(j1_id, 0), theta_i, dynamics_model); | ||
graph.addPrior(JointVelKey(j1_id, 0), dtheta_i, dynamics_model); | ||
graph.addPrior(internal::JointAngleKey(j1_id, 0), theta_i, dynamics_model); | ||
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. The same copy/pasta!!!!!! |
||
graph.addPrior(internal::JointVelKey(j1_id, 0), dtheta_i, dynamics_model); | ||
|
||
// Add state and min torque objectives to trajectory factor graph. | ||
graph.addPrior(JointVelKey(j1_id, t_steps), dtheta_T, objectives_model); | ||
graph.addPrior(JointAccelKey(j1_id, t_steps), dtheta_T, objectives_model); | ||
graph.addPrior(internal::JointVelKey(j1_id, t_steps), dtheta_T, objectives_model); | ||
graph.addPrior(internal::JointAccelKey(j1_id, t_steps), dtheta_T, objectives_model); | ||
bool apply_theta_objective_all_dt = false; | ||
graph.addPrior(JointAngleKey(j1_id, t_steps), theta_T, objectives_model); | ||
graph.addPrior(internal::JointAngleKey(j1_id, t_steps), theta_T, objectives_model); | ||
if (apply_theta_objective_all_dt) { | ||
for (int t = 0; t < t_steps; t++) | ||
graph.addPrior(JointAngleKey(j1_id, t), theta_T, objectives_model); | ||
graph.addPrior(internal::JointAngleKey(j1_id, t), theta_T, objectives_model); | ||
} | ||
for (int t = 0; t <= t_steps; t++) | ||
graph.emplace_shared<MinTorqueFactor>(TorqueKey(j1_id, t), control_model); | ||
graph.emplace_shared<MinTorqueFactor>(internal::TorqueKey(j1_id, t), control_model); | ||
|
||
// Initialize solution. | ||
auto init_vals = ZeroValuesTrajectory(ip, t_steps, 0, 0.0); | ||
|
@@ -88,8 +87,8 @@ int main(int argc, char** argv) { | |
double t_elapsed = 0; | ||
for (int t = 0; t <= t_steps; t++, t_elapsed += dt) { | ||
std::vector<gtsam::Key> keys = { | ||
JointAngleKey(j1_id, t), JointVelKey(j1_id, t), JointAccelKey(j1_id, t), | ||
TorqueKey(j1_id, t)}; | ||
internal::JointAngleKey(j1_id, t), internal::JointVelKey(j1_id, t), internal::JointAccelKey(j1_id, t), | ||
internal::TorqueKey(j1_id, t)}; | ||
std::vector<std::string> vals = {std::to_string(t_elapsed)}; | ||
for (auto&& k : keys) vals.push_back(std::to_string(results.atDouble(k))); | ||
traj_file << boost::algorithm::join(vals, ",") << "\n"; | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Copy/pasta
I think there must be a function already to do this, and if not, there should be