Privacy
An open-source, flexible 3D physical simulation framework
mars::sim::RotatingRaySensor Class Reference

#include <RotatingRaySensor.h>

Public Member Functions

 RotatingRaySensor (interfaces::ControlCenter *control, RotatingRayConfig config)
 
 ~RotatingRaySensor (void)
 
bool getPointcloud (std::vector< utils::Vector > &pointcloud)
 Returns a complete scan covering the complete defined horizontal range. More...
 
int getSensorData (double **) const
 Copies the current full pointcloud to a double array with (x,y,z). More...
 
virtual void receiveData (const data_broker::DataInfo &info, const data_broker::DataPackage &package, int callbackParam)
 Receives the measured distances, calculates the vectors in the local sensor frame and transfers them into the world to compensate the movement during pointcloud gathering. More...
 
virtual void update (std::vector< interfaces::draw_item > *drawItems)
 Uses the current node pose and the current distances to draw the laser rays. More...
 
virtual configmaps::ConfigMap createConfig () const
 
const RotatingRayConfiggetConfig () const
 
utils::Quaternion turn ()
 Turns the sensor during each simulation step. More...
 
int getNumberRays ()
 Number of lasers * number of bands. More...
 
std::vector< utils::Vector > & getDirections ()
 Returns all the ray directions as normalized vectors. More...
 
- Public Member Functions inherited from mars::interfaces::BasePolarIntersectionSensor
 BasePolarIntersectionSensor (unsigned long id, std::string name, int cols, int rows, double angleX, double angleY, double maxDistance=std::numeric_limits< double >::infinity())
 
virtual ~BasePolarIntersectionSensor ()
 
- Public Member Functions inherited from mars::interfaces::BaseNodeSensor
 BaseNodeSensor (unsigned long id, std::string name)
 
virtual ~BaseNodeSensor ()
 
utils::Quaternion getOrientation () const
 
unsigned long getAttachedNode ()
 
- Public Member Functions inherited from mars::interfaces::BaseSensor
 BaseSensor ()
 
virtual ~BaseSensor ()
 
 BaseSensor (unsigned long id, std::string name)
 
unsigned long getID () const
 
const std::string getName () const
 
virtual int getAsciiData (char *data) const
 
void getCoreExchange (core_objects_exchange *obj) const
 
- Public Member Functions inherited from mars::interfaces::BaseArraySensor< double >
 BaseArraySensor (int cols, int rows, int channels=1)
 
virtual ~BaseArraySensor ()
 
const std::vector< double > getData () const
 
const int & getCols () const
 
const int & getRows () const
 
const int & getChannels () const
 
double & operator[] (const int &index)
 
virtual void resize (int cols, int rows, int channels=1)
 
- Public Member Functions inherited from mars::interfaces::SensorInterface
 SensorInterface (ControlCenter *center)
 
virtual ~SensorInterface ()
 
- Public Member Functions inherited from mars::data_broker::ReceiverInterface
 ReceiverInterface ()
 
virtual ~ReceiverInterface ()
 
- Public Member Functions inherited from mars::interfaces::DrawInterface
virtual ~DrawInterface ()
 

Static Public Member Functions

static interfaces::BaseSensorinstanciate (interfaces::ControlCenter *control, interfaces::BaseConfig *config)
 
static interfaces::BaseConfigparseConfig (interfaces::ControlCenter *control, configmaps::ConfigMap *config)
 Config methods all part of BaseSensor. More...
 
- Static Public Member Functions inherited from mars::interfaces::BaseSensor
static BaseConfigparseConfig (ControlCenter *control, configmaps::ConfigMap *config)
 

Public Attributes

RotatingRayConfig config
 
- Public Attributes inherited from mars::interfaces::BasePolarIntersectionSensor
double stepX
 
double stepY
 
double maxDistance
 
- Public Attributes inherited from mars::interfaces::BaseSensor
unsigned long id
 
std::string name
 
unsigned long updateRate
 

Protected Member Functions

void run ()
 The thread will execute this method once it has been started . More...
 

Private Attributes

std::vector< utils::Vectordirections
 Contains the normalized scan directions. More...
 
std::list< utils::Vectorpointcloud1
 
std::list< utils::Vectorpointcloud2
 
std::list< utils::Vector > * toCloud
 
std::list< utils::Vector > * fromCloud
 
std::vector< utils::Vectorpointcloud_full
 
bool convertPointCloud
 
int nextCloud
 
double vertical_resolution
 
bool update_available
 
bool full_scan
 
double turning_offset
 
double turning_end_fullscan
 
utils::Quaternion orientation_offset
 
long positionIndices [3]
 
long rotationIndices [4]
 
double turning_step
 
int nsamples
 
mars::utils::Mutex mutex_pointcloud
 
mars::utils::Mutex poseMutex
 
Eigen::Affine3d current_pose
 
bool closeThread
 
unsigned int num_points
 

Additional Inherited Members

- Protected Attributes inherited from mars::interfaces::BaseNodeSensor
unsigned long attached_node
 
bool calcAcceletaion
 
bool calcSpeed
 
bool calcPosition
 
bool calcRotationSpeed
 
bool calcOrientation
 
utils::Vector acceleration
 
utils::Vector speed
 
utils::Vector position
 
utils::Vector rotationSpeed
 
utils::Quaternion orientation
 
- Protected Attributes inherited from mars::interfaces::BaseArraySensor< double >
int cols
 
int rows
 
int channels
 
std::vector< double > data
 
- Protected Attributes inherited from mars::interfaces::SensorInterface
ControlCentercontrol
 
- Private Member Functions inherited from mars::utils::Thread
 Thread ()
 
virtual ~Thread ()
 
void start ()
 Starts the execution of this Thread. More...
 
void cancel (bool block=false)
 Tries to cancel the Thread. More...
 
void setCancellationPoint ()
 Adds a cancellation point to your run method. More...
 
bool wait ()
 stops execution until the thread has finished. More...
 
bool join ()
 
bool wait (unsigned long timeoutMilliseconds)
 puts the Thread to sleep for a specified amount of time. More...
 
bool isRunning () const
 returns true if the Thread is running. More...
 
bool isFinished () const
 
void setStackSize (std::size_t stackSize)
 
std::size_t getStackSize () const
 
bool isCurrentThread () const
 
- Static Private Member Functions inherited from mars::utils::Thread
static ThreadgetCurrentThread ()
 
static void cancelAll (bool block=false)
 
static void msleep (unsigned long msec)
 causes the current thread to sleep for More...
 

Detailed Description

Definition at line 89 of file RotatingRaySensor.h.

Constructor & Destructor Documentation

◆ RotatingRaySensor()

mars::sim::RotatingRaySensor::RotatingRaySensor ( interfaces::ControlCenter control,
RotatingRayConfig  config 
)

Definition at line 56 of file RotatingRaySensor.cpp.

◆ ~RotatingRaySensor()

mars::sim::RotatingRaySensor::~RotatingRaySensor ( void  )

Definition at line 170 of file RotatingRaySensor.cpp.

Member Function Documentation

◆ createConfig()

ConfigMap mars::sim::RotatingRaySensor::createConfig ( ) const
virtual

Reimplemented from mars::interfaces::BaseSensor.

Definition at line 408 of file RotatingRaySensor.cpp.

◆ getConfig()

const RotatingRayConfig & mars::sim::RotatingRaySensor::getConfig ( ) const

Definition at line 435 of file RotatingRaySensor.cpp.

◆ getDirections()

std::vector<utils::Vector>& mars::sim::RotatingRaySensor::getDirections ( )
inline

Returns all the ray directions as normalized vectors.

Definition at line 164 of file RotatingRaySensor.h.

◆ getNumberRays()

int mars::sim::RotatingRaySensor::getNumberRays ( )

Number of lasers * number of bands.

Definition at line 313 of file RotatingRaySensor.cpp.

◆ getPointcloud()

bool mars::sim::RotatingRaySensor::getPointcloud ( std::vector< utils::Vector > &  pointcloud)

Returns a complete scan covering the complete defined horizontal range.

The pointcloud is gathered within the world frame and

  • after a complete scan has been received - transformed into the current local frame. This prevents strong distortions on slower computers. If a full scan is not available an empty pointcloud will be returned.

Definition at line 177 of file RotatingRaySensor.cpp.

◆ getSensorData()

int mars::sim::RotatingRaySensor::getSensorData ( double **  data_) const
virtual

Copies the current full pointcloud to a double array with (x,y,z).

Warning
Memory has to be freed manually! Inherited from BaseSensor, implemented from BasePolarIntersectionSensor.

Reimplemented from mars::interfaces::BasePolarIntersectionSensor.

Definition at line 188 of file RotatingRaySensor.cpp.

◆ instanciate()

BaseSensor * mars::sim::RotatingRaySensor::instanciate ( interfaces::ControlCenter control,
interfaces::BaseConfig config 
)
static

Definition at line 50 of file RotatingRaySensor.cpp.

◆ parseConfig()

BaseConfig * mars::sim::RotatingRaySensor::parseConfig ( interfaces::ControlCenter control,
configmaps::ConfigMap config 
)
static

Config methods all part of BaseSensor.

Definition at line 350 of file RotatingRaySensor.cpp.

◆ receiveData()

void mars::sim::RotatingRaySensor::receiveData ( const data_broker::DataInfo info,
const data_broker::DataPackage package,
int  callbackParam 
)
virtual

Receives the measured distances, calculates the vectors in the local sensor frame and transfers them into the world to compensate the movement during pointcloud gathering.

The points are transformed back to the current node pose when the pointcloud is requested. Inherited from ReceiverInterface. Method is called by the DataBroker as soon as the registered event occurs.

Implements mars::data_broker::ReceiverInterface.

Definition at line 200 of file RotatingRaySensor.cpp.

◆ run()

void mars::sim::RotatingRaySensor::run ( )
protectedvirtual

The thread will execute this method once it has been started .

See also
start(), cancel(), wait(), wait(unsigned long)

Implements mars::utils::Thread.

Definition at line 317 of file RotatingRaySensor.cpp.

◆ turn()

utils::Quaternion mars::sim::RotatingRaySensor::turn ( )

Turns the sensor during each simulation step.

As soon as a full scan has been done (depends on the number of bands) the pointcloud is copied to pointcloud_full and a new scan is initiated. Runs in the same thread than receiveData, so only the use of full_pointcloud (turn(), getPointcloud() and getSensorData()) has to be synchronized.

Definition at line 288 of file RotatingRaySensor.cpp.

◆ update()

void mars::sim::RotatingRaySensor::update ( std::vector< interfaces::draw_item > *  drawItems)
virtual

Uses the current node pose and the current distances to draw the laser rays.

Inherited from DrawInterface.

Implements mars::interfaces::DrawInterface.

Definition at line 266 of file RotatingRaySensor.cpp.

Member Data Documentation

◆ closeThread

bool mars::sim::RotatingRaySensor::closeThread
private

Definition at line 197 of file RotatingRaySensor.h.

◆ config

RotatingRayConfig mars::sim::RotatingRaySensor::config

Definition at line 168 of file RotatingRaySensor.h.

◆ convertPointCloud

bool mars::sim::RotatingRaySensor::convertPointCloud
private

Definition at line 183 of file RotatingRaySensor.h.

◆ current_pose

Eigen::Affine3d mars::sim::RotatingRaySensor::current_pose
private

Definition at line 196 of file RotatingRaySensor.h.

◆ directions

std::vector<utils::Vector> mars::sim::RotatingRaySensor::directions
private

Contains the normalized scan directions.

Definition at line 175 of file RotatingRaySensor.h.

◆ fromCloud

std::list<utils::Vector> * mars::sim::RotatingRaySensor::fromCloud
private

Definition at line 181 of file RotatingRaySensor.h.

◆ full_scan

bool mars::sim::RotatingRaySensor::full_scan
private

Definition at line 187 of file RotatingRaySensor.h.

◆ mutex_pointcloud

mars::utils::Mutex mars::sim::RotatingRaySensor::mutex_pointcloud
mutableprivate

Definition at line 195 of file RotatingRaySensor.h.

◆ nextCloud

int mars::sim::RotatingRaySensor::nextCloud
private

Definition at line 184 of file RotatingRaySensor.h.

◆ nsamples

int mars::sim::RotatingRaySensor::nsamples
private

Definition at line 194 of file RotatingRaySensor.h.

◆ num_points

unsigned int mars::sim::RotatingRaySensor::num_points
private

Definition at line 198 of file RotatingRaySensor.h.

◆ orientation_offset

utils::Quaternion mars::sim::RotatingRaySensor::orientation_offset
private

Definition at line 190 of file RotatingRaySensor.h.

◆ pointcloud1

std::list<utils::Vector> mars::sim::RotatingRaySensor::pointcloud1
private

Definition at line 179 of file RotatingRaySensor.h.

◆ pointcloud2

std::list<utils::Vector> mars::sim::RotatingRaySensor::pointcloud2
private

Definition at line 180 of file RotatingRaySensor.h.

◆ pointcloud_full

std::vector<utils::Vector> mars::sim::RotatingRaySensor::pointcloud_full
private

Definition at line 182 of file RotatingRaySensor.h.

◆ poseMutex

mars::utils::Mutex mars::sim::RotatingRaySensor::poseMutex
mutableprivate

Definition at line 195 of file RotatingRaySensor.h.

◆ positionIndices

long mars::sim::RotatingRaySensor::positionIndices[3]
private

Definition at line 191 of file RotatingRaySensor.h.

◆ rotationIndices

long mars::sim::RotatingRaySensor::rotationIndices[4]
private

Definition at line 192 of file RotatingRaySensor.h.

◆ toCloud

std::list<utils::Vector>* mars::sim::RotatingRaySensor::toCloud
private

Definition at line 181 of file RotatingRaySensor.h.

◆ turning_end_fullscan

double mars::sim::RotatingRaySensor::turning_end_fullscan
private

Definition at line 189 of file RotatingRaySensor.h.

◆ turning_offset

double mars::sim::RotatingRaySensor::turning_offset
private

Definition at line 188 of file RotatingRaySensor.h.

◆ turning_step

double mars::sim::RotatingRaySensor::turning_step
private

Definition at line 193 of file RotatingRaySensor.h.

◆ update_available

bool mars::sim::RotatingRaySensor::update_available
private

Definition at line 186 of file RotatingRaySensor.h.

◆ vertical_resolution

double mars::sim::RotatingRaySensor::vertical_resolution
private

Definition at line 185 of file RotatingRaySensor.h.


The documentation for this class was generated from the following files: