Control Libraries 7.4.0
Loading...
Searching...
No Matches
bind_cartesian_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/Jacobian.hpp>
7#include <state_representation/space/cartesian/CartesianState.hpp>
8#include <state_representation/space/joint/JointPositions.hpp>
9#include <state_representation/space/joint/JointState.hpp>
10
11#include "py_controller.hpp"
12
13using namespace state_representation;
14using namespace py_parameter;
15
16void cartesian_controller(py::module_& m) {
17 py::object parameter_map = py::module_::import("state_representation").attr("ParameterMap");
18 py::class_<IController<CartesianState>, std::shared_ptr<IController<CartesianState>>, PyController<CartesianState>> c(m, "ICartesianController", parameter_map);
19
20 c.def(
21 "compute_command", py::overload_cast<const CartesianState&, const CartesianState&>(&IController<CartesianState>::compute_command),
22 "Compute the command output based on the commanded state and a feedback state.", "command_state"_a, "feedback_state"_a);
23 c.def(
24 "compute_command", py::overload_cast<const CartesianState&, const CartesianState&, const Jacobian&>(&IController<CartesianState>::compute_command),
25 "Compute the command output in joint space from command and feedback states in task space.", "command_state"_a, "feedback_state"_a, "jacobian"_a);
26 c.def(
27 "compute_command", py::overload_cast<const CartesianState&, const CartesianState&, const JointPositions&, const std::string&>(&IController<CartesianState>::compute_command),
28 "Compute the command output in joint space from command and feedback states in task space.", "command_state"_a, "feedback_state"_a, "joint_positions"_a, "frame"_a = std::string(""));
29
30 c.def("get_robot_model", &IController<CartesianState>::get_robot_model, "Get the robot model associated with the controller.");
31 c.def("set_robot_model", &IController<CartesianState>::set_robot_model, "Set the robot model associated with the controller.", "robot_model"_a);
32}
33
34void bind_cartesian_controllers(py::module_& m) {
35 cartesian_controller(m);
36
37 m.def("create_cartesian_controller", [](CONTROLLER_TYPE type, const std::list<ParameterContainer>& parameters) -> py::object {
38 return py::cast(CartesianControllerFactory::create_controller(type, container_to_interface_ptr_list(parameters)));
39 }, "Create a controller of the desired type with initial parameters.", "type"_a, "parameters"_a);
40
41 m.def("create_cartesian_controller", [](CONTROLLER_TYPE type) -> py::object {
42 return py::cast(CartesianControllerFactory::create_controller(type, std::list<std::shared_ptr<ParameterInterface>>()));
43 }, "Create a controller of the desired type.", "type"_a);
44
45 m.def("create_cartesian_controller", [](CONTROLLER_TYPE type, const std::list<ParameterContainer>& parameters, const robot_model::Model& robot_model) -> py::object {
46 return py::cast(CartesianControllerFactory::create_controller(type, container_to_interface_ptr_list(parameters), robot_model));
47 }, "Create a controller of the desired type with initial parameters and an associated robot model.", "type"_a, "parameters"_a, "robot_model"_a);
48
49 m.def("create_cartesian_controller", [](CONTROLLER_TYPE type, const robot_model::Model& robot_model) -> py::object {
50 return py::cast(CartesianControllerFactory::create_controller(type, std::list<std::shared_ptr<ParameterInterface>>(), robot_model));
51 }, "Create a controller of the desired type with an associated robot model.", "type"_a, "robot_model"_a);
52}
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.