File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
include/cddp-cpp/cddp_core Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,17 @@ class CDDP {
162
162
* @brief Set the Reference state
163
163
* @param reference_state Reference state
164
164
*/
165
- void setReferenceState (const Eigen::VectorXd& reference_state) { reference_state_ = reference_state; }
165
+ void setReferenceState (const Eigen::VectorXd& reference_state) {
166
+ reference_state_ = reference_state;
167
+ // Update the objective reference state
168
+ objective_->setReferenceState (reference_state);
169
+ }
170
+
171
+ void setReferenceStates (const std::vector<Eigen::VectorXd>& reference_states) {
172
+ reference_states_ = reference_states;
173
+ // Update the objective reference states
174
+ objective_->setReferenceStates (reference_states);
175
+ }
166
176
167
177
/* *
168
178
* @brief Set the time horizon for the problem
@@ -282,6 +292,7 @@ class CDDP {
282
292
std::unique_ptr<LogBarrier> log_barrier_;
283
293
Eigen::VectorXd initial_state_;
284
294
Eigen::VectorXd reference_state_; // Desired reference state
295
+ std::vector<Eigen::VectorXd> reference_states_; // Desired reference states (trajectory)
285
296
int horizon_; // Time horizon for the problem
286
297
double timestep_; // Time step for the problem
287
298
CDDPOptions options_; // Options for the solver
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ TEST(CDDPTest, SolveLogCDDP) {
46
46
0.0 , 0.0 , 10.0 ;
47
47
Qf = 0.5 * Qf;
48
48
Eigen::VectorXd goal_state (state_dim);
49
- goal_state << 2 .0 , 2.0 , M_PI/2.0 ;
49
+ goal_state << 3 .0 , 2.0 , M_PI/2.0 ;
50
50
51
51
// Create an empty vector of Eigen::VectorXd
52
52
std::vector<Eigen::VectorXd> empty_reference_states;
@@ -82,6 +82,10 @@ TEST(CDDPTest, SolveLogCDDP) {
82
82
cddp_solver.setDynamicalSystem (std::move (system));
83
83
cddp_solver.setObjective (std::move (objective));
84
84
85
+ // Update goal state (for test)
86
+ goal_state << 2.0 , 2.0 , M_PI/2.0 ;
87
+ cddp_solver.setReferenceState (goal_state);
88
+
85
89
// Define control box constraints
86
90
Eigen::VectorXd control_lower_bound (control_dim);
87
91
control_lower_bound << -1.0 , -M_PI;
You can’t perform that action at this time.
0 commit comments