A C++ interface to Velodyne laser scanners (HDL-64, HDL-32, VLP-16), working on Linux and Windows.
(Using this class requires WinPCap as a run-time dependency in Windows). It can receive data from real devices via an Ethernet connection or parse a WireShark PCAP file for offline processing. The choice of online vs. offline operation is taken upon calling initialize(): if a PCAP input file has been defined, offline operation takes place and network is not listened for incomming packets.
Parsing dual return scans requires a VLP-16 with firmware version 3.0.23 or newer. While converting the scan into a point cloud in mrpt::obs::CObservationVelodyneScan you can select whether to keep the strongest, the last or both laser returns.
XML calibration files are not mandatory for VLP-16 and HDL-32, but they are for HDL-64.
See the source code of the example application [MRPT]/apps/velodyne-view
(velodyne-view web page) for more details.
It is common to save Velodyne datasets as Wireshark's PCAP files. These files can be played back with tools like bittwist, which emit all UDP packets in the PCAP log. Then, use this class to receive the packets as if they come from the real sensor.
Alternatively, if MRPT is linked against libpcap, this class can directly parse a PCAP file to simulate reading from a device offline. See method setPCAPInputFile() and config file parameter ``
To compile with PCAP support: In Debian/Ubuntu, install libpcap-dev. In Windows, install WinPCap developer packages + the regular WinPCap driver.
Data is returned as observations of type:
Configuration includes setting the device IP (optional) and sensor model (mandatory only if a calibration file is not provided). These parameters can be set programmatically (see methods of this class), or via a configuration file with CGenericSensor::loadConfig() (see example config file section below).
Each gathered observation of type mrpt::obs::CObservationVelodyneScan is populated with two timestamps, one for the local PC timestamp and, if available, another one for the GPS-stamped timestamp. Refer to the observation docs for details.
Portions of this class are based on code from velodyne ROS node in https://github.com/ros-drivers/velodyne Copyright (C) 2007 Austin Robot Technology, Patrick Beeson Copyright (C) 2009, 2010 Austin Robot Technology, Jack O'Quin License: Modified BSD Software License Agreement
Definition at line 168 of file CVelodyneScanner.h.
#include <mrpt/hwdrivers/CVelodyneScanner.h>
Classes | |
struct | TModelProperties |
Hard-wired properties of LIDARs depending on the model. More... | |
struct | TModelPropertiesFactory |
Access to default sets of parameters for Velodyne LIDARs. More... | |
Public Types | |
enum | model_t { VLP16 = 1, HDL32 = 2, HDL64 = 3 } |
LIDAR model types. More... | |
enum | return_type_t { UNCHANGED = 0, STRONGEST, LAST, DUAL } |
LIDAR return type. More... | |
using | model_properties_list_t = std::map< model_t, TModelProperties > |
enum | TSensorState { ssInitializing = 0, ssWorking, ssError } |
The current state of the sensor. More... | |
using | Ptr = std::shared_ptr< CGenericSensor > |
using | TListObservations = std::multimap< mrpt::system::TTimeStamp, mrpt::serialization::CSerializable::Ptr > |
using | TListObsPair = std::pair< mrpt::system::TTimeStamp, mrpt::serialization::CSerializable::Ptr > |
Public Member Functions | |
CVelodyneScanner () | |
virtual | ~CVelodyneScanner () |
bool | getNextObservation (mrpt::obs::CObservationVelodyneScan::Ptr &outScan, mrpt::obs::CObservationGPS::Ptr &outGPS) |
Polls the UDP port for incoming data packets. More... | |
void | doProcess () |
This method will be invoked at a minimum rate of "process_rate" (Hz) More... | |
virtual void | initialize () |
Tries to initialize the sensor driver, after setting all the parameters with a call to loadConfig. More... | |
void | close () |
Close the UDP sockets set-up in initialize(). More... | |
bool | receivePackets (mrpt::system::TTimeStamp &data_pkt_timestamp, mrpt::obs::CObservationVelodyneScan::TVelodyneRawPacket &out_data_pkt, mrpt::system::TTimeStamp &pos_pkt_timestamp, mrpt::obs::CObservationVelodyneScan::TVelodynePositionPacket &out_pos_pkt) |
Users normally would prefer calling getNextObservation() instead. More... | |
virtual const mrpt::hwdrivers::TSensorClassId * | GetRuntimeClass () const =0 |
TSensorState | getState () const |
The current state of the sensor More... | |
double | getProcessRate () const |
std::string | getSensorLabel () const |
void | setSensorLabel (const std::string &sensorLabel) |
void | enableVerbose (bool enabled=true) |
Enable or disable extra debug info dumped to std::cout during sensor operation. More... | |
bool | isVerboseEnabled () const |
void | loadConfig (const mrpt::config::CConfigFileBase &configSource, const std::string §ion) |
Loads the generic settings common to any sensor (See CGenericSensor), then call to "loadConfig_sensorSpecific". More... | |
void | getObservations (TListObservations &lstObjects) |
Returns a list of enqueued objects, emptying it (thread-safe). More... | |
virtual void | setPathForExternalImages (const std::string &directory) |
Set the path where to save off-rawlog image files (will be ignored in those sensors where this is not applicable). More... | |
void | setExternalImageFormat (const std::string &ext) |
Set the extension ("jpg","gif","png",...) that determines the format of images saved externally The default is "jpg". More... | |
void | setExternalImageJPEGQuality (const unsigned int quality) |
The quality of JPEG compression, when external images is enabled and the format is "jpg". More... | |
unsigned int | getExternalImageJPEGQuality () const |
Change configuration parameters; to be called BEFORE initialize(); | |
see above for the list of parameters and their meaning | |
void | setModelName (const model_t model) |
See supported model names in the general discussion docs for mrpt::hwdrivers::CVelodyneScanner. More... | |
model_t | getModelName () const |
void | setPosPacketsMinPeriod (double period_seconds) |
Set the minimum period between the generation of mrpt::obs::CObservationGPS observations from Velodyne Position RMC GPS packets. More... | |
double | getPosPacketsMinPeriod () const |
void | setPosPacketsTimingTimeout (double timeout) |
Set how long to wait, after loss of GPS signal, to report timestamps as "not based on satellite time". More... | |
double | getPosPacketsTimingTimeout () const |
void | setDeviceIP (const std::string &ip) |
UDP packets from other IPs will be ignored. More... | |
const std::string & | getDeviceIP () const |
void | setPCAPVerbosity (const bool verbose) |
Enables/disables PCAP info messages to console (default: true) More... | |
void | setPCAPInputFile (const std::string &pcap_file) |
Enables reading from a PCAP file instead of live UDP packet listening. More... | |
const std::string & | getPCAPInputFile () const |
void | setPCAPOutputFile (const std::string &out_pcap_file) |
Enables dumping to a PCAP file in parallel to returning regular MRPT objects. More... | |
const std::string & | getPCAPOutputFile () const |
void | setPCAPInputFileReadOnce (bool read_once) |
bool | getPCAPInputFileReadOnce () const |
const mrpt::obs::VelodyneCalibration & | getCalibration () const |
void | setCalibration (const mrpt::obs::VelodyneCalibration &calib) |
bool | loadCalibrationFile (const std::string &velodyne_xml_calib_file_path) |
Returns false on error. More... | |
bool | setLidarReturnType (return_type_t ret_type) |
Changes among STRONGEST, LAST, DUAL return types (via HTTP post interface). More... | |
bool | setLidarRPM (int rpm) |
Changes Lidar RPM (valid range: 300-600) (via HTTP post interface). More... | |
bool | setLidarOnOff (bool on) |
Switches the LASER on/off (saves energy when not measuring) (via HTTP post interface). More... | |
void | setFramePublishing (bool on) |
Switches whole frame (points in a single revolution) on/off publication to data packet publication. More... | |
Static Public Member Functions | |
static void | registerClass (const TSensorClassId *pNewClass) |
Register a class into the internal list of "CGenericSensor" descendents. More... | |
static CGenericSensor * | createSensor (const std::string &className) |
Creates a sensor by a name of the class. More... | |
static CGenericSensor::Ptr | createSensorPtr (const std::string &className) |
Just like createSensor, but returning a smart pointer to the newly created sensor object. More... | |
Static Public Attributes | |
static short int | VELODYNE_DATA_UDP_PORT = 2368 |
Default: 2368. More... | |
static short int | VELODYNE_POSITION_UDP_PORT = 8308 |
Default: 8308. More... | |
Protected Member Functions | |
void | loadConfig_sensorSpecific (const mrpt::config::CConfigFileBase &configSource, const std::string §ion) |
See the class documentation at the top for expected parameters. More... | |
void | appendObservations (const std::vector< mrpt::serialization::CSerializable::Ptr > &obj) |
This method must be called by derived classes to enqueue a new observation in the list to be returned by getObservations. More... | |
void | appendObservation (const mrpt::serialization::CSerializable::Ptr &obj) |
Like appendObservations() but for just one observation. More... | |
Protected Attributes | |
bool | m_initialized |
model_t | m_model |
Default: "VLP16". More... | |
double | m_pos_packets_min_period |
Default: 0.5 seconds. More... | |
double | m_pos_packets_timing_timeout |
Default: 30 seconds. More... | |
std::string | m_device_ip |
Default: "" (no IP-based filtering) More... | |
bool | m_return_frames |
Default: true Output whole frames and not data packets More... | |
bool | m_pcap_verbose |
Default: true Output PCAP Info msgs. More... | |
std::string | m_pcap_input_file |
Default: "" (do not operate from an offline file) More... | |
std::string | m_pcap_output_file |
Default: "" (do not dump to an offline file) More... | |
mrpt::poses::CPose3D | m_sensorPose |
mrpt::obs::VelodyneCalibration | m_velodyne_calib |
Device calibration file (supplied by vendor in an XML file) More... | |
mrpt::system::TTimeStamp | m_last_pos_packet_timestamp |
void * | m_pcap |
opaque ptr: "pcap_t*" More... | |
void * | m_pcap_out |
opaque ptr: "pcap_t*" More... | |
void * | m_pcap_dumper |
opaque ptr: "pcap_dumper_t *" More... | |
void * | m_pcap_bpf_program |
opaque ptr: bpf_program* More... | |
bool | m_pcap_file_empty |
unsigned int | m_pcap_read_count |
number of pkts read from the file so far (for debugging) More... | |
bool | m_pcap_read_once |
Default: false. More... | |
bool | m_pcap_read_fast |
(Default: false) If false, will use m_pcap_read_full_scan_delay_ms More... | |
double | m_pcap_read_full_scan_delay_ms |
(Default:100 ms) delay after each full scan read from a PCAP log More... | |
double | m_pcap_repeat_delay |
Default: 0 (in seconds) More... | |
size_t | m_grab_decimation_counter |
Used when "m_grab_decimation" is enabled. More... | |
TSensorState | m_state |
bool | m_verbose |
std::string | m_path_for_external_images |
The path where to save off-rawlog images: empty means save images embedded in the rawlog. More... | |
std::string | m_external_images_format |
The extension ("jpg","gif","png",...) that determines the format of images saved externally. More... | |
unsigned int | m_external_images_jpeg_quality |
For JPEG images, the quality (default=95%). More... | |
Private Types | |
using | platform_socket_t = uint32_t |
Handles for the UDP sockets, or INVALID_SOCKET (-1) More... | |
using | registered_sensor_classes_t = std::map< std::string, const TSensorClassId * > |
Used in registerClass. More... | |
Private Member Functions | |
bool | internal_read_PCAP_packet (mrpt::system::TTimeStamp &data_pkt_time, uint8_t *out_data_buffer, mrpt::system::TTimeStamp &pos_pkt_time, uint8_t *out_pos_buffer) |
bool | internal_send_http_post (const std::string &post_data) |
Static Private Member Functions | |
static mrpt::system::TTimeStamp | internal_receive_UDP_packet (platform_socket_t hSocket, uint8_t *out_buffer, const size_t expected_packet_size, const std::string &filter_only_from_IP) |
static registered_sensor_classes_t & | get_registered_sensor_classes () |
Access to singleton. More... | |
Private Attributes | |
platform_socket_t | m_hDataSock |
platform_socket_t | m_hPositionSock |
mrpt::obs::CObservationVelodyneScan::Ptr | m_rx_scan |
In progress RX scan. More... | |
mrpt::obs::gnss::Message_NMEA_RMC | m_last_gps_rmc |
mrpt::system::TTimeStamp | m_last_gps_rmc_age |
int | m_lidar_rpm |
return_type_t | m_lidar_return |
std::mutex | m_csObjList |
The critical section for m_objList. More... | |
TListObservations | m_objList |
The queue of objects to be returned by getObservations. More... | |
using mrpt::hwdrivers::CVelodyneScanner::model_properties_list_t = std::map<model_t, TModelProperties> |
Definition at line 199 of file CVelodyneScanner.h.
|
private |
Handles for the UDP sockets, or INVALID_SOCKET (-1)
Definition at line 415 of file CVelodyneScanner.h.
|
inherited |
Definition at line 73 of file CGenericSensor.h.
|
privateinherited |
Used in registerClass.
Definition at line 124 of file CGenericSensor.h.
|
inherited |
Definition at line 77 of file CGenericSensor.h.
|
inherited |
Definition at line 79 of file CGenericSensor.h.
LIDAR return type.
Enumerator | |
---|---|
UNCHANGED | |
STRONGEST | |
LAST | |
DUAL |
Definition at line 186 of file CVelodyneScanner.h.
|
inherited |
The current state of the sensor.
Enumerator | |
---|---|
ssInitializing | |
ssWorking | |
ssError |
Definition at line 84 of file CGenericSensor.h.
CVelodyneScanner::CVelodyneScanner | ( | ) |
Definition at line 98 of file CVelodyneScanner.cpp.
References m_pcap_bpf_program, mrpt::hwdrivers::CGenericSensor::m_sensorLabel, and THROW_EXCEPTION.
|
virtual |
Definition at line 136 of file CVelodyneScanner.cpp.
References close(), and m_pcap_bpf_program.
|
inlineprotectedinherited |
Like appendObservations() but for just one observation.
Definition at line 179 of file CGenericSensor.h.
References mrpt::hwdrivers::CGenericSensor::appendObservations().
Referenced by mrpt::hwdrivers::CIMUXSens_MT4::doProcess(), mrpt::hwdrivers::CIMUXSens::doProcess(), mrpt::hwdrivers::CGyroKVHDSP3000::doProcess(), mrpt::hwdrivers::CIMUIntersense::doProcess(), mrpt::hwdrivers::CSkeletonTracker::doProcess(), mrpt::hwdrivers::CSwissRanger3DCamera::doProcess(), mrpt::hwdrivers::C2DRangeFinderAbstract::doProcess(), mrpt::hwdrivers::CCANBusReader::doProcess(), doProcess(), and mrpt::hwdrivers::CGPSInterface::flushParsedMessagesNow().
|
protectedinherited |
This method must be called by derived classes to enqueue a new observation in the list to be returned by getObservations.
Passed objects must be created in dynamic memory and a smart pointer passed. Example of creation:
If several observations are passed at once in the vector, they'll be considered as a block regarding the grabbing decimation factor.
Definition at line 53 of file CGenericSensor.cpp.
References CLASS_ID, mrpt::hwdrivers::CGenericSensor::m_csObjList, mrpt::hwdrivers::CGenericSensor::m_grab_decimation, mrpt::hwdrivers::CGenericSensor::m_grab_decimation_counter, mrpt::hwdrivers::CGenericSensor::m_objList, and THROW_EXCEPTION.
Referenced by mrpt::hwdrivers::CGenericSensor::appendObservation(), mrpt::hwdrivers::CNationalInstrumentsDAQ::doProcess(), and mrpt::hwdrivers::CKinect::doProcess().
void CVelodyneScanner::close | ( | ) |
Close the UDP sockets set-up in initialize().
This is called automatically upon destruction
Definition at line 562 of file CVelodyneScanner.cpp.
References m_hDataSock, m_hPositionSock, m_initialized, m_pcap, m_pcap_dumper, and m_pcap_out.
Referenced by initialize(), and ~CVelodyneScanner().
|
staticinherited |
Creates a sensor by a name of the class.
Typically the user may want to create a smart pointer around the returned pointer, whis is made with:
Definition at line 103 of file CGenericSensor.cpp.
References mrpt::hwdrivers::CGenericSensor::get_registered_sensor_classes().
Referenced by mrpt::hwdrivers::CGenericSensor::createSensorPtr().
|
inlinestaticinherited |
Just like createSensor, but returning a smart pointer to the newly created sensor object.
Definition at line 219 of file CGenericSensor.h.
References mrpt::hwdrivers::CGenericSensor::createSensor().
|
virtual |
This method will be invoked at a minimum rate of "process_rate" (Hz)
This | method must throw an exception with a descriptive message if some critical error is found. |
Implements mrpt::hwdrivers::CGenericSensor.
Definition at line 379 of file CVelodyneScanner.cpp.
References mrpt::hwdrivers::CGenericSensor::appendObservation(), getNextObservation(), mrpt::hwdrivers::CGenericSensor::m_state, mrpt::hwdrivers::CGenericSensor::ssError, and mrpt::hwdrivers::CGenericSensor::ssWorking.
|
inlineinherited |
Enable or disable extra debug info dumped to std::cout during sensor operation.
Default: disabled unless the environment variable "MRPT_HWDRIVERS_VERBOSE" is set to "1" during object creation.
Definition at line 105 of file CGenericSensor.h.
References mrpt::hwdrivers::CGenericSensor::m_verbose.
|
staticprivateinherited |
Access to singleton.
Definition at line 112 of file CGenericSensor.cpp.
Referenced by mrpt::hwdrivers::CGenericSensor::createSensor(), and mrpt::hwdrivers::CGenericSensor::registerClass().
|
inline |
Definition at line 313 of file CVelodyneScanner.h.
References m_velodyne_calib.
|
inline |
Definition at line 292 of file CVelodyneScanner.h.
References m_device_ip.
|
inlineinherited |
Definition at line 289 of file CGenericSensor.h.
References mrpt::hwdrivers::CGenericSensor::m_external_images_jpeg_quality.
|
inline |
Definition at line 268 of file CVelodyneScanner.h.
References m_model.
bool CVelodyneScanner::getNextObservation | ( | mrpt::obs::CObservationVelodyneScan::Ptr & | outScan, |
mrpt::obs::CObservationGPS::Ptr & | outGPS | ||
) |
Polls the UDP port for incoming data packets.
The user must call this method in a timely fashion to grab data as it it generated by the device. The minimum call rate should be the expected number of data packets/second (!=scans/second). Checkout Velodyne user manual if in doubt.
[out] | outScan | Upon return, an empty smart pointer will be found here if no new data was available. Otherwise, a valid scan. |
[out] | outGPS | Upon return, an empty smart pointer will be found here if no new GPS data was available. Otherwise, a valid GPS reading. |
Definition at line 211 of file CVelodyneScanner.cpp.
References ASSERTMSG_, mrpt::obs::CObservationVelodyneScan::TVelodyneRawPacket::blocks, mrpt::system::buildTimestampFromParts(), mrpt::obs::gnss::Message_NMEA_RMC::fields, mrpt::hwdrivers::CVelodyneScanner::TModelPropertiesFactory::get(), mrpt::obs::gnss::UTC_time::getAsTimestamp(), mrpt::obs::gnss::Message_NMEA_RMC::getDateAsTimestamp(), mrpt::obs::CObservationVelodyneScan::TVelodyneRawPacket::gps_timestamp, INVALID_TIMESTAMP, m_initialized, m_last_gps_rmc, m_last_gps_rmc_age, m_model, m_pcap, m_pcap_read_fast, m_pcap_read_full_scan_delay_ms, m_pos_packets_timing_timeout, m_return_frames, m_rx_scan, mrpt::hwdrivers::CGenericSensor::m_sensorLabel, m_sensorPose, mrpt::hwdrivers::CGenericSensor::m_state, m_velodyne_calib, mrpt::make_aligned_shared(), mrpt::system::TTimeParts::minute, mrpt::obs::CObservationVelodyneScan::TVelodynePositionPacket::NMEA_GPRMC, mrpt::hwdrivers::CGPSInterface::parse_NMEA(), receivePackets(), mrpt::obs::CObservationVelodyneScan::raw_block_t::rotation, mrpt::system::TTimeParts::second, mrpt::hwdrivers::CGenericSensor::ssWorking, mrpt::system::timeDifference(), mrpt::system::timestampToParts(), mrpt::obs::gnss::Message_NMEA_RMC::content_t::UTCTime, and mrpt::obs::gnss::Message_NMEA_RMC::content_t::validity_char.
Referenced by doProcess().
|
inherited |
Returns a list of enqueued objects, emptying it (thread-safe).
The objects must be freed by the invoker.
Definition at line 91 of file CGenericSensor.cpp.
References mrpt::hwdrivers::CGenericSensor::m_csObjList, and mrpt::hwdrivers::CGenericSensor::m_objList.
|
inline |
Definition at line 300 of file CVelodyneScanner.h.
References m_pcap_input_file.
|
inline |
Definition at line 312 of file CVelodyneScanner.h.
References m_pcap_read_once.
|
inline |
Definition at line 307 of file CVelodyneScanner.h.
References m_pcap_output_file.
|
inline |
Definition at line 276 of file CVelodyneScanner.h.
References m_pos_packets_min_period.
|
inline |
Definition at line 284 of file CVelodyneScanner.h.
References m_pos_packets_timing_timeout.
|
inlineinherited |
Definition at line 93 of file CGenericSensor.h.
References mrpt::hwdrivers::CGenericSensor::m_process_rate.
|
pure virtualinherited |
|
inlineinherited |
Definition at line 94 of file CGenericSensor.h.
References mrpt::hwdrivers::CGenericSensor::m_sensorLabel.
|
inlineinherited |
The current state of the sensor
Definition at line 92 of file CGenericSensor.h.
References mrpt::hwdrivers::CGenericSensor::m_state.
|
virtual |
Tries to initialize the sensor driver, after setting all the parameters with a call to loadConfig.
Tries to initialize the sensor, after setting all the parameters with a call to loadConfig.
Velodyne specifics: this method sets up the UDP listening sockets, so all relevant params MUST BE SET BEFORE calling this.
This | method must throw an exception with a descriptive message if some critical error is found. |
This | method must throw an exception with a descriptive message if some critical error is found. |
Reimplemented from mrpt::hwdrivers::CGenericSensor.
Definition at line 401 of file CVelodyneScanner.cpp.
References close(), mrpt::obs::VelodyneCalibration::empty(), mrpt::format(), mrpt::comms::net::getLastSocketErrorStr(), INVALID_TIMESTAMP, m_device_ip, m_hDataSock, m_hPositionSock, m_initialized, m_last_gps_rmc_age, m_last_pos_packet_timestamp, m_lidar_return, m_lidar_rpm, m_model, m_pcap, m_pcap_bpf_program, m_pcap_file_empty, m_pcap_input_file, m_pcap_read_count, m_pcap_verbose, mrpt::hwdrivers::CGenericSensor::m_state, m_velodyne_calib, setLidarReturnType(), setLidarRPM(), mrpt::hwdrivers::CGenericSensor::ssInitializing, THROW_EXCEPTION, THROW_EXCEPTION_FMT, UNCHANGED, VELODYNE_DATA_UDP_PORT, and VELODYNE_POSITION_UDP_PORT.
|
private |
Definition at line 907 of file CVelodyneScanner.cpp.
References ASSERT_, mrpt::system::os::fprintf(), mrpt::obs::gnss::header, INVALID_TIMESTAMP, m_pcap, m_pcap_bpf_program, m_pcap_file_empty, m_pcap_input_file, m_pcap_read_count, m_pcap_read_once, m_pcap_repeat_delay, m_pcap_verbose, mrpt::hwdrivers::CGenericSensor::m_verbose, mrpt::system::os::memcpy(), mrpt::system::now(), THROW_EXCEPTION, THROW_EXCEPTION_FMT, VELODYNE_DATA_UDP_PORT, and VELODYNE_POSITION_UDP_PORT.
Referenced by receivePackets().
|
staticprivate |
Definition at line 800 of file CVelodyneScanner.cpp.
References mrpt::format(), mrpt::comms::net::getLastSocketErrorStr(), INVALID_TIMESTAMP, mrpt::system::now(), THROW_EXCEPTION, time1, and time2.
Referenced by receivePackets().
|
private |
Definition at line 1104 of file CVelodyneScanner.cpp.
References ASSERTMSG_, mrpt::comms::net::erOk, mrpt::format(), mrpt::comms::net::http_request(), m_device_ip, MRPT_END, and MRPT_START.
Referenced by setLidarOnOff(), setLidarReturnType(), and setLidarRPM().
|
inlineinherited |
Definition at line 106 of file CGenericSensor.h.
References mrpt::hwdrivers::CGenericSensor::m_verbose.
bool CVelodyneScanner::loadCalibrationFile | ( | const std::string & | velodyne_xml_calib_file_path | ) |
Returns false on error.
Definition at line 149 of file CVelodyneScanner.cpp.
References mrpt::obs::VelodyneCalibration::loadFromXMLFile(), and m_velodyne_calib.
Referenced by loadConfig_sensorSpecific().
|
inherited |
Loads the generic settings common to any sensor (See CGenericSensor), then call to "loadConfig_sensorSpecific".
This | method throws an exception with a descriptive message if some critical parameter is missing or has an invalid value. |
Definition at line 132 of file CGenericSensor.cpp.
References mrpt::hwdrivers::CGenericSensor::loadConfig_sensorSpecific(), mrpt::hwdrivers::CGenericSensor::m_grab_decimation, mrpt::hwdrivers::CGenericSensor::m_grab_decimation_counter, mrpt::hwdrivers::CGenericSensor::m_max_queue_len, mrpt::hwdrivers::CGenericSensor::m_process_rate, mrpt::hwdrivers::CGenericSensor::m_sensorLabel, MRPT_END, MRPT_START, mrpt::config::CConfigFileBase::read_double(), mrpt::config::CConfigFileBase::read_int(), and mrpt::config::CConfigFileBase::read_string().
|
protectedvirtual |
See the class documentation at the top for expected parameters.
Implements mrpt::hwdrivers::CGenericSensor.
Definition at line 155 of file CVelodyneScanner.cpp.
References mrpt::DEG2RAD(), mrpt::format(), mrpt::hwdrivers::CVelodyneScanner::TModelPropertiesFactory::get(), mrpt::hwdrivers::CVelodyneScanner::TModelPropertiesFactory::getListKnownModels(), loadCalibrationFile(), m_device_ip, m_lidar_return, m_lidar_rpm, m_model, m_pcap_input_file, m_pcap_output_file, m_pcap_read_fast, m_pcap_read_full_scan_delay_ms, m_pcap_read_once, m_pcap_repeat_delay, m_pos_packets_min_period, m_pos_packets_timing_timeout, m_sensorPose, MRPT_END, MRPT_LOAD_CONFIG_VAR, MRPT_LOAD_HERE_CONFIG_VAR, MRPT_START, mrpt::config::CConfigFileBase::read_enum(), mrpt::config::CConfigFileBase::read_float(), and THROW_EXCEPTION.
bool CVelodyneScanner::receivePackets | ( | mrpt::system::TTimeStamp & | data_pkt_timestamp, |
mrpt::obs::CObservationVelodyneScan::TVelodyneRawPacket & | out_data_pkt, | ||
mrpt::system::TTimeStamp & | pos_pkt_timestamp, | ||
mrpt::obs::CObservationVelodyneScan::TVelodynePositionPacket & | out_pos_pkt | ||
) |
Users normally would prefer calling getNextObservation() instead.
This method polls the UDP data port and returns one Velodyne DATA packet (1206 bytes) and/or one POSITION packet. Refer to Velodyne users manual. Approximate timestamps (based on this computer clock) are returned for each kind of packets, or INVALID_TIMESTAMP if timeout ocurred waiting for a packet.
Definition at line 638 of file CVelodyneScanner.cpp.
References ASSERTMSG_, mrpt::obs::CObservationVelodyneScan::TVelodyneRawPacket::blocks, mrpt::system::TTimeParts::day, mrpt::obs::CObservationVelodyneScan::laser_return_t::distance, mrpt::system::fileNameStripInvalidChars(), mrpt::format(), mrpt::obs::CObservationVelodyneScan::TVelodyneRawPacket::gps_timestamp, mrpt::obs::CObservationVelodyneScan::TVelodynePositionPacket::gps_timestamp, mrpt::obs::CObservationVelodyneScan::raw_block_t::header, mrpt::obs::gnss::header, mrpt::system::TTimeParts::hour, internal_read_PCAP_packet(), internal_receive_UDP_packet(), INVALID_TIMESTAMP, mrpt::obs::CObservationVelodyneScan::raw_block_t::laser_returns, m_device_ip, m_hDataSock, m_hPositionSock, m_last_pos_packet_timestamp, m_pcap, m_pcap_dumper, m_pcap_out, m_pcap_output_file, m_pos_packets_min_period, mrpt::system::os::memcpy(), mrpt::system::TTimeParts::minute, mrpt::system::TTimeParts::month, MRPT_COMPILE_TIME_ASSERT, mrpt::system::now(), mrpt::reverseBytesInPlace(), mrpt::obs::CObservationVelodyneScan::raw_block_t::rotation, mrpt::system::TTimeParts::second, THROW_EXCEPTION, THROW_EXCEPTION_FMT, mrpt::system::timeDifference(), mrpt::system::timestampToParts(), mrpt::obs::CObservationVelodyneScan::TVelodynePositionPacket::unused2, and mrpt::system::TTimeParts::year.
Referenced by getNextObservation().
|
staticinherited |
Register a class into the internal list of "CGenericSensor" descendents.
Used internally in the macros DEFINE_GENERIC_SENSOR, etc...
Can be used as "CGenericSensor::registerClass( SENSOR_CLASS_ID(CMySensor) );" if building custom sensors outside mrpt libraries in user code.
Definition at line 121 of file CGenericSensor.cpp.
References mrpt::hwdrivers::TSensorClassId::className, and mrpt::hwdrivers::CGenericSensor::get_registered_sensor_classes().
Referenced by mrpt::hwdrivers::CGenericSensor::CLASSINIT_GENERIC_SENSOR::CLASSINIT_GENERIC_SENSOR().
|
inline |
Definition at line 317 of file CVelodyneScanner.h.
References m_velodyne_calib.
|
inline |
UDP packets from other IPs will be ignored.
Default: empty string, means do not filter by IP
Definition at line 291 of file CVelodyneScanner.h.
References m_device_ip.
|
inlineinherited |
Set the extension ("jpg","gif","png",...) that determines the format of images saved externally The default is "jpg".
Definition at line 278 of file CGenericSensor.h.
References mrpt::hwdrivers::CGenericSensor::m_external_images_format.
|
inlineinherited |
The quality of JPEG compression, when external images is enabled and the format is "jpg".
Definition at line 285 of file CGenericSensor.h.
References mrpt::hwdrivers::CGenericSensor::m_external_images_jpeg_quality.
void CVelodyneScanner::setFramePublishing | ( | bool | on | ) |
Switches whole frame (points in a single revolution) on/off publication
to data packet publication.
When on, getNextObservation() will return true whenever a frame is avaliable, when off, getNextObservation() will return true whenever a data packet is avaliable. The default is on. When listening to data packets on a PCAP, pcap_read_fast is enforced.
Definition at line 1096 of file CVelodyneScanner.cpp.
References m_return_frames, MRPT_END, and MRPT_START.
bool CVelodyneScanner::setLidarOnOff | ( | bool | on | ) |
Switches the LASER on/off (saves energy when not measuring) (via HTTP post interface).
Can be called at any instant, before or after initialize(). Requires setting a device IP address.
Definition at line 1087 of file CVelodyneScanner.cpp.
References mrpt::format(), internal_send_http_post(), MRPT_END, and MRPT_START.
bool CVelodyneScanner::setLidarReturnType | ( | return_type_t | ret_type | ) |
Changes among STRONGEST, LAST, DUAL return types (via HTTP post interface).
Can be called at any instant, before or after initialize(). Requires setting a device IP address.
Definition at line 1031 of file CVelodyneScanner.cpp.
References DUAL, mrpt::format(), internal_send_http_post(), LAST, MRPT_END, MRPT_START, STRONGEST, THROW_EXCEPTION, and UNCHANGED.
Referenced by initialize().
bool CVelodyneScanner::setLidarRPM | ( | int | rpm | ) |
Changes Lidar RPM (valid range: 300-600) (via HTTP post interface).
Can be called at any instant, before or after initialize(). Requires setting a device IP address.
Definition at line 1067 of file CVelodyneScanner.cpp.
References mrpt::format(), internal_send_http_post(), MRPT_END, and MRPT_START.
Referenced by initialize().
See supported model names in the general discussion docs for mrpt::hwdrivers::CVelodyneScanner.
Definition at line 267 of file CVelodyneScanner.h.
|
inlinevirtualinherited |
Set the path where to save off-rawlog image files (will be ignored in those sensors where this is not applicable).
An empty string (the default value at construction) means to save images embedded in the rawlog, instead of on separate files.
std::exception | If the directory doesn't exists and cannot be created. |
Reimplemented in mrpt::hwdrivers::CCameraSensor, mrpt::hwdrivers::CKinect, mrpt::hwdrivers::COpenNI2Sensor, mrpt::hwdrivers::COpenNI2_RGBD360, and mrpt::hwdrivers::CSwissRanger3DCamera.
Definition at line 267 of file CGenericSensor.h.
References MRPT_UNUSED_PARAM.
|
inline |
Enables reading from a PCAP file instead of live UDP packet listening.
Definition at line 296 of file CVelodyneScanner.h.
References m_pcap_input_file.
|
inline |
Definition at line 308 of file CVelodyneScanner.h.
References m_pcap_read_once.
|
inline |
Enables dumping to a PCAP file in parallel to returning regular MRPT objects.
Default="": no pcap log.
Definition at line 303 of file CVelodyneScanner.h.
References m_pcap_output_file.
|
inline |
Enables/disables PCAP info messages to console (default: true)
Definition at line 294 of file CVelodyneScanner.h.
References m_pcap_verbose.
|
inline |
Set the minimum period between the generation of mrpt::obs::CObservationGPS observations from Velodyne Position RMC GPS packets.
Definition at line 272 of file CVelodyneScanner.h.
References m_pos_packets_min_period.
|
inline |
Set how long to wait, after loss of GPS signal, to report timestamps as "not based on satellite time".
30 secs, with typical velodyne clock drifts, means a ~1.7 ms typical drift.
Definition at line 280 of file CVelodyneScanner.h.
References m_pos_packets_timing_timeout.
|
inlineinherited |
Definition at line 95 of file CGenericSensor.h.
References mrpt::hwdrivers::CGenericSensor::m_sensorLabel.
|
privateinherited |
The critical section for m_objList.
Definition at line 118 of file CGenericSensor.h.
Referenced by mrpt::hwdrivers::CGenericSensor::appendObservations(), and mrpt::hwdrivers::CGenericSensor::getObservations().
|
protected |
Default: "" (no IP-based filtering)
Definition at line 218 of file CVelodyneScanner.h.
Referenced by getDeviceIP(), initialize(), internal_send_http_post(), loadConfig_sensorSpecific(), receivePackets(), and setDeviceIP().
|
protectedinherited |
The extension ("jpg","gif","png",...) that determines the format of images saved externally.
Definition at line 157 of file CGenericSensor.h.
Referenced by mrpt::hwdrivers::CSwissRanger3DCamera::getNextObservation(), mrpt::hwdrivers::CSwissRanger3DCamera::loadConfig_sensorSpecific(), and mrpt::hwdrivers::CGenericSensor::setExternalImageFormat().
|
protectedinherited |
For JPEG images, the quality (default=95%).
Definition at line 159 of file CGenericSensor.h.
Referenced by mrpt::hwdrivers::CGenericSensor::getExternalImageJPEGQuality(), mrpt::hwdrivers::CSwissRanger3DCamera::getNextObservation(), mrpt::hwdrivers::CSwissRanger3DCamera::loadConfig_sensorSpecific(), and mrpt::hwdrivers::CGenericSensor::setExternalImageJPEGQuality().
|
protectedinherited |
If set to N>=2, only 1 out of N observations will be saved to m_objList.
Definition at line 138 of file CGenericSensor.h.
Referenced by mrpt::hwdrivers::CGenericSensor::appendObservations(), and mrpt::hwdrivers::CGenericSensor::loadConfig().
|
protectedinherited |
Used when "m_grab_decimation" is enabled.
Definition at line 145 of file CGenericSensor.h.
Referenced by mrpt::hwdrivers::CGenericSensor::appendObservations(), and mrpt::hwdrivers::CGenericSensor::loadConfig().
|
private |
Definition at line 417 of file CVelodyneScanner.h.
Referenced by close(), initialize(), and receivePackets().
|
private |
Definition at line 417 of file CVelodyneScanner.h.
Referenced by close(), initialize(), and receivePackets().
|
protected |
Definition at line 210 of file CVelodyneScanner.h.
Referenced by close(), getNextObservation(), and initialize().
|
private |
Definition at line 431 of file CVelodyneScanner.h.
Referenced by getNextObservation().
|
private |
Definition at line 432 of file CVelodyneScanner.h.
Referenced by getNextObservation(), and initialize().
|
protected |
Definition at line 230 of file CVelodyneScanner.h.
Referenced by initialize(), and receivePackets().
|
private |
Definition at line 434 of file CVelodyneScanner.h.
Referenced by initialize(), and loadConfig_sensorSpecific().
|
private |
Definition at line 433 of file CVelodyneScanner.h.
Referenced by initialize(), and loadConfig_sensorSpecific().
|
protectedinherited |
See CGenericSensor.
Definition at line 135 of file CGenericSensor.h.
Referenced by mrpt::hwdrivers::CGenericSensor::loadConfig().
|
protected |
Default: "VLP16".
Definition at line 212 of file CVelodyneScanner.h.
Referenced by getModelName(), getNextObservation(), initialize(), loadConfig_sensorSpecific(), and setModelName().
|
privateinherited |
The queue of objects to be returned by getObservations.
Definition at line 120 of file CGenericSensor.h.
Referenced by mrpt::hwdrivers::CGenericSensor::appendObservations(), mrpt::hwdrivers::CGenericSensor::getObservations(), and mrpt::hwdrivers::CGenericSensor::~CGenericSensor().
|
protectedinherited |
The path where to save off-rawlog images: empty means save images embedded in the rawlog.
Definition at line 154 of file CGenericSensor.h.
Referenced by mrpt::hwdrivers::CSwissRanger3DCamera::getNextObservation(), and mrpt::hwdrivers::CSwissRanger3DCamera::setPathForExternalImages().
|
protected |
opaque ptr: "pcap_t*"
Definition at line 234 of file CVelodyneScanner.h.
Referenced by close(), getNextObservation(), initialize(), internal_read_PCAP_packet(), and receivePackets().
|
protected |
opaque ptr: bpf_program*
Definition at line 240 of file CVelodyneScanner.h.
Referenced by CVelodyneScanner(), initialize(), internal_read_PCAP_packet(), and ~CVelodyneScanner().
|
protected |
opaque ptr: "pcap_dumper_t *"
Definition at line 238 of file CVelodyneScanner.h.
Referenced by close(), and receivePackets().
|
protected |
Definition at line 241 of file CVelodyneScanner.h.
Referenced by initialize(), and internal_read_PCAP_packet().
|
protected |
Default: "" (do not operate from an offline file)
Definition at line 224 of file CVelodyneScanner.h.
Referenced by getPCAPInputFile(), initialize(), internal_read_PCAP_packet(), loadConfig_sensorSpecific(), and setPCAPInputFile().
|
protected |
opaque ptr: "pcap_t*"
Definition at line 236 of file CVelodyneScanner.h.
Referenced by close(), and receivePackets().
|
protected |
Default: "" (do not dump to an offline file)
Definition at line 226 of file CVelodyneScanner.h.
Referenced by getPCAPOutputFile(), loadConfig_sensorSpecific(), receivePackets(), and setPCAPOutputFile().
|
protected |
number of pkts read from the file so far (for debugging)
Definition at line 243 of file CVelodyneScanner.h.
Referenced by initialize(), and internal_read_PCAP_packet().
|
protected |
(Default: false) If false, will use m_pcap_read_full_scan_delay_ms
Definition at line 247 of file CVelodyneScanner.h.
Referenced by getNextObservation(), and loadConfig_sensorSpecific().
|
protected |
(Default:100 ms) delay after each full scan read from a PCAP log
Definition at line 249 of file CVelodyneScanner.h.
Referenced by getNextObservation(), and loadConfig_sensorSpecific().
|
protected |
Default: false.
Definition at line 245 of file CVelodyneScanner.h.
Referenced by getPCAPInputFileReadOnce(), internal_read_PCAP_packet(), loadConfig_sensorSpecific(), and setPCAPInputFileReadOnce().
|
protected |
Default: 0 (in seconds)
Definition at line 251 of file CVelodyneScanner.h.
Referenced by internal_read_PCAP_packet(), and loadConfig_sensorSpecific().
|
protected |
Default: true Output PCAP Info msgs.
Definition at line 222 of file CVelodyneScanner.h.
Referenced by initialize(), internal_read_PCAP_packet(), and setPCAPVerbosity().
|
protected |
Default: 0.5 seconds.
Definition at line 214 of file CVelodyneScanner.h.
Referenced by getPosPacketsMinPeriod(), loadConfig_sensorSpecific(), receivePackets(), and setPosPacketsMinPeriod().
|
protected |
Default: 30 seconds.
Definition at line 216 of file CVelodyneScanner.h.
Referenced by getNextObservation(), getPosPacketsTimingTimeout(), loadConfig_sensorSpecific(), and setPosPacketsTimingTimeout().
|
protectedinherited |
See CGenericSensor.
Definition at line 133 of file CGenericSensor.h.
Referenced by mrpt::hwdrivers::CGenericSensor::getProcessRate(), mrpt::hwdrivers::CGyroKVHDSP3000::initialize(), and mrpt::hwdrivers::CGenericSensor::loadConfig().
|
protected |
Default: true Output whole frames and not data packets
Definition at line 220 of file CVelodyneScanner.h.
Referenced by getNextObservation(), and setFramePublishing().
|
private |
In progress RX scan.
Definition at line 429 of file CVelodyneScanner.h.
Referenced by getNextObservation().
|
protectedinherited |
See CGenericSensor.
Definition at line 140 of file CGenericSensor.h.
Referenced by mrpt::hwdrivers::CCANBusReader::CCANBusReader(), mrpt::hwdrivers::CGPSInterface::CGPSInterface(), mrpt::hwdrivers::CGyroKVHDSP3000::CGyroKVHDSP3000(), mrpt::hwdrivers::CHokuyoURG::CHokuyoURG(), mrpt::hwdrivers::CIMUIntersense::CIMUIntersense(), mrpt::hwdrivers::CIMUXSens::CIMUXSens(), mrpt::hwdrivers::CIMUXSens_MT4::CIMUXSens_MT4(), mrpt::hwdrivers::CKinect::CKinect(), mrpt::hwdrivers::CNationalInstrumentsDAQ::CNationalInstrumentsDAQ(), mrpt::hwdrivers::CRoboPeakLidar::CRoboPeakLidar(), mrpt::hwdrivers::CSickLaserSerial::CSickLaserSerial(), mrpt::hwdrivers::CSickLaserUSB::CSickLaserUSB(), mrpt::hwdrivers::CSkeletonTracker::CSkeletonTracker(), mrpt::hwdrivers::CSwissRanger3DCamera::CSwissRanger3DCamera(), CVelodyneScanner(), mrpt::hwdrivers::CIMUXSens_MT4::doProcess(), mrpt::hwdrivers::CIMUXSens::doProcess(), mrpt::hwdrivers::CGyroKVHDSP3000::doProcess(), mrpt::hwdrivers::CIMUIntersense::doProcess(), mrpt::hwdrivers::CSkeletonTracker::doProcess(), mrpt::hwdrivers::CRoboPeakLidar::doProcessSimple(), mrpt::hwdrivers::CSickLaserUSB::doProcessSimple(), mrpt::hwdrivers::CCANBusReader::doProcessSimple(), mrpt::hwdrivers::CSickLaserSerial::doProcessSimple(), mrpt::hwdrivers::CHokuyoURG::doProcessSimple(), mrpt::hwdrivers::CGPSInterface::flushParsedMessagesNow(), mrpt::hwdrivers::CSwissRanger3DCamera::getNextObservation(), mrpt::hwdrivers::CKinect::getNextObservation(), getNextObservation(), mrpt::hwdrivers::CGenericSensor::getSensorLabel(), mrpt::hwdrivers::CNationalInstrumentsDAQ::grabbing_thread(), mrpt::hwdrivers::CGenericSensor::loadConfig(), mrpt::hwdrivers::CSkeletonTracker::processPreview(), mrpt::hwdrivers::C2DRangeFinderAbstract::processPreview(), mrpt::hwdrivers::CSkeletonTracker::processPreviewNone(), and mrpt::hwdrivers::CGenericSensor::setSensorLabel().
|
protected |
Definition at line 227 of file CVelodyneScanner.h.
Referenced by getNextObservation(), and loadConfig_sensorSpecific().
|
protectedinherited |
Definition at line 147 of file CGenericSensor.h.
Referenced by mrpt::hwdrivers::CGyroKVHDSP3000::CGyroKVHDSP3000(), mrpt::hwdrivers::CIMUXSens_MT4::doProcess(), mrpt::hwdrivers::CIMUXSens::doProcess(), mrpt::hwdrivers::CGyroKVHDSP3000::doProcess(), mrpt::hwdrivers::CIMUIntersense::doProcess(), mrpt::hwdrivers::CSkeletonTracker::doProcess(), mrpt::hwdrivers::CSwissRanger3DCamera::doProcess(), mrpt::hwdrivers::C2DRangeFinderAbstract::doProcess(), mrpt::hwdrivers::CGPSInterface::doProcess(), mrpt::hwdrivers::CNationalInstrumentsDAQ::doProcess(), mrpt::hwdrivers::CKinect::doProcess(), doProcess(), mrpt::hwdrivers::CSickLaserUSB::doProcessSimple(), mrpt::hwdrivers::CCANBusReader::doProcessSimple(), mrpt::hwdrivers::CSickLaserSerial::doProcessSimple(), mrpt::hwdrivers::CHokuyoURG::doProcessSimple(), mrpt::hwdrivers::CGPSInterface::flushParsedMessagesNow(), getNextObservation(), mrpt::hwdrivers::CGenericSensor::getState(), mrpt::hwdrivers::CIMUXSens_MT4::initialize(), mrpt::hwdrivers::CIMUXSens::initialize(), mrpt::hwdrivers::CGyroKVHDSP3000::initialize(), mrpt::hwdrivers::CIMUIntersense::initialize(), mrpt::hwdrivers::CSkeletonTracker::initialize(), initialize(), mrpt::hwdrivers::CNationalInstrumentsDAQ::readFromDAQ(), and mrpt::hwdrivers::CIMUXSens::searchPortAndConnect().
|
protected |
Device calibration file (supplied by vendor in an XML file)
Definition at line 229 of file CVelodyneScanner.h.
Referenced by getCalibration(), getNextObservation(), initialize(), loadCalibrationFile(), and setCalibration().
|
protectedinherited |
Definition at line 148 of file CGenericSensor.h.
Referenced by mrpt::hwdrivers::CGenericSensor::CGenericSensor(), mrpt::hwdrivers::CRoboPeakLidar::checkCOMMs(), mrpt::hwdrivers::CNTRIPEmitter::doProcess(), mrpt::hwdrivers::CGPSInterface::doProcess(), mrpt::hwdrivers::CGenericSensor::enableVerbose(), mrpt::hwdrivers::CNationalInstrumentsDAQ::grabbing_thread(), mrpt::hwdrivers::CIMUXSens_MT4::initialize(), mrpt::hwdrivers::CHokuyoURG::initialize(), internal_read_PCAP_packet(), mrpt::hwdrivers::CGenericSensor::isVerboseEnabled(), mrpt::hwdrivers::CGPSInterface::JAVAD_sendMessage(), mrpt::hwdrivers::CGPSInterface::legacy_topcon_setup_commands(), mrpt::hwdrivers::CSickLaserSerial::LMS_setupBaudrate(), mrpt::hwdrivers::CSickLaserSerial::LMS_setupSerialComms(), mrpt::hwdrivers::CSickLaserSerial::LMS_waitIncomingFrame(), mrpt::hwdrivers::CGPSInterface::OnConnectionEstablished(), mrpt::hwdrivers::CGPSInterface::OnConnectionShutdown(), mrpt::hwdrivers::CSickLaserSerial::SendCommandToSICK(), mrpt::hwdrivers::CNationalInstrumentsDAQ::stop(), and mrpt::hwdrivers::CGPSInterface::tryToOpenTheCOM().
|
static |
Default: 2368.
Change it if required.
Definition at line 173 of file CVelodyneScanner.h.
Referenced by initialize(), and internal_read_PCAP_packet().
|
static |
Default: 8308.
Change it if required.
Definition at line 175 of file CVelodyneScanner.h.
Referenced by initialize(), and internal_read_PCAP_packet().
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST |