1#include "state_representation_bindings.hpp" 
    3#include <state_representation/DigitalIOState.hpp> 
    4#include <state_representation/AnalogIOState.hpp> 
    7void digital_io_state(py::module_& m) {
 
    8  py::class_<DigitalIOState, std::shared_ptr<DigitalIOState>, 
State> c(m, 
"DigitalIOState");
 
   10  c.def(py::init(), 
"Empty constructor for an digital IO state");
 
   11  c.def(py::init<const std::string&, unsigned int>(), 
"Constructor with name and number of digital IOs provided", 
"name"_a, 
"nb_ios"_a=0);
 
   12  c.def(py::init<
const std::string&, 
const std::vector<std::string>&>(), 
"Constructor with name and list of digital IO names provided", 
"name"_a, 
"io_names"_a);
 
   13  c.def(py::init<const DigitalIOState&>(), 
"Copy constructor of an digital IO state", 
"state"_a);
 
   15  c.def_static(
"Zero", py::overload_cast<const std::string&, unsigned int>(&
DigitalIOState::Zero), 
"Constructor for a zero digital IO state", 
"name"_a, 
"nb_ios"_a);
 
   16  c.def_static(
"Zero", py::overload_cast<
const std::string&, 
const std::vector<std::string>&>(&
DigitalIOState::Zero), 
"Constructor for a zero digital IO state", 
"name"_a, 
"io_names"_a);
 
   17  c.def_static(
"Random", py::overload_cast<const std::string&, unsigned int>(&
DigitalIOState::Random), 
"Constructor for a random digital IO state", 
"name"_a, 
"nb_ios"_a);
 
   18  c.def_static(
"Random", py::overload_cast<
const std::string&, 
const std::vector<std::string>&>(&
DigitalIOState::Random), 
"Constructor for a random digital IO state", 
"name"_a, 
"io_names"_a);
 
   20  c.def(
"get_size", &DigitalIOState::get_size, 
"Getter of the size from the attributes.");
 
   21  c.def(
"get_names", &DigitalIOState::get_names, 
"Getter of the names attribute.");
 
   22  c.def(
"get_joint_index", &DigitalIOState::get_io_index, 
"Get IO index by the name of the IO, if it exists", 
"io_name"_a);
 
   23  c.def(
"set_names", py::overload_cast<unsigned int>(&DigitalIOState::set_names), 
"Setter of the names from the number of IOs", 
"nb_ios"_a);
 
   24  c.def(
"set_names", py::overload_cast<
const std::vector<std::string>&>(&DigitalIOState::set_names), 
"Setter of the names from a list of IO names", 
"names"_a);
 
   26  c.def(
"get_value", [](
const DigitalIOState& state, 
const std::string& name) { 
return state.get_value(name); }, 
"Get the value of a digital IO by its name, if it exists", 
"name"_a);
 
   27  c.def(
"get_value", [](
const DigitalIOState& state, 
unsigned int io_index) { 
return state.get_value(io_index); }, 
"Get the value of a digital IO by its index, if it exists", 
"io_index"_a);
 
   28  c.def(
"set_value", py::overload_cast<bool, const std::string&>(&DigitalIOState::set_value), 
"Set the value of a digital IO by its name", 
"value"_a, 
"name"_a);
 
   29  c.def(
"set_value", py::overload_cast<bool, unsigned int>(&DigitalIOState::set_value), 
"Set the value of a digital IO by its index", 
"value"_a, 
"io_index"_a);
 
   31  c.def(
"is_true", [](
const DigitalIOState& state, 
const std::string& name) { 
return state.is_true(name); }, 
"Check if a digital IO is true by its name, if it exists", 
"name"_a);
 
   32  c.def(
"is_true", [](
const DigitalIOState& state, 
unsigned int io_index) { 
return state.is_true(io_index); }, 
"Check if a digital IO is true by its index, if it exists", 
"io_index"_a);
 
   33  c.def(
"is_false", [](
const DigitalIOState& state, 
const std::string& name) { 
return state.is_false(name); }, 
"Check if a digital IO is false by its name, if it exists", 
"name"_a);
 
   34  c.def(
"is_false", [](
const DigitalIOState& state, 
unsigned int io_index) { 
return state.is_false(io_index); }, 
"Check if a digital IO is false by its index, if it exists", 
"io_index"_a);
 
   35  c.def(
"set_true", py::overload_cast<const std::string&>(&
DigitalIOState::set_true), 
"Set the a digital IO to true by its name", 
"name"_a);
 
   36  c.def(
"set_true", py::overload_cast<unsigned int>(&
DigitalIOState::set_true), 
"Set the a digital IO to true by its index", 
"io_index"_a);
 
   37  c.def(
"set_false", py::overload_cast<const std::string&>(&
DigitalIOState::set_false), 
"Set the a digital IO to false by its name", 
"name"_a);
 
   38  c.def(
"set_false", py::overload_cast<unsigned int>(&
DigitalIOState::set_false), 
"Set the a digital IO to false by its index", 
"io_index"_a);
 
   42  c.def(
"data", &DigitalIOState::data, 
"Returns the values of the IO state as an Eigen vector");
 
   43  c.def(
"array", &DigitalIOState::array, 
"Returns the values of the IO state an Eigen array");
 
   44  c.def(
"set_data", py::overload_cast<
const Eigen::Vector<bool, Eigen::Dynamic>&>(&DigitalIOState::set_data), 
"Set the values of the IO state from a single Eigen vector", 
"data"_a);
 
   45  c.def(
"set_data", py::overload_cast<
const std::vector<bool>&>(&DigitalIOState::set_data), 
"Set the values of the IO state from a single list", 
"data"_a);
 
   47  c.def(
"to_list", &DigitalIOState::to_std_vector, 
"Return the IO values as a list");
 
   56    std::stringstream buffer;
 
   62void analog_io_state(py::module_& m) {
 
   63  py::class_<AnalogIOState, std::shared_ptr<AnalogIOState>, 
State> c(m, 
"AnalogIOState");
 
   65  c.def(py::init(), 
"Empty constructor for an analog IO state");
 
   66  c.def(py::init<const std::string&, unsigned int>(), 
"Constructor with name and number of analog IOs provided", 
"name"_a, 
"nb_ios"_a=0);
 
   67  c.def(py::init<
const std::string&, 
const std::vector<std::string>&>(), 
"onstructor with name and list of analog IO names provided", 
"name"_a, 
"io_names"_a);
 
   68  c.def(py::init<const AnalogIOState&>(), 
"Copy constructor of an analog IO state", 
"state"_a);
 
   70  c.def_static(
"Zero", py::overload_cast<const std::string&, unsigned int>(&
AnalogIOState::Zero), 
"Constructor for a zero analog IO state", 
"name"_a, 
"nb_ios"_a);
 
   71  c.def_static(
"Zero", py::overload_cast<
const std::string&, 
const std::vector<std::string>&>(&
AnalogIOState::Zero), 
"Constructor for a zero analog IO state", 
"name"_a, 
"io_names"_a);
 
   72  c.def_static(
"Random", py::overload_cast<const std::string&, unsigned int>(&
AnalogIOState::Random), 
"Constructor for a random analog IO state", 
"name"_a, 
"nb_ios"_a);
 
   73  c.def_static(
"Random", py::overload_cast<
const std::string&, 
const std::vector<std::string>&>(&
AnalogIOState::Random), 
"Constructor for a random analog IO state", 
"name"_a, 
"io_names"_a);
 
   75  c.def(
"get_size", &AnalogIOState::get_size, 
"Getter of the size from the attributes.");
 
   76  c.def(
"get_names", &AnalogIOState::get_names, 
"Getter of the names attribute.");
 
   77  c.def(
"get_joint_index", &AnalogIOState::get_io_index, 
"Get IO index by the name of the IO, if it exists", 
"io_name"_a);
 
   78  c.def(
"set_names", py::overload_cast<unsigned int>(&AnalogIOState::set_names), 
"Setter of the names from the number of IOs", 
"nb_ios"_a);
 
   79  c.def(
"set_names", py::overload_cast<
const std::vector<std::string>&>(&AnalogIOState::set_names), 
"Setter of the names from a list of IO names", 
"names"_a);
 
   81  c.def(
"get_value", [](
const AnalogIOState& state, 
const std::string& name) { 
return state.get_value(name); }, 
"Get the value of an analog IO by its name, if it exists", 
"name"_a);
 
   82  c.def(
"get_value", [](
const AnalogIOState& state, 
unsigned int io_index) { 
return state.get_value(io_index); }, 
"Get the value of an analog IO by its index, if it exists", 
"io_index"_a);
 
   83  c.def(
"set_value", py::overload_cast<double, const std::string&>(&AnalogIOState::set_value), 
"Set the value of an analog IO by its name", 
"value"_a, 
"name"_a);
 
   84  c.def(
"set_value", py::overload_cast<double, unsigned int>(&AnalogIOState::set_value), 
"Set the value of an analog IO by its index", 
"value"_a, 
"io_index"_a);
 
   88  c.def(
"data", &AnalogIOState::data, 
"Returns the values of the IO state as an Eigen vector");
 
   89  c.def(
"array", &AnalogIOState::array, 
"Returns the values of the IO state an Eigen array");
 
   90  c.def(
"set_data", py::overload_cast<const Eigen::VectorXd&>(&AnalogIOState::set_data), 
"Set the values of the IO state from a single Eigen vector", 
"data"_a);
 
   91  c.def(
"set_data", py::overload_cast<
const std::vector<double>&>(&AnalogIOState::set_data), 
"Set the values of the IO state from a single list", 
"data"_a);
 
   93  c.def(
"to_list", &AnalogIOState::to_std_vector, 
"Return the IO values as a list");
 
   98  c.def(
"__deepcopy__", [](
const AnalogIOState &state, py::dict) {
 
  102    std::stringstream buffer;
 
  108void bind_io_state(py::module_& m) {
 
static AnalogIOState Zero(const std::string &name, unsigned int nb_ios)
Constructor for a zero analog IO state.
 
void set_zero()
Set the analog IO state to zero data.
 
AnalogIOState copy() const
Return a copy of the analog IO state.
 
static AnalogIOState Random(const std::string &name, unsigned int nb_ios)
Constructor for an analog IO state with random data.
 
void set_false()
Set all digital IOs false.
 
static DigitalIOState Zero(const std::string &name, unsigned int nb_ios)
Constructor for a zero digital IO state.
 
DigitalIOState copy() const
Return a copy of the digital IO state.
 
void set_true(const std::string &name)
Set the a digital IO to true by its name.
 
static DigitalIOState Random(const std::string &name, unsigned int nb_ios)
Constructor for a digital IO state with random data.
 
Abstract class to represent a state.