Skip to content
Snippets Groups Projects
Commit f92bab14 authored by Pierre-Alexandre Leziart's avatar Pierre-Alexandre Leziart
Browse files

Rebase changes to python bindings from flying branch

parent 549bde6c
No related branches found
No related tags found
No related merge requests found
...@@ -21,8 +21,11 @@ struct FootTrajectoryGeneratorVisitor ...@@ -21,8 +21,11 @@ struct FootTrajectoryGeneratorVisitor
.def("update", &FootTrajectoryGenerator::update, bp::args("k", "targetFootstep"), .def("update", &FootTrajectoryGenerator::update, bp::args("k", "targetFootstep"),
"Compute target location of footsteps from Python.\n") "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_elapsed_durations", &FootTrajectoryGenerator::getT0s,
.def("get_phase_durations", &FootTrajectoryGenerator::getTswing, "Get the flying period of the feet.\n"); "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() { static void expose() {
......
...@@ -10,15 +10,21 @@ struct GaitVisitor : public bp::def_visitor<GaitVisitor<Gait>> { ...@@ -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_past_gait", &Gait::getPastGait, "Get past gait matrix.\n")
.def("get_gait_matrix", &Gait::getCurrentGait, "Get 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("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_new_step", &Gait::isNewPhase, "True if new phase of the gait.\n")
.def("is_static", &Gait::getIsStatic, "True if static 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("initialize", &Gait::initialize, bp::args("params"), "Initialize Gait from Python.\n")
.def("update", &Gait::update, bp::args("k", "k_mpc", "joystickCode"), .def("update", &Gait::update, bp::args("k", "k_mpc", "joystickCode"),
"Update current gait matrix from Python.\n") "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", .add_property("matrix",
bp::make_function(&Gait::getCurrentGait, bp::return_value_policy<bp::return_by_value>())); bp::make_function(&Gait::getCurrentGait, bp::return_value_policy<bp::return_by_value>()));
} }
......
...@@ -8,21 +8,28 @@ struct JoystickVisitor : public bp::def_visitor<JoystickVisitor<Joystick>> { ...@@ -8,21 +8,28 @@ struct JoystickVisitor : public bp::def_visitor<JoystickVisitor<Joystick>> {
void visit(PyClassJoystick& cl) const { void visit(PyClassJoystick& cl) const {
cl.def(bp::init<>(bp::arg(""), "Default constructor.")) 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_p_ref", &Joystick::getPRef, "Get Reference Position")
.def("get_v_ref", &Joystick::getVRef, "Get Reference Velocity") .def("get_v_ref", &Joystick::getVRef, "Get Reference Velocity")
.def("get_joystick_code", &Joystick::getJoystickCode, "Get Joystick Code") .def("get_joystick_code", &Joystick::getJoystickCode, "Get Joystick Code")
.def("get_start", &Joystick::getStart, "Get Joystick Start") .def("get_start", &Joystick::getStart, "Get Joystick Start")
.def("get_stop", &Joystick::getStop, "Get Joystick Stop") .def("get_stop", &Joystick::getStop, "Get Joystick Stop")
.def("get_cross", &Joystick::getCross, "Get Joystick Cross status") .def("get_cross", &Joystick::getCross, "Get Joystick Cross status")
.def("get_circle", &Joystick::getCircle, "Get Joystick Circle status") .def("get_circle", &Joystick::getCircle, "Get Joystick Circle status")
.def("get_triangle", &Joystick::getTriangle, "Get Joystick Triangle status") .def("get_triangle", &Joystick::getTriangle, "Get Joystick Triangle status")
.def("get_square", &Joystick::getSquare, "Get Joystick Square status") .def("get_square", &Joystick::getSquare, "Get Joystick Square status")
.def("get_l1", &Joystick::getL1, "Get Joystick L1 status") .def("get_l1", &Joystick::getL1, "Get Joystick L1 status")
.def("get_r1", &Joystick::getR1, "Get Joystick R1 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>()); } static void expose() { bp::class_<Joystick>("Joystick", bp::no_init).def(JoystickVisitor<Joystick>()); }
......
...@@ -8,7 +8,10 @@ struct ParamsVisitor : public bp::def_visitor<ParamsVisitor<Params>> { ...@@ -8,7 +8,10 @@ struct ParamsVisitor : public bp::def_visitor<ParamsVisitor<Params>> {
void visit(PyClassParams& cl) const { void visit(PyClassParams& cl) const {
cl.def(bp::init<>(bp::arg(""), "Default constructor.")) 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 // Read Params from Python
.def_readwrite("config_file", &Params::config_file) .def_readwrite("config_file", &Params::config_file)
...@@ -32,6 +35,7 @@ struct ParamsVisitor : public bp::def_visitor<ParamsVisitor<Params>> { ...@@ -32,6 +35,7 @@ struct ParamsVisitor : public bp::def_visitor<ParamsVisitor<Params>> {
.def_readwrite("Kff_main", &Params::Kff_main) .def_readwrite("Kff_main", &Params::Kff_main)
.def_readwrite("osqp_w_states", &Params::osqp_w_states) .def_readwrite("osqp_w_states", &Params::osqp_w_states)
.def_readwrite("osqp_w_forces", &Params::osqp_w_forces) .def_readwrite("osqp_w_forces", &Params::osqp_w_forces)
.def_readwrite("gait_vec", &Params::gait_vec)
.def_readonly("gait", &Params::get_gait) .def_readonly("gait", &Params::get_gait)
.def_readonly("t_switch", &Params::get_t_switch) .def_readonly("t_switch", &Params::get_t_switch)
.def_readonly("v_switch", &Params::get_v_switch) .def_readonly("v_switch", &Params::get_v_switch)
......
...@@ -9,9 +9,10 @@ struct StatePlannerVisitor : public bp::def_visitor<StatePlannerVisitor<StatePla ...@@ -9,9 +9,10 @@ struct StatePlannerVisitor : public bp::def_visitor<StatePlannerVisitor<StatePla
cl.def(bp::init<>(bp::arg(""), "Default constructor.")) cl.def(bp::init<>(bp::arg(""), "Default constructor."))
.def("get_reference_states", &StatePlanner::getReferenceStates, "Get xref matrix.\n") .def("get_reference_states", &StatePlanner::getReferenceStates, "Get xref matrix.\n")
.def("initialize", &StatePlanner::initialize, bp::args("params"), "Initialize StatePlanner from Python.\n") .def("initialize", &StatePlanner::initialize, bp::args("params", "gaitIn"),
.def("compute_reference_states", &StatePlanner::computeReferenceStates, bp::args("q", "v", "b_vref"), "Initialize StatePlanner from Python.\n")
"Run 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() { static void expose() {
......
...@@ -23,6 +23,8 @@ struct WbcWrapperVisitor : public bp::def_visitor<WbcWrapperVisitor<WbcWrapper>> ...@@ -23,6 +23,8 @@ struct WbcWrapperVisitor : public bp::def_visitor<WbcWrapperVisitor<WbcWrapper>>
.def_readonly("vdes", &WbcWrapper::get_vdes) .def_readonly("vdes", &WbcWrapper::get_vdes)
.def_readonly("tau_ff", &WbcWrapper::get_tau_ff) .def_readonly("tau_ff", &WbcWrapper::get_tau_ff)
.def_readonly("ddq_cmd", &WbcWrapper::get_ddq_cmd) .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("f_with_delta", &WbcWrapper::get_f_with_delta)
.def_readonly("ddq_with_delta", &WbcWrapper::get_ddq_with_delta) .def_readonly("ddq_with_delta", &WbcWrapper::get_ddq_with_delta)
.def_readonly("nle", &WbcWrapper::get_nle) .def_readonly("nle", &WbcWrapper::get_nle)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment