本文整理汇总了C++中VariablesGrid::addVector方法的典型用法代码示例。如果您正苦于以下问题:C++ VariablesGrid::addVector方法的具体用法?C++ VariablesGrid::addVector怎么用?C++ VariablesGrid::addVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VariablesGrid
的用法示例。
在下文中一共展示了VariablesGrid::addVector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDataGrids
returnValue PlotWindow::getDataGrids( const VariablesGrid* const variablesGrid,
VariableType& _type,
VariablesGrid& _dataGrid,
Grid& _discretizationGrid
)
{
_dataGrid.init();
_discretizationGrid.init( );
_type = variablesGrid->getType( );
InterpolationMode mode = IM_LINEAR;
if ( ( _type == VT_CONTROL ) || ( _type == VT_PARAMETER ) )
mode = IM_CONSTANT;
switch ( mode )
{
case IM_CONSTANT:
_discretizationGrid.addTime( 0.0 );
for( uint i=0; i<variablesGrid->getNumPoints( )-1; ++i )
{
_dataGrid.addVector( variablesGrid->getVector(i),variablesGrid->getTime(i) );
_dataGrid.addVector( variablesGrid->getVector(i),variablesGrid->getTime(i+1) );
_discretizationGrid.addTime( (double)_dataGrid.getNumPoints() );
}
_dataGrid.addVector( variablesGrid->getLastVector(),variablesGrid->getLastTime() );
_discretizationGrid.addTime( (double)_dataGrid.getNumPoints() );
break;
case IM_LINEAR:
_dataGrid = *variablesGrid;
break;
default:
return ACADOERROR( RET_NOT_YET_IMPLEMENTED );
}
_dataGrid.setType( _type );
return SUCCESSFUL_RETURN;
}
示例2: main
int main( )
{
USING_NAMESPACE_ACADO
// DEFINE THE VARIABLES:
// ----------------------------------------------------------
DifferentialState p ; // the trolley position
DifferentialState v ; // the trolley velocity
DifferentialState phi ; // the excitation angle
DifferentialState omega; // the angular velocity
Control a ; // the acc. of the trolley
const double g = 9.81; // the gravitational constant
const double b = 0.20; // the friction coefficient
// ----------------------------------------------------------
// DEFINE THE MODEL EQUATIONS:
// ----------------------------------------------------------
DifferentialEquation f;
f << dot( p ) == v ;
f << dot( v ) == a ;
f << dot( phi ) == omega ;
f << dot( omega ) == -g*sin(phi) - a*cos(phi) - b*omega;
// ----------------------------------------------------------
// SETTING UP THE (SIMULATED) PROCESS:
// -----------------------------------
OutputFcn identity;
DynamicSystem dynamicSystem( f,identity );
Process process( dynamicSystem,INT_RK45 );
// SETTING UP THE MPC CONTROLLER:
// ------------------------------
ExportedRTIscheme rtiScheme( 4,1, 10, 0.3 );
#ifdef USE_CVXGEN
set_defaults( );
#endif
Vector xuRef(5);
xuRef.setZero( );
VariablesGrid reference;
reference.addVector( xuRef, 0.0 );
reference.addVector( xuRef, 10.0 );
StaticReferenceTrajectory referenceTrajectory( reference );
Controller controller( rtiScheme,referenceTrajectory );
controller.set( USE_REFERENCE_PREDICTION,NO );
// SETTING UP THE SIMULATION ENVIRONMENT, RUN THE EXAMPLE...
// ----------------------------------------------------------
SimulationEnvironment sim( 0.0,10.0, process,controller );
Vector x0(4);
x0(0) = 1.0;
x0(1) = 0.0;
x0(2) = 0.0;
x0(3) = 0.0;
sim.init( x0 );
sim.run( );
// ... AND PLOT THE RESULTS
// ------------------------
VariablesGrid diffStates;
sim.getProcessDifferentialStates( diffStates );
VariablesGrid feedbackControl;
sim.getFeedbackControl( feedbackControl );
GnuplotWindow window;
window.addSubplot( diffStates(0), "p" );
window.addSubplot( diffStates(1), "v" );
window.addSubplot( diffStates(2), "phi" );
window.addSubplot( diffStates(3), "omega" );
window.addSubplot( feedbackControl(0), "a" );
window.plot( );
return 0;
}