@@ -24,7 +24,7 @@ namespace simple_mpc
2424 namespace bp = boost::python;
2525 using eigenpy::StdVectorPythonVisitor;
2626
27- void initialize ( MPC & self, const bp::dict & settings, std::shared_ptr<OCPHandler> problem)
27+ MPC * createMPC ( const bp::dict & settings, std::shared_ptr<OCPHandler> problem)
2828 {
2929 MPCSettings conf;
3030
@@ -42,7 +42,7 @@ namespace simple_mpc
4242 conf.T_contact = bp::extract<int >(settings[" T_contact" ]);
4343 conf.timestep = bp::extract<double >(settings[" timestep" ]);
4444
45- self. initialize ( conf, problem) ;
45+ return new MPC{ conf, problem} ;
4646 }
4747
4848 bp::dict getSettings (MPC & self)
@@ -73,8 +73,7 @@ namespace simple_mpc
7373 StdVectorPythonVisitor<std::vector<MapBool>, true >::expose (" StdVec_MapBool" );
7474
7575 bp::class_<MPC>(" MPC" , bp::no_init)
76- .def (bp::init<>(bp::args (" self" )))
77- .def (" initialize" , &initialize)
76+ .def (" __init__" , bp::make_constructor (&createMPC, bp::default_call_policies ()))
7877 .def (" getSettings" , &getSettings)
7978 .def (" generateCycleHorizon" , &MPC::generateCycleHorizon, bp::args (" self" , " contact_states" ))
8079 .def (" iterate" , &MPC::iterate, bp::args (" self" , " x" ))
0 commit comments