23 #ifndef FINITE_DIFFERENCES_COLLOCATION_H_ 24 #define FINITE_DIFFERENCES_COLLOCATION_H_ 57 assert(error.size() == x1.size());
58 assert(x1.size() >= 3);
62 error.head(2) -= (x2.head(2) - x1.head(2)) / dt;
63 error.coeffRef(2) -=
normalize_theta(x2.coeffRef(2) - x1.coeffRef(2)) / dt;
66 int n = x1.size() - 3;
67 error.tail(n) -= (x2.tail(n) - x1.tail(n)) / dt;
94 assert(error.size() == x1.size());
95 assert(dt > 0 &&
"dt must be greater then zero!");
97 Eigen::VectorXd midpoint = 0.5 * (x1 + x2);
100 system.
dynamics(midpoint, u1, error);
101 error.head(2) -= (x2.head(2) - x1.head(2)) / dt;
102 error.coeffRef(2) -=
normalize_theta(x2.coeffRef(2) - x1.coeffRef(2)) / dt;
105 int n = x1.size() - 3;
106 error.tail(n) -= (x2.tail(n) - x1.tail(n)) / dt;
133 assert(error.size() == x1.size());
134 assert(dt > 0 &&
"dt must be greater then zero!");
136 Eigen::VectorXd f1(x1.size());
140 error.head(2) -= (x2.head(2) - x1.head(2)) / dt - 0.5 * (f1.head(2) + error.head(2));
141 error.coeffRef(2) -=
normalize_theta(x2.coeffRef(2) - x1.coeffRef(2)) / dt - 0.5 * (f1.coeffRef(2) + error.coeffRef(2));
144 int n = x1.size() - 3;
145 error.tail(n) -= (x2.tail(n) - x1.tail(n)) / dt - 0.5 * (f1.tail(n) + error.tail(n));
152 #endif // FINITE_DIFFERENCES_COLLOCATION_H_
void computeEqualityConstraint(const StateVector &x1, const InputVector &u1, const StateVector &x2, double dt, const corbo::SystemDynamicsInterface &system, Eigen::Ref< Eigen::VectorXd > error) override
void computeEqualityConstraint(const StateVector &x1, const InputVector &u1, const StateVector &x2, double dt, const corbo::SystemDynamicsInterface &system, Eigen::Ref< Eigen::VectorXd > error) override
corbo::FiniteDifferencesCollocationInterface::Ptr getInstance() const override
corbo::FiniteDifferencesCollocationInterface::Ptr getInstance() const override
corbo::FiniteDifferencesCollocationInterface::Ptr getInstance() const override
Collocation via Crank-Nicolson differences (specialized for SE2)
virtual void dynamics(const Eigen::Ref< const StateVector > &x, const Eigen::Ref< const ControlVector > &u, Eigen::Ref< StateVector > f) const=0
void computeEqualityConstraint(const StateVector &x1, const InputVector &u1, const StateVector &x2, double dt, const corbo::SystemDynamicsInterface &system, Eigen::Ref< Eigen::VectorXd > error) override
double interpolate_angle(double angle1, double angle2, double factor)
Return the interpolated angle between two angles [rad].
Collocation via midpoint differences (specialized for SE2)
Eigen::VectorXd StateVector
double normalize_theta(double theta)
normalize angle to interval [-pi, pi)
Collocation via forward differences (specialized for SE2)
Eigen::VectorXd InputVector
std::shared_ptr< FiniteDifferencesCollocationInterface > Ptr