diff --git a/python/FootTrajectoryGenerator.cpp b/python/FootTrajectoryGenerator.cpp index 79fce1a2666761a9d2249c81e025ac65b6385732..1e3e110e0994312c91786b08923317dabfe35313 100644 --- a/python/FootTrajectoryGenerator.cpp +++ b/python/FootTrajectoryGenerator.cpp @@ -21,8 +21,11 @@ struct FootTrajectoryGeneratorVisitor .def("update", &FootTrajectoryGenerator::update, bp::args("k", "targetFootstep"), "Compute target location of footsteps from Python.\n") - .def("get_elapsed_durations", &FootTrajectoryGenerator::getT0s, "Get the current timings of the flying feet.\n") - .def("get_phase_durations", &FootTrajectoryGenerator::getTswing, "Get the flying period of the feet.\n"); + .def("get_elapsed_durations", &FootTrajectoryGenerator::getT0s, + "Get the current timings of the flying feet.\n") + .def("get_phase_durations", &FootTrajectoryGenerator::getTswing, "Get the flying period of the feet.\n") + .def("get_trajectory_to_target", &FootTrajectoryGenerator::getTrajectoryToTarget, bp::args("j"), + "Get the whole swing trajectory from current position to target on the ground.\n"); } static void expose() { diff --git a/python/Gait.cpp b/python/Gait.cpp index e22f8a7fc131dda145aca12e37936a86b2aec3d3..63d1a47cf59922825c10b641c0e60ed823fd37e6 100644 --- a/python/Gait.cpp +++ b/python/Gait.cpp @@ -10,15 +10,21 @@ struct GaitVisitor : public bp::def_visitor<GaitVisitor<Gait>> { .def("get_past_gait", &Gait::getPastGait, "Get past gait matrix.\n") .def("get_gait_matrix", &Gait::getCurrentGait, "Get gait matrix.\n") + .def("get_gait_coeff", &Gait::getCurrentGaitCoeff, bp::args("i", "j"), "Get gait coefficient.\n") .def("get_desired_gait", &Gait::getDesiredGait, "Get desired gait matrix.\n") .def("is_new_step", &Gait::isNewPhase, "True if new phase of the gait.\n") .def("is_static", &Gait::getIsStatic, "True if static gait.\n") + .def("get_phase_duration", &Gait::getPhaseDuration, bp::args("i", "j", "value"), "Get phase duration.\n") + .def("get_remaining_time", &Gait::getRemainingTime, "Get remaining time of the last computed phase.\n") .def("initialize", &Gait::initialize, bp::args("params"), "Initialize Gait from Python.\n") .def("update", &Gait::update, bp::args("k", "k_mpc", "joystickCode"), "Update current gait matrix from Python.\n") + .def("set_new_phase", &Gait::setNewPhase, bp::args("value"), "Set value of newPhase_ from Python.\n") + .def("set_late", &Gait::setLate, bp::args("i"), "Set value of isLate_ from Python.\n") + .add_property("matrix", bp::make_function(&Gait::getCurrentGait, bp::return_value_policy<bp::return_by_value>())); } diff --git a/python/Joystick.cpp b/python/Joystick.cpp index f22aad4cdccdade162832e76c5f35dacf5fc4c5f..047f2331a56fa5f5ba8122bd2574c25bbc5cef33 100644 --- a/python/Joystick.cpp +++ b/python/Joystick.cpp @@ -8,21 +8,28 @@ struct JoystickVisitor : public bp::def_visitor<JoystickVisitor<Joystick>> { void visit(PyClassJoystick& cl) const { cl.def(bp::init<>(bp::arg(""), "Default constructor.")) - .def("initialize", &Joystick::initialize, bp::args("params"), "Initialize Joystick from Python.\n") + .def("initialize", &Joystick::initialize, bp::args("params"), "Initialize Joystick from Python.\n") - .def("update_v_ref", &Joystick::update_v_ref, bp::args("k", "gait_is_static"), "Update joystick values.") + .def("update_v_ref", &Joystick::update_v_ref, bp::args("k", "gait_is_static"), "Update joystick values.") + .def("handle_v_switch", &Joystick::handle_v_switch_py, bp::args("k", "k_switch", "v_switch"), + "Run security check.\n") + + .def("update_for_analysis", &Joystick::update_for_analysis, + bp::args("des_vel_analysis", "N_analysis", "N_steady"), "Set test velocity profile.\n") - .def("get_p_ref", &Joystick::getPRef, "Get Reference Position") - .def("get_v_ref", &Joystick::getVRef, "Get Reference Velocity") - .def("get_joystick_code", &Joystick::getJoystickCode, "Get Joystick Code") - .def("get_start", &Joystick::getStart, "Get Joystick Start") - .def("get_stop", &Joystick::getStop, "Get Joystick Stop") - .def("get_cross", &Joystick::getCross, "Get Joystick Cross status") - .def("get_circle", &Joystick::getCircle, "Get Joystick Circle status") - .def("get_triangle", &Joystick::getTriangle, "Get Joystick Triangle status") - .def("get_square", &Joystick::getSquare, "Get Joystick Square status") - .def("get_l1", &Joystick::getL1, "Get Joystick L1 status") - .def("get_r1", &Joystick::getR1, "Get Joystick R1 status"); + .def("get_p_ref", &Joystick::getPRef, "Get Reference Position") + .def("get_v_ref", &Joystick::getVRef, "Get Reference Velocity") + .def("get_joystick_code", &Joystick::getJoystickCode, "Get Joystick Code") + .def("get_start", &Joystick::getStart, "Get Joystick Start") + .def("get_stop", &Joystick::getStop, "Get Joystick Stop") + .def("get_cross", &Joystick::getCross, "Get Joystick Cross status") + .def("get_circle", &Joystick::getCircle, "Get Joystick Circle status") + .def("get_triangle", &Joystick::getTriangle, "Get Joystick Triangle status") + .def("get_square", &Joystick::getSquare, "Get Joystick Square status") + .def("get_l1", &Joystick::getL1, "Get Joystick L1 status") + .def("get_r1", &Joystick::getR1, "Get Joystick R1 status") + .def("get_profile_duration", &Joystick::getProfileDuration, "Get duration of current velocity profile") + .def("get_last_reached_velocity", &Joystick::getLastReachedVelocity, bp::args("k"), + "Get last reached velocity.\n"); } static void expose() { bp::class_<Joystick>("Joystick", bp::no_init).def(JoystickVisitor<Joystick>()); } diff --git a/python/Params.cpp b/python/Params.cpp index d8db929fda3c286d1fedfb67d3d57c175e7a92c4..60104fbdaede20906302a7ccbaf2d2d1ca5461cc 100644 --- a/python/Params.cpp +++ b/python/Params.cpp @@ -8,7 +8,10 @@ struct ParamsVisitor : public bp::def_visitor<ParamsVisitor<Params>> { void visit(PyClassParams& cl) const { cl.def(bp::init<>(bp::arg(""), "Default constructor.")) - .def("initialize", &Params::initialize, bp::args("file_path"), "Initialize Params from Python.\n") + .def("read_yaml", &Params::read_yaml, bp::args("file_path"), + "Read yaml file to retrieve parameters from Python.\n") + .def("convert_gait_vec", &Params::convert_gait_vec, "Convert gait vector into matrix.\n") + .def("initialize", &Params::initialize, "Initialize Params from Python.\n") // Read Params from Python .def_readwrite("config_file", &Params::config_file) @@ -32,6 +35,7 @@ struct ParamsVisitor : public bp::def_visitor<ParamsVisitor<Params>> { .def_readwrite("Kff_main", &Params::Kff_main) .def_readwrite("osqp_w_states", &Params::osqp_w_states) .def_readwrite("osqp_w_forces", &Params::osqp_w_forces) + .def_readwrite("gait_vec", &Params::gait_vec) .def_readonly("gait", &Params::get_gait) .def_readonly("t_switch", &Params::get_t_switch) .def_readonly("v_switch", &Params::get_v_switch) diff --git a/python/StatePlanner.cpp b/python/StatePlanner.cpp index 40a04612c94cd6be42ce8c33fccc1fec34aa6a05..3958ff39e4cfbc5ac428c514cecdb6e184885c65 100644 --- a/python/StatePlanner.cpp +++ b/python/StatePlanner.cpp @@ -9,9 +9,10 @@ struct StatePlannerVisitor : public bp::def_visitor<StatePlannerVisitor<StatePla cl.def(bp::init<>(bp::arg(""), "Default constructor.")) .def("get_reference_states", &StatePlanner::getReferenceStates, "Get xref matrix.\n") - .def("initialize", &StatePlanner::initialize, bp::args("params"), "Initialize StatePlanner from Python.\n") - .def("compute_reference_states", &StatePlanner::computeReferenceStates, bp::args("q", "v", "b_vref"), - "Run StatePlanner from Python.\n"); + .def("initialize", &StatePlanner::initialize, bp::args("params", "gaitIn"), + "Initialize StatePlanner from Python.\n") + .def("compute_reference_states", &StatePlanner::computeReferenceStates, + bp::args("k", "q", "v", "b_vref", "fsteps"), "Run StatePlanner from Python.\n"); } static void expose() { diff --git a/python/WbcWrapper.cpp b/python/WbcWrapper.cpp index 7a47b75ff174c55bf627bfdd4c7e3e12afd32632..05cd469b7e5448de80bfeebd8356d0931aaab9ff 100644 --- a/python/WbcWrapper.cpp +++ b/python/WbcWrapper.cpp @@ -23,6 +23,8 @@ struct WbcWrapperVisitor : public bp::def_visitor<WbcWrapperVisitor<WbcWrapper>> .def_readonly("vdes", &WbcWrapper::get_vdes) .def_readonly("tau_ff", &WbcWrapper::get_tau_ff) .def_readonly("ddq_cmd", &WbcWrapper::get_ddq_cmd) + .def_readonly("dq_cmd", &WbcWrapper::get_dq_cmd) + .def_readonly("q_cmd", &WbcWrapper::get_q_cmd) .def_readonly("f_with_delta", &WbcWrapper::get_f_with_delta) .def_readonly("ddq_with_delta", &WbcWrapper::get_ddq_with_delta) .def_readonly("nle", &WbcWrapper::get_nle)