@@ -64,19 +64,19 @@ LeggedRobotMpcnetInterface::LeggedRobotMpcnetInterface(size_t nDataGenerationThr
64
64
mpcnetDefinitionPtrs.reserve (nDataGenerationThreads + nPolicyEvaluationThreads);
65
65
referenceManagerPtrs.reserve (nDataGenerationThreads + nPolicyEvaluationThreads);
66
66
for (int i = 0 ; i < (nDataGenerationThreads + nPolicyEvaluationThreads); i++) {
67
- leggedRobotInterfacePtrs_.push_back (std::unique_ptr <LeggedRobotInterface>(new LeggedRobotInterface ( taskFile, urdfFile, referenceFile) ));
68
- std::shared_ptr<ocs2::mpcnet::MpcnetDefinitionBase> mpcnetDefinitionPtr ( new LeggedRobotMpcnetDefinition ( *leggedRobotInterfacePtrs_[i]) );
67
+ leggedRobotInterfacePtrs_.push_back (std::make_unique <LeggedRobotInterface>(taskFile, urdfFile, referenceFile));
68
+ auto mpcnetDefinitionPtr = std::make_shared<LeggedRobotMpcnetDefinition>( *leggedRobotInterfacePtrs_[i]);
69
69
mpcPtrs.push_back (getMpc (*leggedRobotInterfacePtrs_[i]));
70
70
mpcnetPtrs.push_back (std::unique_ptr<ocs2::mpcnet::MpcnetControllerBase>(new ocs2::mpcnet::MpcnetOnnxController (
71
71
mpcnetDefinitionPtr, leggedRobotInterfacePtrs_[i]->getReferenceManagerPtr (), onnxEnvironmentPtr)));
72
72
if (raisim) {
73
73
RaisimRolloutSettings raisimRolloutSettings (raisimFile, " rollout" );
74
74
raisimRolloutSettings.portNumber_ += i;
75
- leggedRobotRaisimConversionsPtrs_.push_back (std::unique_ptr <LeggedRobotRaisimConversions>( new LeggedRobotRaisimConversions (
75
+ leggedRobotRaisimConversionsPtrs_.push_back (std::make_unique <LeggedRobotRaisimConversions>(
76
76
leggedRobotInterfacePtrs_[i]->getPinocchioInterface (), leggedRobotInterfacePtrs_[i]->getCentroidalModelInfo (),
77
- leggedRobotInterfacePtrs_[i]->getInitialState ()))) ;
77
+ leggedRobotInterfacePtrs_[i]->getInitialState ()));
78
78
leggedRobotRaisimConversionsPtrs_[i]->loadSettings (raisimFile, " rollout" , true );
79
- rolloutPtrs.push_back (std::unique_ptr<RolloutBase>( new RaisimRollout (
79
+ rolloutPtrs.push_back (std::make_unique< RaisimRollout> (
80
80
urdfFile, resourcePath,
81
81
[&, i](const vector_t & state, const vector_t & input) {
82
82
return leggedRobotRaisimConversionsPtrs_[i]->stateToRaisimGenCoordGenVel (state, input);
@@ -90,7 +90,7 @@ LeggedRobotMpcnetInterface::LeggedRobotMpcnetInterface(size_t nDataGenerationThr
90
90
nullptr , raisimRolloutSettings,
91
91
[&, i](double time, const vector_t & input, const vector_t & state, const Eigen::VectorXd& q, const Eigen::VectorXd& dq) {
92
92
return leggedRobotRaisimConversionsPtrs_[i]->inputToRaisimPdTargets (time, input, state, q, dq);
93
- }))) ;
93
+ }));
94
94
if (raisimRolloutSettings.generateTerrain_ ) {
95
95
raisim::TerrainProperties terrainProperties;
96
96
terrainProperties.zScale = raisimRolloutSettings.terrainRoughness_ ;
@@ -132,9 +132,9 @@ std::unique_ptr<MPC_BASE> LeggedRobotMpcnetInterface::getMpc(LeggedRobotInterfac
132
132
return settings;
133
133
}();
134
134
// create one MPC instance
135
- std::unique_ptr<MPC_BASE> mpcPtr ( new GaussNewtonDDP_MPC (mpcSettings, ddpSettings, leggedRobotInterface. getRollout (),
136
- leggedRobotInterface.getOptimalControlProblem (),
137
- leggedRobotInterface.getInitializer () ));
135
+ auto mpcPtr =
136
+ std::make_unique<GaussNewtonDDP_MPC>(mpcSettings, ddpSettings, leggedRobotInterface.getRollout (),
137
+ leggedRobotInterface. getOptimalControlProblem (), leggedRobotInterface.getInitializer ());
138
138
mpcPtr->getSolverPtr ()->setReferenceManager (leggedRobotInterface.getReferenceManagerPtr ());
139
139
return mpcPtr;
140
140
}
0 commit comments