Choreonoid  1.8
ForceSensor.h
Go to the documentation of this file.
1 
6 #ifndef CNOID_BODY_FORCE_SENSOR_H
7 #define CNOID_BODY_FORCE_SENSOR_H
8 
9 #include "Device.h"
10 #include <memory>
11 #include "exportdecl.h"
12 
13 namespace cnoid {
14 
15 class Mapping;
16 
17 class CNOID_EXPORT ForceSensor : public Device
18 {
19 public:
20  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
21 
22  ForceSensor();
23  ForceSensor(const ForceSensor& org, bool copyStateOnly = false);
24 
25  virtual const char* typeName() const override;
26  void copyStateFrom(const ForceSensor& other);
27  virtual void copyStateFrom(const DeviceState& other) override;
28  virtual DeviceState* cloneState() const override;
29  virtual void forEachActualType(std::function<bool(const std::type_info& type)> func) override;
30  virtual void clearState() override;
31  virtual int stateSize() const override;
32  virtual const double* readState(const double* buf) override;
33  virtual double* writeState(double* out_buf) const override;
34 
35  const Vector6& wrench() const { return F_; }
36  Vector6& wrench() { return F_; }
37  const Vector6& maxWrench() const { return spec->F_max; }
38  Vector6& maxWrench() { return spec->F_max; }
39  const Vector6& F() const { return F_; }
40  Vector6& F() { return F_; }
41  const Vector6& F_max() const { return spec->F_max; }
42  Vector6& F_max() { return spec->F_max; }
43 
44  Vector6::FixedSegmentReturnType<3>::Type force() { return F_.head<3>(); }
45  Vector6::ConstFixedSegmentReturnType<3>::Type force() const { return F_.head<3>(); }
46  Vector6::FixedSegmentReturnType<3>::Type f() { return F_.head<3>(); }
47  Vector6::ConstFixedSegmentReturnType<3>::Type f() const { return F_.head<3>(); }
48 
49  Vector6::FixedSegmentReturnType<3>::Type torque() { return F_.tail<3>(); }
50  Vector6::ConstFixedSegmentReturnType<3>::Type torque() const { return F_.tail<3>(); }
51  Vector6::FixedSegmentReturnType<3>::Type tau() { return F_.tail<3>(); }
52  Vector6::ConstFixedSegmentReturnType<3>::Type tau() const { return F_.tail<3>(); }
53 
54  bool readSpecifications(const Mapping* info);
55  bool writeSpecifications(Mapping* info) const;
56 
57 protected:
58  virtual Referenced* doClone(CloneMap* cloneMap) const override;
59 
60 private:
61  Vector6 F_; // f (linear force) + tau (torque)
62 
63  struct Spec {
64  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
65  Vector6 F_max;
66  };
67  std::unique_ptr<Spec> spec;
68 };
69 
71 
72 }
73 
74 #endif
cnoid::Mapping
Definition: ValueTree.h:253
Device.h
cnoid::ForceSensor::force
Vector6::FixedSegmentReturnType< 3 >::Type force()
Definition: ForceSensor.h:44
cnoid::ForceSensorPtr
ref_ptr< ForceSensor > ForceSensorPtr
Definition: ForceSensor.h:70
cnoid::ForceSensor::force
Vector6::ConstFixedSegmentReturnType< 3 >::Type force() const
Definition: ForceSensor.h:45
cnoid::ForceSensor::wrench
Vector6 & wrench()
Definition: ForceSensor.h:36
cnoid::ForceSensor::wrench
const Vector6 & wrench() const
Definition: ForceSensor.h:35
cnoid::ForceSensor::F_max
const Vector6 & F_max() const
Definition: ForceSensor.h:41
cnoid::ForceSensor::tau
Vector6::ConstFixedSegmentReturnType< 3 >::Type tau() const
Definition: ForceSensor.h:52
cnoid::ForceSensor::tau
Vector6::FixedSegmentReturnType< 3 >::Type tau()
Definition: ForceSensor.h:51
cnoid::ref_ptr
Definition: Referenced.h:103
cnoid::ForceSensor
Definition: ForceSensor.h:17
cnoid::ForceSensor::torque
Vector6::ConstFixedSegmentReturnType< 3 >::Type torque() const
Definition: ForceSensor.h:50
cnoid::ForceSensor::f
Vector6::FixedSegmentReturnType< 3 >::Type f()
Definition: ForceSensor.h:46
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::CloneMap
Definition: CloneMap.h:13
cnoid::DeviceState
Definition: Device.h:20
cnoid::ForceSensor::F_max
Vector6 & F_max()
Definition: ForceSensor.h:42
cnoid::Referenced
Definition: Referenced.h:54
cnoid::ForceSensor::maxWrench
const Vector6 & maxWrench() const
Definition: ForceSensor.h:37
cnoid::Vector6
Eigen::Matrix< double, 6, 1 > Vector6
Definition: EigenTypes.h:61
cnoid::Device
Definition: Device.h:53
cnoid::ForceSensor::f
Vector6::ConstFixedSegmentReturnType< 3 >::Type f() const
Definition: ForceSensor.h:47
cnoid::ForceSensor::maxWrench
Vector6 & maxWrench()
Definition: ForceSensor.h:38
cnoid::ForceSensor::torque
Vector6::FixedSegmentReturnType< 3 >::Type torque()
Definition: ForceSensor.h:49
cnoid::ForceSensor::F
const Vector6 & F() const
Definition: ForceSensor.h:39
cnoid::ForceSensor::F
Vector6 & F()
Definition: ForceSensor.h:40