A class for interfacing to an SCIP2.0-compliant Hokuyo laser device. More...
#include <hokuyo.h>
Public Member Functions | |
long long | calcLatency (bool intensity, double min_ang, double max_ang, int clustering=0, int skip=0, int num=0, int timeout=-1) |
Compute latency between actual hokuyo readings and system time. | |
void | clearLatency () |
This method clears the offset that was computed with calcLatency. | |
void | close () |
Close the port. | |
void | getConfig (LaserConfig &config) |
Retrieve the native hokuyo configuration. | |
std::string | getFirmwareVersion () |
Return firmware version. | |
std::string | getID () |
Return hokuyo serial number. | |
long long | getLatency () |
std::string | getProductName () |
Return hokuyo product name. | |
std::string | getProtocolVersion () |
Return hokuyo protocol version. | |
std::string | getStatus () |
Get status message from the hokuyo. | |
std::string | getVendorName () |
Return hokuyo vendor name. | |
bool | isIntensitySupported () |
Tries to determine if intensity mode is supported. | |
Laser () | |
Constructor. | |
int | laserFlush () |
Wrapper around tcflush. | |
int | laserOff () |
Turn the laser off. | |
int | laserOn () |
Turn the laser on. | |
int | laserReadline (char *buf, int len, int timeout=-1) |
Read a full line from the hokuyo using fgets. | |
int | laserWrite (const char *msg) |
Wrapper around fputs. | |
void | open (const char *port_name) |
Open the port. | |
int | pollScan (LaserScan &scan, double min_ang, double max_ang, int clustering=0, int timeout=-1) |
Retrieve a single scan from the hokuyo. | |
bool | portOpen () |
Check whether the port is open. | |
void | queryVersionInformation () |
uint64_t | readTime (int timeout=-1) |
Read in a time value. | |
int | requestScans (bool intensity, double min_ang, double max_ang, int clustering=0, int skip=0, int num=0, int timeout=-1) |
Request a sequence of scans from the hokuyo. | |
void | reset () |
Reset the laser to its power on state. | |
int | sendCmd (const char *cmd, int timeout=-1) |
int | serviceScan (LaserScan &scan, int timeout=-1) |
Retrieve a scan if they have been requested. | |
void | setToSCIP2 () |
Sends an SCIP2.0 command to the hokuyo device. | |
int | stopScanning () |
Stop retrieving scans. | |
~Laser () | |
Destructor. | |
Private Member Functions | |
bool | checkSum (const char *buf, int buf_len) |
Compute the checksum of a given buffer. | |
long long int | getHokuyoClockOffset (int reps, int timeout=-1) |
Use the TM command to determine the offset between the PC clock and. | |
long long int | getHokuyoScanStampToSystemStampOffset (bool intensity, double min_ang, double max_ang, int clustering, int skip, int reps, int timeout=-1) |
Get reps scans and returns the median difference between the system. | |
char * | laserReadlineAfter (char *buf, int len, const char *str, int timeout=-1) |
Search for a particular sequence and then read the rest of the line. | |
void | querySensorConfig () |
Query the sensor configuration of the hokuyo. | |
void | readData (LaserScan &scan, bool has_intensity, int timout=-1) |
Read in a scan. | |
Private Attributes | |
int | afrt_ |
int | amax_ |
int | amin_ |
int | ares_ |
int | dmax_ |
int | dmin_ |
std::string | firmware_version_ |
int | laser_fd_ |
unsigned int | last_time_ |
long long | offset_ |
std::string | product_name_ |
std::string | protocol_version_ |
int | rate_ |
char | read_buf [256] |
int | read_buf_end |
int | read_buf_start |
std::string | serial_number_ |
unsigned int | time_repeat_count_ |
std::string | vendor_name_ |
int | wrapped_ |
A class for interfacing to an SCIP2.0-compliant Hokuyo laser device.
Almost all methods of this class may throw an exception of type hokuyo::Exception in the event of an error when communicating with the device. This primarily include read/write problems (hokuyo::Exception), communication time-outs (hokuyo:TimeoutException), and corrupted data (hokuyo::CorruptedDataException). However, many methods which wrap commands that are sent to the hokuyo will return a hokuyo-supplied status code as well. These are not "exceptional," in that the device is operating correctly from a communication standpoint, although the return code may still indicate that the device has undergone some sort of failure. In these cases, return codes of 0 are normal operation. For more information on the possible device error codes, consult the hokuyo manual.
Constructor.
Definition at line 74 of file hokuyo.cpp.
Destructor.
Definition at line 87 of file hokuyo.cpp.
long long hokuyo::Laser::calcLatency | ( | bool | intensity, |
double | min_ang, | ||
double | max_ang, | ||
int | clustering = 0 , |
||
int | skip = 0 , |
||
int | num = 0 , |
||
int | timeout = -1 |
||
) |
Compute latency between actual hokuyo readings and system time.
This function will estimate the latency between when the data is actually acquired by the hokuyo and a read call returns from the hokuyo with the data. This latency is stored in an offset variable and applied to the measurement of system time which occurs immediately after a read. This means that the system_time_stamp variable on LaserScan struct is corrected and accurately reflects the exact time of the hokuyo data in computer system time. This function takes the same arguments as a call to request scans, since this latency may be parameter dependent. NOTE: This method will take approximately 10 seconds to return.
intensity | Whether or not intensity data should be provided |
min_ang | Minimal angle of the scan (radians) |
max_ang | Maximum angle of the scan (radians) |
clustering | Number of adjascent ranges to be clustered into a single measurement |
skip | Number of scans to skip between returning measurements |
num | Number of times to repeat the measurement 0 for auto. |
timeout | Timeout in milliseconds. |
Definition at line 1047 of file hokuyo.cpp.
bool hokuyo::Laser::checkSum | ( | const char * | buf, |
int | buf_len | ||
) | [private] |
Compute the checksum of a given buffer.
Definition at line 452 of file hokuyo.cpp.
void hokuyo::Laser::clearLatency | ( | ) | [inline] |
void hokuyo::Laser::close | ( | ) |
void hokuyo::Laser::getConfig | ( | LaserConfig & | config | ) |
Retrieve the native hokuyo configuration.
This function will retrieve the native configuration for the laser. In particular, this specifies the smallest possible min, and largest possible maximum values that can be used.
config | A reference to the LaserConfig which will be populated |
Definition at line 279 of file hokuyo.cpp.
Return firmware version.
Definition at line 919 of file hokuyo.cpp.
long long int hokuyo::Laser::getHokuyoClockOffset | ( | int | reps, |
int | timeout = -1 |
||
) | [private] |
Use the TM command to determine the offset between the PC clock and.
Definition at line 998 of file hokuyo.cpp.
long long int hokuyo::Laser::getHokuyoScanStampToSystemStampOffset | ( | bool | intensity, |
double | min_ang, | ||
double | max_ang, | ||
int | clustering, | ||
int | skip, | ||
int | reps, | ||
int | timeout = -1 |
||
) | [private] |
Get reps scans and returns the median difference between the system.
Definition at line 1019 of file hokuyo.cpp.
Return hokuyo serial number.
Definition at line 908 of file hokuyo.cpp.
long long hokuyo::Laser::getLatency | ( | ) | [inline] |
Return hokuyo product name.
Definition at line 952 of file hokuyo.cpp.
Return hokuyo protocol version.
Definition at line 930 of file hokuyo.cpp.
Get status message from the hokuyo.
Definition at line 963 of file hokuyo.cpp.
Return hokuyo vendor name.
Definition at line 941 of file hokuyo.cpp.
bool hokuyo::Laser::isIntensitySupported | ( | ) |
Tries to determine if intensity mode is supported.
Definition at line 767 of file hokuyo.cpp.
int hokuyo::Laser::laserFlush | ( | ) |
Wrapper around tcflush.
Definition at line 322 of file hokuyo.cpp.
int hokuyo::Laser::laserOff | ( | ) |
Turn the laser off.
Definition at line 718 of file hokuyo.cpp.
int hokuyo::Laser::laserOn | ( | ) |
Turn the laser on.
Definition at line 710 of file hokuyo.cpp.
int hokuyo::Laser::laserReadline | ( | char * | buf, |
int | len, | ||
int | timeout = -1 |
||
) |
Read a full line from the hokuyo using fgets.
Definition at line 336 of file hokuyo.cpp.
char * hokuyo::Laser::laserReadlineAfter | ( | char * | buf, |
int | len, | ||
const char * | str, | ||
int | timeout = -1 |
||
) | [private] |
Search for a particular sequence and then read the rest of the line.
Definition at line 393 of file hokuyo.cpp.
int hokuyo::Laser::laserWrite | ( | const char * | msg | ) |
Wrapper around fputs.
Definition at line 293 of file hokuyo.cpp.
void hokuyo::Laser::open | ( | const char * | port_name | ) |
Open the port.
This must be done before the hokuyo can be used. This call essentially wraps fopen, with some additional calls to tcsetattr.
port_name | A character array containing the name of the port |
Definition at line 96 of file hokuyo.cpp.
int hokuyo::Laser::pollScan | ( | hokuyo::LaserScan & | scan, |
double | min_ang, | ||
double | max_ang, | ||
int | clustering = 0 , |
||
int | timeout = -1 |
||
) |
Retrieve a single scan from the hokuyo.
scan | A reference to the LaserScan which will be populated |
min_ang | Minimal angle of the scan |
max_ang | Maximum angle of the scan |
clustering | Number of adjascent ranges to be clustered into a single measurement. |
timeout | Timeout in milliseconds. |
Definition at line 661 of file hokuyo.cpp.
bool hokuyo::Laser::portOpen | ( | ) | [inline] |
void hokuyo::Laser::querySensorConfig | ( | ) | [private] |
Query the sensor configuration of the hokuyo.
Definition at line 414 of file hokuyo.cpp.
Call VV and store the returned version information Use other methods to read the information.
Definition at line 870 of file hokuyo.cpp.
void hokuyo::Laser::readData | ( | hokuyo::LaserScan & | scan, |
bool | has_intensity, | ||
int | timout = -1 |
||
) | [private] |
Read in a scan.
<
Definition at line 502 of file hokuyo.cpp.
uint64_t hokuyo::Laser::readTime | ( | int | timeout = -1 | ) |
Read in a time value.
Definition at line 467 of file hokuyo.cpp.
int hokuyo::Laser::requestScans | ( | bool | intensity, |
double | min_ang, | ||
double | max_ang, | ||
int | clustering = 0 , |
||
int | skip = 0 , |
||
int | num = 0 , |
||
int | timeout = -1 |
||
) |
Request a sequence of scans from the hokuyo.
This function will request a sequence of scans from the hokuyo. If indefinite scans are requested, stop_scanning() must be called to terminate scanning. Service_scan() must be called repeatedly to receive scans as they come in.
intensity | Whether or not intensity data should be provided |
min_ang | Minimal angle of the scan (radians) |
max_ang | Maximum angle of the scan (radians) |
clustering | Number of adjascent ranges to be clustered into a single measurement |
skip | Number of scans to skip between returning measurements |
num | Number of scans to return (0 for indefinite) |
timeout | Timeout in milliseconds. |
Definition at line 738 of file hokuyo.cpp.
void hokuyo::Laser::reset | ( | ) |
Reset the laser to its power on state.
This calls TM2 and RS. Exceptions raised by TM2 are ignored as they are normal in the case where the laser is scanning. Exceptions raised by RS are passed back to the caller.
Definition at line 184 of file hokuyo.cpp.
int hokuyo::Laser::sendCmd | ( | const char * | cmd, |
int | timeout = -1 |
||
) |
This function allows commands to be sent directly to the hokuyo. Possible commands can be found in the hokuyo documentation. It will only read up until the end of the status code. Any additional bytes will be left on the line for parsing.
cmd | Command and arguments in a character array |
timeout | Timeout in milliseconds. |
Definition at line 252 of file hokuyo.cpp.
int hokuyo::Laser::serviceScan | ( | hokuyo::LaserScan & | scan, |
int | timeout = -1 |
||
) |
Retrieve a scan if they have been requested.
scan | A reference to the LaserScan which will be populated. |
timeout | Timeout in milliseconds. |
Definition at line 798 of file hokuyo.cpp.
void hokuyo::Laser::setToSCIP2 | ( | ) |
Sends an SCIP2.0 command to the hokuyo device.
Definition at line 235 of file hokuyo.cpp.
int hokuyo::Laser::stopScanning | ( | ) |
Stop retrieving scans.
Definition at line 723 of file hokuyo.cpp.
int hokuyo::Laser::afrt_ [private] |
int hokuyo::Laser::amax_ [private] |
int hokuyo::Laser::amin_ [private] |
int hokuyo::Laser::ares_ [private] |
int hokuyo::Laser::dmax_ [private] |
int hokuyo::Laser::dmin_ [private] |
std::string hokuyo::Laser::firmware_version_ [private] |
int hokuyo::Laser::laser_fd_ [private] |
unsigned int hokuyo::Laser::last_time_ [private] |
long long hokuyo::Laser::offset_ [private] |
std::string hokuyo::Laser::product_name_ [private] |
std::string hokuyo::Laser::protocol_version_ [private] |
int hokuyo::Laser::rate_ [private] |
char hokuyo::Laser::read_buf[256] [private] |
int hokuyo::Laser::read_buf_end [private] |
int hokuyo::Laser::read_buf_start [private] |
std::string hokuyo::Laser::serial_number_ [private] |
unsigned int hokuyo::Laser::time_repeat_count_ [private] |
std::string hokuyo::Laser::vendor_name_ [private] |
int hokuyo::Laser::wrapped_ [private] |