1#include "state_representation_bindings.h"
3#include <state_representation/State.hpp>
6void state_type(py::module_& m) {
7 py::enum_<StateType>(m,
"StateType")
8 .value(
"NONE", StateType::NONE)
9 .value(
"STATE", StateType::STATE)
10 .value(
"SPATIAL_STATE", StateType::SPATIAL_STATE)
11 .value(
"CARTESIAN_STATE", StateType::CARTESIAN_STATE)
12 .value(
"CARTESIAN_POSE", StateType::CARTESIAN_POSE)
13 .value(
"CARTESIAN_TWIST", StateType::CARTESIAN_TWIST)
14 .value(
"CARTESIAN_ACCELERATION", StateType::CARTESIAN_ACCELERATION)
15 .value(
"CARTESIAN_WRENCH", StateType::CARTESIAN_WRENCH)
16 .value(
"JOINT_STATE", StateType::JOINT_STATE)
17 .value(
"JOINT_POSITIONS", StateType::JOINT_POSITIONS)
18 .value(
"JOINT_VELOCITIES", StateType::JOINT_VELOCITIES)
19 .value(
"JOINT_ACCELERATIONS", StateType::JOINT_ACCELERATIONS)
20 .value(
"JOINT_TORQUES", StateType::JOINT_TORQUES)
21 .value(
"JACOBIAN", StateType::JACOBIAN)
22 .value(
"PARAMETER", StateType::PARAMETER)
23 .value(
"GEOMETRY_SHAPE", StateType::GEOMETRY_SHAPE)
24 .value(
"GEOMETRY_ELLIPSOID", StateType::GEOMETRY_ELLIPSOID)
25 .value(
"TRAJECTORY", StateType::TRAJECTORY)
29void state(py::module_& m) {
30 py::class_<State, std::shared_ptr<State>> c(m,
"State");
32 c.def(py::init(),
"Empty constructor");
33 c.def(py::init<const StateType&>(),
"Constructor only specifying the type of the state from the StateType enumeration",
"type"_a);
34 c.def(py::init<const StateType&, const std::string&, const bool&>(),
"Constructor with name specification",
"type"_a,
"name"_a,
"empty"_a=
true);
35 c.def(py::init<const State&>(),
"Copy constructor from another State",
"state"_a);
39 c.def(
"set_empty", &
State::set_empty,
"Setter of the empty attribute",
"empty"_a=
true);
40 c.def(
"set_filled", &
State::set_filled,
"Setter of the empty attribute to false and also reset the timestamp");
47 c.def(
"is_deprecated", &State::is_deprecated<std::micro>,
"Check if the state is deprecated given a certain time delay with microsecond precision");
49 c.def(
"is_compatible", &
State::is_compatible,
"Check if the state is compatible for operations with the state given as argument",
"state"_a);
52 c.def(
"__copy__", [](
const State &state) {
55 c.def(
"__deepcopy__", [](
const State &state, py::dict) {
58 c.def(
"__repr__", [](
const State& state) {
59 std::stringstream buffer;
63 c.def(
"__bool__", [](
const State& state) {
65 }, py::is_operator());
68void bind_state(py::module_& m) {
Abstract class to represent a state.
void reset_timestamp()
Reset the timestamp attribute to now.
virtual void initialize()
Initialize the State to a zero value.
const std::string & get_name() const
Getter of the name as const reference.
virtual void set_name(const std::string &name)
Setter of the name.
void set_timestamp(const std::chrono::time_point< std::chrono::steady_clock > &timepoint)
Setter of the timestamp attribute.
const StateType & get_type() const
Getter of the type attribute.
void set_filled()
Setter of the empty attribute to false and also reset the timestamp.
virtual bool is_compatible(const State &state) const
Check if the state is compatible for operations with the state given as argument.
const std::chrono::time_point< std::chrono::steady_clock > & get_timestamp() const
Getter of the timestamp attribute.
bool is_empty() const
Getter of the empty attribute.
void set_empty(bool empty=true)
Setter of the empty attribute.