Klamp't  0.10.1
ForceSensors.h
1 #ifndef CONTROL_FORCE_SENSORS_H
2 #define CONTROL_FORCE_SENSORS_H
3 
4 #include "Sensor.h"
5 #include <KrisLibrary/math3d/primitives.h>
6 
7 
8 namespace Klampt {
9 
10 using namespace Math3D;
11 
43 class ContactSensor : public SensorBase
44 {
45  public:
46  ContactSensor();
47  virtual ~ContactSensor() {}
48  virtual const char* Type() const override { return "ContactSensor"; }
49  virtual void Simulate(SimRobotController* robot,Simulator* sim) override;
50  virtual void SimulateKinematic(RobotModel& robot,WorldModel& world) override;
51  virtual void Reset() override;
52  virtual void MeasurementNames(vector<string>& names) const override;
53  virtual void GetMeasurements(vector<double>& values) const override;
54  virtual void SetMeasurements(const vector<double>& values) override;
55  virtual map<string,string> Settings() const override;
56  virtual bool GetSetting(const string& name,string& str) const override;
57  virtual bool SetSetting(const string& name,const string& str) override;
58  virtual void DrawGL(const RobotModel& robot,const vector<double>& measurements) override;
59 
60  int link;
61  RigidTransform Tsensor;
62  Vector2 patchMin,patchMax;
63  Real patchTolerance;
64  bool hasForce[3];
65  Vector3 fResolution;
66  Vector3 fVariance;
67  Real fSensitivity;
68  Vector3 fSaturation;
69  Real falloffCoefficient;
70 
71  bool contact;
72  Vector3 force;
73 };
74 
94 {
95  public:
97  virtual ~ForceTorqueSensor() {}
98  virtual const char* Type() const override { return "ForceTorqueSensor"; }
99  virtual void Simulate(SimRobotController* robot,Simulator* sim) override;
100  virtual void SimulateKinematic(RobotModel& robot,WorldModel& world) override;
101  virtual void Reset() override;
102  virtual void MeasurementNames(vector<string>& names) const override;
103  virtual void GetMeasurements(vector<double>& values) const override;
104  virtual void SetMeasurements(const vector<double>& values) override;
105  virtual map<string,string> Settings() const override;
106  virtual bool GetSetting(const string& name,string& str) const override;
107  virtual bool SetSetting(const string& name,const string& str) override;
108  virtual void DrawGL(const RobotModel& robot,const vector<double>& measurements) override;
109 
110  int link;
111  bool hasForce[3];
112  bool hasTorque[3];
113  Vector3 fVariance, tVariance;
114 
115  Vector3 f,t;
116 };
117 
118 } //namespace Klampt
119 
120 #endif
Simulates a contact sensor / tactile sensor.
Definition: ForceSensors.h:44
virtual void DrawGL(const RobotModel &robot, const vector< double > &measurements) override
virtual void MeasurementNames(vector< string > &names) const override
Must be overridden to produce a list of names of each measurement.
Vector3 fResolution
Resolution of the sensor (default 0)
Definition: ForceSensors.h:65
Vector3 force
Measurement: the force magnitude.
Definition: ForceSensors.h:72
Vector3 fSaturation
The maximum force registered on each axis (default inf)
Definition: ForceSensors.h:68
virtual bool GetSetting(const string &name, string &str) const override
Get a named setting. Returns false if the name is not supported.
Vector2 patchMax
The 2D contact patch in the local frame of the sensor.
Definition: ForceSensors.h:62
virtual map< string, string > Settings() const override
Returns a map of all current name-value pairs of the sensor's settings.
virtual bool SetSetting(const string &name, const string &str) override
RigidTransform Tsensor
Local frame of the sensor relative to the link (by convention, origin is at contact patch center,...
Definition: ForceSensors.h:61
virtual void Reset() override
Should be overridden if the sensor is stateful to reset to an initial state.
virtual void SetMeasurements(const vector< double > &values) override
bool contact
Measurement: true if contact has been made.
Definition: ForceSensors.h:71
Vector3 fVariance
Estimated variance of the sensor (default 0)
Definition: ForceSensors.h:66
virtual void Simulate(SimRobotController *robot, Simulator *sim) override
Called whenever the sensor is updated from the simulaton.
virtual void SimulateKinematic(RobotModel &robot, WorldModel &world) override
Updates the sensor for a kinematic world. Useful for non-simulation debugging.
int link
The link on which the sensor is located.
Definition: ForceSensors.h:60
virtual void GetMeasurements(vector< double > &values) const override
Must be overridden to returns a list of all measurements.
Simulates a force-torque sensor mounted between a link and its parent. Can be configured to be up to ...
Definition: ForceSensors.h:94
virtual void GetMeasurements(vector< double > &values) const override
Must be overridden to returns a list of all measurements.
virtual void MeasurementNames(vector< string > &names) const override
Must be overridden to produce a list of names of each measurement.
virtual bool GetSetting(const string &name, string &str) const override
Get a named setting. Returns false if the name is not supported.
virtual void SimulateKinematic(RobotModel &robot, WorldModel &world) override
Updates the sensor for a kinematic world. Useful for non-simulation debugging.
int link
The link on which the sensor is located (between link and parent)
Definition: ForceSensors.h:110
virtual void DrawGL(const RobotModel &robot, const vector< double > &measurements) override
Vector3 t
Measurement: the force/torque at the given position, on the link (negative on the parent link)
Definition: ForceSensors.h:115
virtual map< string, string > Settings() const override
Returns a map of all current name-value pairs of the sensor's settings.
virtual bool SetSetting(const string &name, const string &str) override
virtual void SetMeasurements(const vector< double > &values) override
virtual void Simulate(SimRobotController *robot, Simulator *sim) override
Called whenever the sensor is updated from the simulaton.
virtual void Reset() override
Should be overridden if the sensor is stateful to reset to an initial state.
Vector3 tVariance
Estimated variance of the sensor (default 0)
Definition: ForceSensors.h:113
The main robot type used in RobotSim.
Definition: Robot.h:84
A sensor base class. A SensorBase should allow a Controller to both connect to a simulation as well a...
Definition: Sensor.h:56
A class containing information about an ODE-simulated and controlled robot.
Definition: SimRobotController.h:20
A physical simulator for a WorldModel.
Definition: Simulator.h:70
The main world class containing multiple robots, objects, and static geometries (terrains)....
Definition: World.h:25