From d049efff6e1d2776c6ce0ab4f2a5bf65a3308f4e Mon Sep 17 00:00:00 2001 From: Alexis Duburcq Date: Fri, 22 Mar 2024 15:51:45 +0100 Subject: [PATCH] [core/python] Expose more convenience getters. --- core/include/jiminy/core/engine/engine.h | 2 +- core/src/engine/engine.cc | 2 +- python/jiminy_pywrap/src/engine.cc | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/include/jiminy/core/engine/engine.h b/core/include/jiminy/core/engine/engine.h index b6bc402654..e6736ba64c 100644 --- a/core/include/jiminy/core/engine/engine.h +++ b/core/include/jiminy/core/engine/engine.h @@ -664,7 +664,7 @@ namespace jiminy GenericConfig getOptions() const noexcept; void setOptions(const GenericConfig & engineOptions); bool getIsTelemetryConfigured() const; - std::shared_ptr & getRobot(const std::string & robotName); + std::shared_ptr getRobot(const std::string & robotName); std::ptrdiff_t getRobotIndex(const std::string & robotName) const; const RobotState & getRobotState(const std::string & robotName) const; const StepperState & getStepperState() const; diff --git a/core/src/engine/engine.cc b/core/src/engine/engine.cc index 8cf54b877b..fe4c4a86d2 100644 --- a/core/src/engine/engine.cc +++ b/core/src/engine/engine.cc @@ -2776,7 +2776,7 @@ namespace jiminy return std::distance(robots_.begin(), robotIt); } - std::shared_ptr & Engine::getRobot(const std::string & robotName) + std::shared_ptr Engine::getRobot(const std::string & robotName) { std::ptrdiff_t robotIndex = getRobotIndex(robotName); return robots_[robotIndex]; diff --git a/python/jiminy_pywrap/src/engine.cc b/python/jiminy_pywrap/src/engine.cc index cfdedf81c9..d76a409a26 100644 --- a/python/jiminy_pywrap/src/engine.cc +++ b/python/jiminy_pywrap/src/engine.cc @@ -770,7 +770,10 @@ namespace jiminy::python .def("get_options", &Engine::getOptions) .DEF_READONLY_WITH_POLICY( - "robots", &Engine::robots_, bp::return_value_policy>()) + "robots", &Engine::robots_, bp::return_value_policy>()) + .def("get_robot", &Engine::getRobot, (bp::arg("self"), "robot_name")) + .def("get_robot_index", &Engine::getRobotIndex, (bp::arg("self"), "robot_name")) + .def("get_robot_state", &Engine::getRobotState, (bp::arg("self"), "robot_name")) .ADD_PROPERTY_GET("robot_states", &internal::engine::getRobotStates) .ADD_PROPERTY_GET_WITH_POLICY("stepper_state",