当前位置: 首页>>代码示例>>C++>>正文


C++ SX::at方法代码示例

本文整理汇总了C++中SX::at方法的典型用法代码示例。如果您正苦于以下问题:C++ SX::at方法的具体用法?C++ SX::at怎么用?C++ SX::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SX的用法示例。


在下文中一共展示了SX::at方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getOutput

SX MultipleShooting::getOutput(string o)
{
     SX ret = ssym(o, N);
     for (int k=0; k<N; k++)
	  ret.at(k) = getOutput(o, k);
	
     return ret;
}
开发者ID:RobotXiaoFeng,项目名称:casadi,代码行数:8,代码来源:MultipleShooting.cpp

示例2: D

void
dxdt(map<string,SX> &xDot, map<string,SX> &outputs, map<string,SX> state, map<string,SX> action, map<string,SX> param, SX t)
{
	double g  = 9.8;
	double L1 = 0.1;
	double L2 = 0.1;
	double m0 = 0.1;
	double mp = 0.03;
	double m1 = mp;
	double m2 = mp;
     
	double d1 = m0 + m1 + m2;
	double d2 = (0.5*m1 + m2)*L1;
	double d3 = 0.5 * m2 * L2;
	double d4 = ( m1/3 + m2 )*SQR(L1);
	double d5 = 0.5 * m2 * L1 * L2;
	double d6 = m2 * SQR(L2)/3;
	double f1 = (0.5*m1 + m2) * L1 * g;
	double f2 = 0.5 * m2 * L2 * g;

	// th0  = y(1);
	// th1  = y(2);
	// th2  = y(3);
	// th0d = y(4);
	// th1d = y(5);
	// th2d = y(6);

	SX th0  = state["th0"];
	SX th1  = state["th1"];
	SX th2  = state["th2"];
	SX th0d = state["th0d"];
	SX th1d = state["th1d"];
	SX th2d = state["th2d"];

	// D = [          d1,     d2*cos(th1),     d3*cos(th2);
	// 	     d2*cos(th1),              d4, d5*cos(th1-th2);
	// 	     d3*cos(th2), d5*cos(th1-th2),              d6;];

	SX D( zerosSX(3,3) );
	makeDense(D);
	D[0,0] =          d1;   D[0,1] =     d2*cos(th1);   D[0,2] =     d3*cos(th2);
	D[1,0] = d2*cos(th1);   D[1,1] =              d4;   D[1,2] = d5*cos(th1-th2);
	D[2,0] = d3*cos(th2);   D[2,1] = d5*cos(th1-th2);   D[2,2] =              d6;

	// C = [0,     -d2*sin(th1)*th1d,    -d3*sin(th2)*th2d;
	// 	    0,                     0, d5*sin(th1-th2)*th2d;
	// 	    0, -d5*sin(th1-th2)*th1d,                    0;];
	SX C( zerosSX(3,3) );
	makeDense(C);
	C[0,0] = 0;   C[0,1] =      -d2*sin(th1)*th1d;   C[0,2] =     -d3*sin(th2)*th2d;
	C[1,0] = 0;   C[1,1] =                      0;   C[1,2] =  d5*sin(th1-th2)*th2d;
	C[2,0] = 0;   C[2,1] =  -d5*sin(th1-th2)*th1d;   C[2,2] =                     0;

	// G = [0; -f1*sin(th1); -f2*sin(th2);];
	SX G( zerosSX(3,1) );
	makeDense(G);
	G.at(0) = 0;
	G.at(1) = -f1*sin(th1);
	G.at(2) = -f2*sin(th2);

	// H = [1;0;0;];
	SX H( zerosSX(3,1) );
	makeDense(H);
	H.at(0) = 1;
	H.at(1) = 0;
	H.at(2) = 0;

	// dy(1:3) = y(4:6);
	xDot["th0"] = th0d;
	xDot["th1"] = th1d;
	xDot["th2"] = th2d;

	// dy(4:6) = D\( - C*y(4:6) - G + H*u );
	SX vel( zerosSX(3,1) );
	makeDense(vel);
	vel.at(0) = th0d;
	vel.at(1) = th1d;
	vel.at(2) = th2d;
	SX accel = mul( inv(D), - mul( C, vel ) - G + mul( H, SX(action["u"]) ) );

	simplify(accel.at(0));
	simplify(accel.at(1));
	simplify(accel.at(2));

	xDot["th0d"] = accel.at(0);
	xDot["th1d"] = accel.at(1);
	xDot["th2d"] = accel.at(2);

	// cout << th0 << endl;
	// cout << th1 << endl;
	// cout << th2 << endl;

	// cout << th0d << endl;
	// cout << th1d << endl;
	// cout << th2d << endl;

	// cout << accel.at(0) << endl;
	// cout << accel.at(1) << endl;
	// cout << accel.at(2) << endl;

//.........这里部分代码省略.........
开发者ID:BrechtBa,项目名称:casadi,代码行数:101,代码来源:ddpDoubleCartpole.cpp


注:本文中的SX::at方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。