RobotFrame.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2022 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 
7 #include <mc_rbdyn/Frame.h>
8 
9 namespace mc_rbdyn
10 {
11 
21 struct MC_RBDYN_DLLAPI RobotFrame : public mc_rtc::shared<RobotFrame, Frame>
22 {
23 protected:
25  {
26  };
27 
28 public:
29  friend struct Robot;
30 
43  RobotFrame(NewRobotFrameToken, const std::string & name, Robot & robot, const std::string & body);
44 
58  RobotFrame(NewRobotFrameToken, const std::string & name, RobotFrame & parent, sva::PTransformd X_p_f, bool baked);
59 
61  inline const Robot & robot() const noexcept { return robot_; }
62 
64  inline Robot & robot() noexcept { return robot_; }
65 
67  inline unsigned int bodyMbcIndex() const noexcept { return bodyMbcIdx_; }
68 
70  const std::string & body() const noexcept;
71 
73  sva::PTransformd position() const noexcept final;
74 
76  sva::MotionVecd velocity() const noexcept final;
77 
79  inline const sva::PTransformd & X_p_f() const noexcept { return position_; }
80 
82  sva::PTransformd X_b_f() const noexcept;
83 
91  inline RobotFrame & X_p_f(sva::PTransformd pt) noexcept
92  {
93  position_ = pt;
94  return *this;
95  }
96 
98  inline bool hasForceSensor() const noexcept { return sensor_; }
99 
104  const ForceSensor & forceSensor() const;
105 
110  sva::ForceVecd wrench() const;
111 
120  Eigen::Vector2d cop(double min_pressure = 0.5) const;
121 
130  Eigen::Vector3d copW(double min_pressure = 0.5) const;
131 
140  RobotFramePtr makeFrame(const std::string & name, const sva::PTransformd & X_p_f, bool baked = false);
141 
143  inline mc_tvm::RobotFrame & tvm_frame() const
144  {
146  return reinterpret_cast<mc_tvm::RobotFrame &>(Frame::tvm_frame());
147  }
148 
149 protected:
153  unsigned int bodyMbcIdx_;
155  const ForceSensor * sensor_ = nullptr;
156 
157  void init_tvm_frame() const final;
158 
160  void resetForceSensor() noexcept;
161 };
162 
163 } // namespace mc_rbdyn
#define MC_RBDYN_DLLAPI
Definition: api.h:50
Definition: generic_gripper.h:15
std::shared_ptr< RobotFrame > RobotFramePtr
Definition: fwd.h:24
Definition: ForceSensor.h:20
Definition: Frame.h:31
mc_tvm::Frame & tvm_frame() const
Definition: Frame.h:126
Definition: RobotFrame.h:25
Definition: RobotFrame.h:22
Robot & robot() noexcept
Definition: RobotFrame.h:64
bool hasForceSensor() const noexcept
Definition: RobotFrame.h:98
RobotFrame(NewRobotFrameToken, const std::string &name, RobotFrame &parent, sva::PTransformd X_p_f, bool baked)
sva::PTransformd X_b_f() const noexcept
RobotFrame(NewRobotFrameToken, const std::string &name, Robot &robot, const std::string &body)
const Robot & robot() const noexcept
Definition: RobotFrame.h:61
Eigen::Vector2d cop(double min_pressure=0.5) const
Eigen::Vector3d copW(double min_pressure=0.5) const
void init_tvm_frame() const final
Robot & robot_
Definition: RobotFrame.h:151
const ForceSensor & forceSensor() const
sva::ForceVecd wrench() const
const std::string & body() const noexcept
unsigned int bodyMbcIndex() const noexcept
Definition: RobotFrame.h:67
unsigned int bodyMbcIdx_
Definition: RobotFrame.h:153
mc_tvm::RobotFrame & tvm_frame() const
Definition: RobotFrame.h:143
RobotFramePtr makeFrame(const std::string &name, const sva::PTransformd &X_p_f, bool baked=false)
Definition: Robot.h:63
Definition: shared.h:28
Definition: RobotFrame.h:28