ForceSensor.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2019 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 
7 #include <mc_rbdyn/Device.h>
9 
10 namespace mc_rbdyn
11 {
12 
13 struct Robot;
14 
20 {
21 public:
23  ForceSensor();
24 
37  ForceSensor(const std::string & name, const std::string & parentBodyName, const sva::PTransformd & X_p_f);
38 
39  ForceSensor(const ForceSensor & fs);
40 
41  ForceSensor & operator=(const ForceSensor & fs);
42 
43  ForceSensor(ForceSensor &&) = default;
44  ForceSensor & operator=(ForceSensor &&) = default;
45 
47  ~ForceSensor() noexcept override;
48 
50  inline const std::string & parentBody() const { return Device::parent(); }
51 
53  inline const sva::PTransformd & X_p_f() const { return Device::X_p_s(); }
54 
56  inline sva::PTransformd X_0_f(const mc_rbdyn::Robot & robot) const { return Device::X_0_s(robot); }
57 
59  inline const sva::ForceVecd & wrench() const { return wrench_; }
60 
65  inline const Eigen::Vector3d & force() const { return wrench().force(); }
66 
71  inline const Eigen::Vector3d & couple() const { return wrench().couple(); }
72 
77  inline void wrench(const sva::ForceVecd & wrench) { wrench_ = wrench; }
78 
86  sva::ForceVecd wrenchWithoutGravity(const mc_rbdyn::Robot & robot) const;
87 
95  sva::ForceVecd worldWrench(const mc_rbdyn::Robot & robot) const;
96 
104  sva::ForceVecd worldWrenchWithoutGravity(const mc_rbdyn::Robot & robot) const;
105 
113  void loadCalibrator(const detail::ForceSensorCalibData & data) noexcept;
114 
124  void loadCalibrator(const std::string & calib_file, const Eigen::Vector3d & gravity = {0., 0., 9.81});
125 
131  void copyCalibrator(const mc_rbdyn::ForceSensor & other);
132 
137  void resetCalibrator();
138 
142  const sva::PTransformd & X_fsmodel_fsactual() const;
143 
146  const sva::PTransformd X_fsactual_parent() const;
147 
149  double mass() const;
150 
152  const sva::ForceVecd & offset() const;
153 
155  inline const detail::ForceSensorCalibData & calib() const noexcept { return calibration_; }
156 
158  /* End of Calibration group */
159 
160  DevicePtr clone() const override;
161 
162 private:
163  sva::ForceVecd wrench_;
164 
165  detail::ForceSensorCalibData calibration_;
166 };
167 
168 inline bool operator==(const mc_rbdyn::ForceSensor & lhs, const mc_rbdyn::ForceSensor & rhs)
169 {
170  return lhs.name() == rhs.name() && lhs.parentBody() == rhs.parentBody() && lhs.X_p_f() == rhs.X_p_f();
171 }
172 
173 } // namespace mc_rbdyn
Device.h
mc_rtc::constants::gravity
const Eigen::Vector3d gravity
Definition: constants.h:16
mc_rbdyn::Device::X_0_s
sva::PTransformd X_0_s(const mc_rbdyn::Robot &robot) const
mc_rbdyn::ForceSensor::X_p_f
const sva::PTransformd & X_p_f() const
Definition: ForceSensor.h:53
mc_rbdyn::Device
Definition: Device.h:29
mc_rbdyn::Robot
Definition: Robot.h:62
mc_rbdyn::ForceSensor::wrench
const sva::ForceVecd & wrench() const
Definition: ForceSensor.h:59
mc_rbdyn::ForceSensor::X_0_f
sva::PTransformd X_0_f(const mc_rbdyn::Robot &robot) const
Definition: ForceSensor.h:56
mc_rbdyn::Device::X_p_s
const sva::PTransformd & X_p_s() const
Definition: Device.h:64
mc_rbdyn::ForceSensor
Definition: ForceSensor.h:19
mc_rbdyn::ForceSensor::couple
const Eigen::Vector3d & couple() const
Definition: ForceSensor.h:71
mc_rbdyn::Device::name
const std::string & name() const
Definition: Device.h:49
mc_rbdyn::ForceSensor::wrench
void wrench(const sva::ForceVecd &wrench)
Definition: ForceSensor.h:77
MC_RBDYN_DLLAPI
#define MC_RBDYN_DLLAPI
Definition: api.h:50
mc_rbdyn::ForceSensor::parentBody
const std::string & parentBody() const
Definition: ForceSensor.h:50
mc_rbdyn::operator==
bool operator==(const mc_rbdyn::BodySensor &lhs, const mc_rbdyn::BodySensor &rhs)
Definition: BodySensor.h:147
mc_rbdyn::Device::parent
const std::string & parent() const
Definition: Device.h:55
mc_rbdyn::DevicePtr
std::unique_ptr< Device > DevicePtr
Definition: Device.h:20
mc_rbdyn
Definition: generic_gripper.h:14
mc_rtc::gui::Robot
auto Robot(const std::string &name, GetT get_fn)
Definition: Robot.h:56
ForceSensorCalibData.h
mc_rbdyn::detail::ForceSensorCalibData
Definition: ForceSensorCalibData.h:8
mc_rbdyn::ForceSensor::calib
const detail::ForceSensorCalibData & calib() const noexcept
Definition: ForceSensor.h:155
mc_rbdyn::ForceSensor::force
const Eigen::Vector3d & force() const
Definition: ForceSensor.h:65