Control Libraries 7.4.0
Loading...
Searching...
No Matches
bind_joint_controllers.cpp
1#include "controllers_bindings.hpp"
2
3#include <controllers/ControllerFactory.hpp>
4#include <controllers/IController.hpp>
5#include <robot_model/Model.hpp>
6#include <state_representation/space/joint/JointState.hpp>
7
8#include "py_controller.hpp"
9
10using namespace state_representation;
11using namespace py_parameter;
12
13void joint_controller(py::module_& m) {
14 py::object parameter_map = py::module_::import("state_representation").attr("ParameterMap");
15 py::class_<IController<JointState>, std::shared_ptr<IController<JointState>>, PyController<JointState>> c(m, "IJointController", parameter_map);
16
17 c.def(
18 "compute_command", py::overload_cast<const JointState&, const JointState&>(&IController<JointState>::compute_command),
19 "Compute the command output based on the commanded state and a feedback state.", "command_state"_a, "feedback_state"_a);
20
21 c.def("get_robot_model", &IController<JointState>::get_robot_model, "Get the robot model associated with the controller.");
22 c.def("set_robot_model", &IController<JointState>::set_robot_model, "Set the robot model associated with the controller.", "robot_model"_a);
23}
24
25void bind_joint_controllers(py::module_& m) {
26 joint_controller(m);
27
28 m.def("create_joint_controller", [](CONTROLLER_TYPE type, const std::list<ParameterContainer>& parameters, unsigned int dimensions = 6) -> py::object {
29 return py::cast(JointControllerFactory::create_controller(type, container_to_interface_ptr_list(parameters), dimensions));
30 }, "Create a controller of the desired type with initial parameters.", "type"_a, "parameters"_a, "dimensions"_a = int(6));
31
32 m.def("create_joint_controller", [](CONTROLLER_TYPE type, unsigned int dimensions = 6) -> py::object {
33 return py::cast(JointControllerFactory::create_controller(type, std::list<std::shared_ptr<ParameterInterface>>(), dimensions));
34 }, "Create a controller of the desired type.", "type"_a, "dimensions"_a = int(6));
35
36 m.def("create_joint_controller", [](CONTROLLER_TYPE type, const std::list<ParameterContainer>& parameters, const robot_model::Model& robot_model) -> py::object {
37 return py::cast(JointControllerFactory::create_controller(type, container_to_interface_ptr_list(parameters), robot_model));
38 }, "Create a controller of the desired type with initial parameters and an associated robot model.", "type"_a, "parameters"_a, "robot_model"_a);
39
40 m.def("create_joint_controller", [](CONTROLLER_TYPE type, const robot_model::Model& robot_model) -> py::object {
41 return py::cast(JointControllerFactory::create_controller(type, std::list<std::shared_ptr<ParameterInterface>>(), robot_model));
42 }, "Create a controller of the desired type with an associated robot model.", "type"_a, "robot_model"_a);
43}
static std::shared_ptr< IController< S > > create_controller(CONTROLLER_TYPE type, unsigned int dimensions=6)
Create a controller of the desired type.
Abstract class to define a controller in a desired state type, such as joint or Cartesian spaces.
The Model class is a wrapper around pinocchio dynamic computation library with state_representation e...
Definition Model.hpp:62
CONTROLLER_TYPE
Enumeration of the implemented controllers.
Robot kinematics and dynamics.
Core state variables and objects.