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
mc_rbdyn::RobotFrame::tvm_frame
mc_tvm::RobotFrame & tvm_frame() const
Definition: RobotFrame.h:143
mc_rbdyn::RobotFrame::bodyMbcIdx_
unsigned int bodyMbcIdx_
Definition: RobotFrame.h:153
mc_rbdyn::RobotFrame::robot
Robot & robot() noexcept
Definition: RobotFrame.h:64
mc_rtc::shared
Definition: shared.h:27
mc_rbdyn::Frame::tvm_frame
mc_tvm::Frame & tvm_frame() const
Definition: Frame.h:126
mc_rbdyn::RobotFrame::robot
const Robot & robot() const noexcept
Definition: RobotFrame.h:61
mc_rbdyn::RobotFrame::robot_
Robot & robot_
Definition: RobotFrame.h:151
mc_rbdyn::Robot
Definition: Robot.h:62
mc_rbdyn::RobotFrame::bodyMbcIndex
unsigned int bodyMbcIndex() const noexcept
Definition: RobotFrame.h:67
mc_rbdyn::ForceSensor
Definition: ForceSensor.h:19
mc_rbdyn::RobotFrame
Definition: RobotFrame.h:21
Frame.h
mc_rbdyn::RobotFrame::NewRobotFrameToken
Definition: RobotFrame.h:24
MC_RBDYN_DLLAPI
#define MC_RBDYN_DLLAPI
Definition: api.h:50
mc_tvm::RobotFrame
Definition: RobotFrame.h:27
mc_rbdyn::RobotFramePtr
std::shared_ptr< RobotFrame > RobotFramePtr
Definition: fwd.h:24
mc_rbdyn::Frame::NewFrameToken
Definition: Frame.h:30
mc_rbdyn::RobotFrame::hasForceSensor
bool hasForceSensor() const noexcept
Definition: RobotFrame.h:98
mc_rbdyn
Definition: generic_gripper.h:14