Klamp't
0.9.0
|
Simulates an RGB, D, or RGB+D camera sensor. Provides a 2D grid of color and/or depth values, capped and quantized. More...
#include <VisualSensors.h>
Public Member Functions | |
virtual const char * | Type () const override |
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. | |
virtual void | Reset () override |
Should be overridden if the sensor is stateful to reset to an initial state. | |
virtual void | MeasurementNames (vector< string > &names) const override |
Must be overridden to produce a list of names of each measurement. | |
virtual void | GetMeasurements (vector< double > &values) const override |
Must be overridden to returns a list of all measurements. | |
virtual void | SetMeasurements (const vector< double > &values) override |
virtual map< string, string > | Settings () const override |
Returns a map of all current name-value pairs of the sensor's settings. | |
virtual bool | GetSetting (const string &name, string &str) const override |
Get a named setting. Returns false if the name is not supported. | |
virtual bool | SetSetting (const string &name, const string &str) override |
virtual void | DrawGL (const RobotModel &robot, const vector< double > &measurements) override |
void | GetViewport (Camera::Viewport &view) const |
void | SetViewport (const Camera::Viewport &view) |
Public Member Functions inherited from Klampt::SensorBase | |
virtual void | Advance (double dt) |
Advances to the next time step with duration dt elapsed. | |
virtual bool | ReadState (File &f) |
virtual bool | WriteState (File &f) const |
virtual void | GetInternalState (vector< double > &state) const |
Any other state besides measurements/settings that you might want to store. Used in ReadState. | |
virtual void | SetInternalState (const vector< double > &state) |
Any other state besides measurements/settings that you might want to store. Used in WriteState. | |
Public Attributes | |
int | link |
RigidTransform | Tsensor |
z is forward, x is to the right of image, and y is down | |
bool | rgb |
bool | depth |
If rgb is true, gives color measurements. If depth is true, gives depth measurements. | |
int | xres |
int | yres |
resolution of camera in x and y directions (# of pixels) | |
double | xfov |
double | yfov |
field of view in x and y directions (radians) | |
double | zmin |
double | zmax |
range limits, > 0 | |
int | zresolution |
resolution in z direction | |
double | zvarianceLinear |
variance in z estimates, linear term | |
double | zvarianceConstant |
variance in z estimates, constant term | |
bool | useGLFramebuffers |
GLDraw::GLRenderToImage | renderer |
vector< unsigned char > | pixels |
vector< float > | floats |
GLDraw::GLDisplayList | depthDisplayList |
unsigned int | depthDisplayHash |
Public Attributes inherited from Klampt::SensorBase | |
string | name |
double | rate |
bool | enabled |
Simulates an RGB, D, or RGB+D camera sensor. Provides a 2D grid of color and/or depth values, capped and quantized.
Camera is assumed to be centered at middle of image. The image is also rectified and depth values are converted to meters (or whatever unit you are generally using). The coordinate convention is Z forward, X right, Y down following OpenCV, ROS and other camera standards.
The format of the measurements list is a list of rgb[i,j] pixels if rgb=true, then followed by a list of d[i,j] pixels giving depth in meters (or whatever unit you are generally using) if depth=true. The rgb pixels are given as casts from unsigned integers in the pixel format 0xrrggbb to doubles. The depth pixels are given as floats.
The list of measurements proceeds in scan-line order from the upper-left pixel.
For optimal performance using the graphics card, you must install the GLEW package on your system. You must also initialize OpenGL before running the simulator, which typically requires popping up a visualization window.
Configurable settings:
|
overridevirtual |
If the sensor can be drawn, draw the sensor on the robot's current configuration, using these measurements, using OpenGL calls.
Reimplemented from Klampt::SensorBase.
void Klampt::CameraSensor::GetViewport | ( | Camera::Viewport & | view | ) | const |
Gets the OpenGL view associated with the camera. The result is in the link's local frame. Note that in OpenGL views, Z is backward, and Y is up.
|
overridevirtual |
Updates the internal measurement vector. Should be overridden to correctly restore state using ReadState(), or to visualize a physical robot's sensors.
Reimplemented from Klampt::SensorBase.
|
overridevirtual |
Set a named setting. Returns false if the name is not supported, or the value is formatted incorrectly
Reimplemented from Klampt::SensorBase.
void Klampt::CameraSensor::SetViewport | ( | const Camera::Viewport & | view | ) |
Sets the camera to match the OpenGL view. The view is assumed to be in the link's local frame. Note that in OpenGL views, Z is backward, and Y is up.