Skip to content

Commit

Permalink
[core/python] Expose more convenience getters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis Duburcq committed Mar 22, 2024
1 parent 0c41abe commit d049eff
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/include/jiminy/core/engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ namespace jiminy
GenericConfig getOptions() const noexcept;
void setOptions(const GenericConfig & engineOptions);
bool getIsTelemetryConfigured() const;
std::shared_ptr<Robot> & getRobot(const std::string & robotName);
std::shared_ptr<Robot> 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;
Expand Down
2 changes: 1 addition & 1 deletion core/src/engine/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2776,7 +2776,7 @@ namespace jiminy
return std::distance(robots_.begin(), robotIt);
}

std::shared_ptr<Robot> & Engine::getRobot(const std::string & robotName)
std::shared_ptr<Robot> Engine::getRobot(const std::string & robotName)
{
std::ptrdiff_t robotIndex = getRobotIndex(robotName);
return robots_[robotIndex];
Expand Down
5 changes: 4 additions & 1 deletion python/jiminy_pywrap/src/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,10 @@ namespace jiminy::python
.def("get_options", &Engine::getOptions)

.DEF_READONLY_WITH_POLICY(
"robots", &Engine::robots_, bp::return_value_policy<result_converter<true>>())
"robots", &Engine::robots_, bp::return_value_policy<result_converter<false>>())
.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",
Expand Down

0 comments on commit d049eff

Please sign in to comment.