Klamp't  0.9.0
VisualSensors.h
1 #ifndef CONTROL_VISUAL_SENSORS_H
2 #define CONTROL_VISUAL_SENSORS_H
3 
4 #include "Sensor.h"
5 #include <KrisLibrary/camera/viewport.h>
6 #include <KrisLibrary/math3d/primitives.h>
7 #include <KrisLibrary/GLdraw/GLRenderToImage.h>
8 #include <KrisLibrary/GLdraw/GLDisplayList.h>
9 
10 namespace Klampt {
11  using namespace Math3D;
12 
13 class WorldModel;
14 class RobotModel;
15 
41 {
42  public:
44  virtual ~LaserRangeSensor() {}
45  virtual const char* Type() const override { return "LaserRangeSensor"; }
46  virtual void Simulate(SimRobotController* robot,Simulator* sim) override;
47  virtual void SimulateKinematic(RobotModel& robot,WorldModel& world) override;
48  virtual void Advance(double dt) override;
49  virtual void Reset() override;
50  virtual void MeasurementNames(vector<string>& names) const override;
51  virtual void GetMeasurements(vector<double>& values) const override;
52  virtual void SetMeasurements(const vector<double>& values) override;
53  virtual map<string,string> Settings() const override;
54  virtual bool GetSetting(const string& name,string& str) const override;
55  virtual bool SetSetting(const string& name,const string& str) override;
56  virtual void DrawGL(const RobotModel& robot,const vector<double>& measurements) override;
57 
58  int link;
59  RigidTransform Tsensor;
61  double depthResolution;
62  double depthMinimum,depthMaximum;
63  double depthVarianceLinear,depthVarianceConstant;
71  enum { SweepSinusoid, SweepTriangular, SweepSawtooth};
77  Real xSweepMagnitude,xSweepPeriod,xSweepPhase;
78  int xSweepType;
84  Real ySweepMagnitude,ySweepPeriod,ySweepPhase;
85  int ySweepType;
86 
87  //simulated depth readings
88  vector<double> depthReadings;
89  //internal state
90  Real last_dt,last_t;
91 };
92 
93 
125 class CameraSensor : public SensorBase
126 {
127  public:
128  CameraSensor();
129  virtual ~CameraSensor();
130  virtual const char* Type() const override { return "CameraSensor"; }
131  virtual void Simulate(SimRobotController* robot,Simulator* sim) override;
132  virtual void SimulateKinematic(RobotModel& robot,WorldModel& world) override;
133  virtual void Reset() override;
134  virtual void MeasurementNames(vector<string>& names) const override;
135  virtual void GetMeasurements(vector<double>& values) const override;
136  virtual void SetMeasurements(const vector<double>& values) override;
137  virtual map<string,string> Settings() const override;
138  virtual bool GetSetting(const string& name,string& str) const override;
139  virtual bool SetSetting(const string& name,const string& str) override;
140  virtual void DrawGL(const RobotModel& robot,const vector<double>& measurements) override;
143  void GetViewport(Camera::Viewport& view) const;
146  void SetViewport(const Camera::Viewport& view);
147 
148  int link;
149  RigidTransform Tsensor;
150  bool rgb,depth;
151  int xres,yres;
152  double xfov,yfov;
153  double zmin,zmax;
157 
158  //internal: used for OpenGL rendering / buffers
159  bool useGLFramebuffers;
160  GLDraw::GLRenderToImage renderer;
161  //last measurements
162  vector<unsigned char> pixels;
163  vector<float> floats;
164  //visualization state
165  GLDraw::GLDisplayList depthDisplayList;
166  unsigned int depthDisplayHash;
167 };
168 
169 } //namespace Klampt
170 
171 #endif
int zresolution
resolution in z direction
Definition: VisualSensors.h:154
RigidTransform Tsensor
z is forward, x points left, y points up
Definition: VisualSensors.h:59
double zvarianceConstant
variance in z estimates, constant term
Definition: VisualSensors.h:156
double depthResolution
resolution of the depth measurement
Definition: VisualSensors.h:61
double depthMaximum
minimum / maximum depth
Definition: VisualSensors.h:62
double zvarianceLinear
variance in z estimates, linear term
Definition: VisualSensors.h:155
A physical simulator for a WorldModel.
Definition: Simulator.h:69
int yres
resolution of camera in x and y directions (# of pixels)
Definition: VisualSensors.h:151
int measurementCount
number of readings per cycle
Definition: VisualSensors.h:60
double zmax
range limits, > 0
Definition: VisualSensors.h:153
A class containing information about an ODE-simulated and controlled robot.
Definition: SimRobotController.h:19
Real ySweepMagnitude
Definition: VisualSensors.h:84
A sensor base class. A SensorBase should allow a Controller to both connect to a simulation as well a...
Definition: Sensor.h:55
Simulates an RGB, D, or RGB+D camera sensor. Provides a 2D grid of color and/or depth values...
Definition: VisualSensors.h:125
Simulates a laser range sensor, either sweeping or stationary. Can both simulate both 1D sweeping and...
Definition: VisualSensors.h:40
bool depth
If rgb is true, gives color measurements. If depth is true, gives depth measurements.
Definition: VisualSensors.h:150
double yfov
field of view in x and y directions (radians)
Definition: VisualSensors.h:152
RigidTransform Tsensor
z is forward, x is to the right of image, and y is down
Definition: VisualSensors.h:149
The main robot type used in RobotSim.
Definition: Robot.h:83
Real xSweepMagnitude
Definition: VisualSensors.h:77
Definition: ContactDistance.h:6
The main world class containing multiple robots, objects, and static geometries (terrains). Lights and other viewport information may also be stored here.
Definition: World.h:24