Skip to content

Commit f25af06

Browse files
Merge pull request #10 from astomodynamics:ros_integration_test
Ros_integration_test
2 parents fc1fa4b + 16fb0c7 commit f25af06

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

include/cddp/cddp_core/CDDPProblem.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ struct CDDPOptions {
4343
double regularization_max = 1e6; // Maximum regularization
4444
double regularization_min = 1e-6; // Minimum regularization
4545
bool print_iterations = true; // Option for debug printing
46+
bool is_ilqr = false; // Option for iLQR
4647
};
4748

4849
class CDDPProblem {

include/cddp/cddp_core/Objective.hpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,69 @@ class QuadraticTrackingCost : public Objective {
127127
}
128128

129129
};
130+
131+
132+
// // Example: Quadratic Tracking Cost Function with Acceleration Cost
133+
// class QuadraticTrackingCostWithAccel : public Objective {
134+
// private:
135+
// Eigen::MatrixXd Q_;
136+
// Eigen::MatrixXd R_;
137+
// Eigen::MatrixXd Ra_;
138+
// Eigen::MatrixXd Qf_;
139+
// std::vector<Eigen::VectorXd> X_ref_;
140+
// Eigen::VectorXd goal_state_;
141+
// double timestep_;
142+
143+
// public:
144+
// QuadraticTrackingCostWithAccel(const Eigen::MatrixXd& Q, const Eigen::MatrixXd& R, const Eigen::MatrixXd &Qf, std::vector<Eigen::VectorXd> &X_ref, Eigen::VectorXd &goal_state, double timestep) : Q_(Q), R_(R), Ra_(Ra), Qf_(Qf), X_ref_(X_ref), goal_state_(goal_state), timestep_(timestep) {}
145+
146+
// double calculateCost(const std::vector<Eigen::VectorXd>& X, const std::vector<Eigen::VectorXd>& U) const override {
147+
// double cost = 0.0;
148+
// for (int i = 0; i < U.size(); i++) {
149+
// cost += calculateRunningCost(X[i], U[i], i);
150+
// }
151+
// cost += calculateFinalCost(X[X.size() - 1]);
152+
153+
// for (int i = 0; i < U.size() - 1; i++) {
154+
155+
// }
156+
// return cost;
157+
// }
158+
159+
// double calculateRunningCost(const Eigen::VectorXd& x, const Eigen::VectorXd& u, int k) const override {
160+
// double cost = 0.0; // Initialize cost to 0
161+
// cost += 0.5 * ((x - X_ref_[k]).transpose() * Q_ * (x - X_ref_[k])).value() * timestep_;
162+
// cost += 0.5 * (u.transpose() * R_ * u).value() * timestep_;
163+
// return cost;
164+
// }
165+
166+
// std::tuple<Eigen::MatrixXd, Eigen::MatrixXd> calculateRunningCostGradient(const Eigen::VectorXd& x, const Eigen::VectorXd& u, int k) const override {
167+
// Eigen::VectorXd l_x = Q_ * (x - X_ref_[k]) * timestep_;
168+
// Eigen::VectorXd l_u = R_ * u * timestep_;
169+
// return std::make_tuple(l_x, l_u);
170+
// }
171+
172+
// std::tuple<Eigen::MatrixXd, Eigen::MatrixXd, Eigen::MatrixXd> calculateRunningCostHessian(const Eigen::VectorXd& x, const Eigen::VectorXd& u, int k) const override {
173+
// Eigen::MatrixXd l_xx = Q_ * timestep_;
174+
// Eigen::MatrixXd l_ux = Eigen::MatrixXd::Zero(R_.rows(), Q_.rows());
175+
// Eigen::MatrixXd l_uu = R_ * timestep_;
176+
// return std::make_tuple(l_xx, l_ux, l_uu);
177+
// }
178+
179+
// double calculateFinalCost(const Eigen::VectorXd& x) const override {
180+
// return 0.5 * ((x - goal_state_).transpose() * Qf_ * (x - goal_state_)).value();
181+
// }
182+
183+
// Eigen::VectorXd calculateFinalCostGradient(const Eigen::VectorXd& x) const override {
184+
// return Qf_ * (x - goal_state_);
185+
// }
186+
187+
// Eigen::MatrixXd calculateFinalCostHessian(const Eigen::VectorXd& x) const override {
188+
// return Qf_;
189+
// }
190+
191+
// };
192+
130193
} // namespace cddp
131194

132195
#endif // CDDP_OBJECTIVE_HPP

0 commit comments

Comments
 (0)