Flexiv RDK APIs  2.1
model.hpp
Go to the documentation of this file.
1 
6 #ifndef FLEXIV_RDK_MODEL_HPP_
7 #define FLEXIV_RDK_MODEL_HPP_
8 
9 #include "robot.hpp"
10 #include <Eigen/Eigen>
11 #include <memory>
12 
13 namespace flexiv::rdk {
14 
19 struct IKParams
20 {
22  std::array<double, kPoseSize> cartesian_pose = {};
23 
25  std::vector<double> seed_q = {};
26 
28  bool free_orientation = false;
29 };
30 
35 struct IKResult
36 {
38  bool success = false;
39 
41  std::map<JointGroup, std::vector<double>> solved_q = {};
42 };
43 
48 class Model
49 {
50 public:
60  Model(const Robot& robot,
61  const Eigen::Vector3d& gravity_vector = Eigen::Vector3d(0.0, 0.0, -9.81));
62  virtual ~Model();
63 
68  std::vector<std::string> link_names() const;
69 
74  std::vector<std::string> joint_names() const;
75 
87  void Reload();
88 
98  void Update(const std::vector<double>& full_q, const std::vector<double>& full_dq);
99 
100  //========================================== DYNAMICS ==========================================
111  Eigen::MatrixXd dJ(const std::string& link_name);
112 
119  Eigen::MatrixXd M();
120 
127  Eigen::MatrixXd C();
128 
135  Eigen::VectorXd g();
136 
144  Eigen::VectorXd c();
145 
146  //========================================= KINEMATICS =========================================
155  Eigen::MatrixXd J(const std::string& link_name);
156 
166  Eigen::Isometry3d T(const std::string& link_name);
167 
182  void SyncURDF(const std::string& template_urdf_path);
183 
195  size_t SyncKinematicsYAML(const std::string& template_yaml_path);
196 
208  IKResult SolveConstrainedIK(const std::map<JointGroup, IKParams>& ik_params_by_group);
209 
222  std::map<JointGroup, std::pair<double, double>> configuration_score() const;
223 
224  //======================================= MULTI-CONTACT ========================================
234  std::map<JointGroup, std::vector<Eigen::Vector3d>> multi_contact_forces() const;
235 
245  std::map<JointGroup, std::vector<Eigen::Vector3d>> multi_contact_positions() const;
246 
247 private:
248  class Impl;
249  std::unique_ptr<Impl> pimpl_;
250 };
251 
252 } /* namespace flexiv::rdk */
253 
254 #endif /* FLEXIV_RDK_MODEL_HPP_ */
Interface to obtain certain model data of the robot, including kinematics and dynamics.
Definition: model.hpp:49
size_t SyncKinematicsYAML(const std::string &template_yaml_path)
[Blocking] Sync the actual kinematic parameters of the connected robot into the template YAML file.
Eigen::MatrixXd J(const std::string &link_name)
[Non-blocking] Compute the Jacobian matrix at the specified frame w.r.t. world frame.
IKResult SolveConstrainedIK(const std::map< JointGroup, IKParams > &ik_params_by_group)
[Blocking] Solve constrained IK using one or more active joint groups.
std::vector< std::string > link_names() const
[Non-blocking] Names of all links in the robot model.
std::vector< std::string > joint_names() const
[Non-blocking] Names of all actuated joints in the robot model.
Model(const Robot &robot, const Eigen::Vector3d &gravity_vector=Eigen::Vector3d(0.0, 0.0, -9.81))
[Non-blocking] Instantiate the robot model interface.
std::map< JointGroup, std::vector< Eigen::Vector3d > > multi_contact_positions() const
[Non-blocking] Estimated multi-contact positions on each link of applicable joint groups,...
Eigen::VectorXd c()
[Non-blocking] Compute the Coriolis force vector in generalized coordinates, i.e. joint space.
Eigen::MatrixXd dJ(const std::string &link_name)
[Non-blocking] Compute the time derivative of Jacobian matrix at the specified frame w....
void Reload()
[Blocking] Reload (refresh) parameters of the robot model stored locally in this class using the late...
Eigen::Isometry3d T(const std::string &link_name)
[Non-blocking] Compute the transformation matrix of the specified frame w.r.t. world frame.
Eigen::VectorXd g()
[Non-blocking] Compute the gravity force vector in generalized coordinates, i.e. joint space.
void Update(const std::vector< double > &full_q, const std::vector< double > &full_dq)
[Non-blocking] Update the configuration (posture) of the locally-stored robot model so that the local...
std::map< JointGroup, std::pair< double, double > > configuration_score() const
[Blocking] Score of each joint group's current configuration (posture), calculated from the manipulab...
Eigen::MatrixXd M()
[Non-blocking] Compute the mass matrix in generalized coordinates, i.e. joint space.
std::map< JointGroup, std::vector< Eigen::Vector3d > > multi_contact_forces() const
[Non-blocking] Estimated multi-contact forces applied on each link of applicable joint groups,...
void SyncURDF(const std::string &template_urdf_path)
[Blocking] Sync the actual kinematic parameters of the connected robot into the template URDF file.
Eigen::MatrixXd C()
[Non-blocking] Compute the Coriolis/centripetal matrix in generalized coordinates,...
Main interface to control the robot, containing several function categories and background services.
Definition: robot.hpp:24
Per-joint-group IK input parameters for SolveConstrainedIK().
Definition: model.hpp:20
std::vector< double > seed_q
Definition: model.hpp:25
std::array< double, kPoseSize > cartesian_pose
Definition: model.hpp:22
Result from SolveConstrainedIK().
Definition: model.hpp:36
std::map< JointGroup, std::vector< double > > solved_q
Definition: model.hpp:41