53 for(
uint i = 0; i < dim; i++ ) {
54 for(
uint k1 = 0; k1 < dim2; k1++ ) {
55 for(
uint k2 = 0; k2 <= k1; k2++ ) {
56 inter_res(k1,i) += expr(k1,k2)*arg(k2,i);
58 for(
uint k2 = k1+1; k2 < dim2; k2++ ) {
59 inter_res(k1,i) += expr(k2,k1)*arg(k2,i);
65 for(
uint i = 0; i < dim; i++ ) {
66 for(
uint j = 0; j <= i; j++ ) {
68 for(
uint k1 = 0; k1 < dim2; k1++ ) {
69 new_tmp = new_tmp+arg(k1,i)*inter_res(k1,j);
71 new_expr(i,j) = new_tmp;
72 new_expr(j,i) = new_tmp;
83 for(
uint j = 0; j <= i; j++ ) {
84 new_expr << expr(i,j);
114 const double tau1 = 0.012790605943772;
115 const double a1 = 0.047418203070092;
116 const double tau2 = 0.024695192379264;
117 const double a2 = 0.034087337273386;
118 const double g = 9.81;
119 const double c = 0.2;
120 const double m = 1318.0;
128 aT = -1.0 / tau1 * vT + a1 / tau1 * uT;
129 aL = -1.0 / tau2 * vL + a2 / tau2 * uL;
149 int NX = states.getDim();
150 int NU = controls.getDim();
154 expr(0) = - 1.0/xL*(-g*
sin(phi)-aT*
cos(phi)-2*vL*omega-c*omega/(m*xL)) +
log(duT/duL)*
pow(xL,2);
155 expr(1) = - 1.0/xL*(-g*
tan(phi)-aT*
acos(phi)-2*
atan(vL)*omega-c*
asin(omega)/
exp(xL)) + duT/
pow(omega,3);
167 S_tmp.
appendRows(zeros<double>(NU,NX).appendCols(eye<double>(NU)));
174 fun.
init(f,
"symmetricDerivative", NX*(1+NX+NU)+expr.
getDim(), 0, 2, 0, 0, 0);
194 fun2.
init(f2,
"alternativeSymmetric", NX*(1+NX+NU)+expr.
getDim(), 0, 2, 0, 0, 0);
201 std::ofstream stream2(
"ADtest/ADsymbolic_output2.c" );
205 std::ofstream stream(
"ADtest/ADsymbolic_output.c" );
USING_NAMESPACE_ACADO IntermediateState sin(const Expression &arg)
Expression symmetricDerivative(const Expression &arg1, const Expression &arg2, const Expression &forward_seed, const Expression &backward_seed, Expression *forward_result, Expression *backward_result)
Allows to setup and evaluate a general function based on SymbolicExpressions.
IntermediateState atan(const Expression &arg)
Expression backwardDerivative(const Expression &arg1, const Expression &arg2)
Allows to export code of an ACADO function.
#define USING_NAMESPACE_ACADO
Expression forwardDerivative(const Expression &arg1, const Expression &arg2)
IntermediateState asin(const Expression &arg)
IntermediateState pow(const Expression &arg1, const Expression &arg2)
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
IntermediateState tan(const Expression &arg)
Expression returnLowerTriangular(const Expression &expr)
IntermediateState cos(const Expression &arg)
Base class for all variables within the symbolic expressions family.
IntermediateState acos(const Expression &arg)
Expression multipleForwardDerivative(const Expression &arg1, const Expression &arg2, const Expression &seed)
Expression & appendRows(const Expression &arg)
Expression transpose() const
IntermediateState exp(const Expression &arg)
USING_NAMESPACE_ACADO Expression symmetricDoubleProduct(const Expression &expr, const Expression &arg)
virtual returnValue exportCode(std::ostream &stream, const std::string &_realString="real_t", const std::string &_intString="int", int _precision=16) const
Expression & appendCols(const Expression &arg)
returnValue init(const Function &_f, const std::string &_name="acadoFcn", const uint _numX=0, const uint _numXA=0, const uint _numU=0, const uint _numP=0, const uint _numDX=0, const uint _numOD=0)
Allows to setup and evaluate differential equations (ODEs and DAEs) based on SymbolicExpressions.
IntermediateState log(const Expression &arg)