@@ -127,6 +127,69 @@ class QuadraticTrackingCost : public Objective {
127
127
}
128
128
129
129
};
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
+
130
193
} // namespace cddp
131
194
132
195
#endif // CDDP_OBJECTIVE_HPP
0 commit comments