Public Member Functions | Private Member Functions | Private Attributes
hokuyo::Laser Class Reference

A class for interfacing to an SCIP2.0-compliant Hokuyo laser device. More...

#include <hokuyo.h>

List of all members.

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_

Detailed Description

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.

Definition at line 123 of file hokuyo.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 74 of file hokuyo.cpp.

Destructor.

Definition at line 87 of file hokuyo.cpp.


Member Function Documentation

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.

Parameters:
intensityWhether or not intensity data should be provided
min_angMinimal angle of the scan (radians)
max_angMaximum angle of the scan (radians)
clusteringNumber of adjascent ranges to be clustered into a single measurement
skipNumber of scans to skip between returning measurements
numNumber of times to repeat the measurement 0 for auto.
timeoutTimeout in milliseconds.
Returns:
Median latency in nanoseconds

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]

This method clears the offset that was computed with calcLatency.

Definition at line 286 of file hokuyo.h.

Close the port.

This call essentiall wraps fclose.

Definition at line 210 of file hokuyo.cpp.

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.

Parameters:
configA reference to the LaserConfig which will be populated
Returns:
Status code returned from hokuyo device.

Definition at line 279 of file hokuyo.cpp.

Return firmware version.

Returns:
Firmware version of hokuyo.

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.

std::string hokuyo::Laser::getID ( )

Return hokuyo serial number.

Returns:
Serial number of hokuyo.

Definition at line 908 of file hokuyo.cpp.

long long hokuyo::Laser::getLatency ( ) [inline]

Returns the latency that is in use.

Returns:
Latency in nanoseconds.

Definition at line 293 of file hokuyo.h.

Return hokuyo product name.

Returns:
Product name of hokuyo.

Definition at line 952 of file hokuyo.cpp.

Return hokuyo protocol version.

Returns:
Protocol version of hokuyo.

Definition at line 930 of file hokuyo.cpp.

std::string hokuyo::Laser::getStatus ( )

Get status message from the hokuyo.

Returns:
Status message

Definition at line 963 of file hokuyo.cpp.

Return hokuyo vendor name.

Returns:
Vendor name of hokuyo.

Definition at line 941 of file hokuyo.cpp.

Tries to determine if intensity mode is supported.

Returns:
True if intensity mode is supported, false if it is not. hokuyo::Exception if no scan could be read even out of intensity mode.

Definition at line 767 of file hokuyo.cpp.

Wrapper around tcflush.

Definition at line 322 of file hokuyo.cpp.

Turn the laser off.

Returns:
Status code returned from hokuyo device.

Definition at line 718 of file hokuyo.cpp.

Turn the laser on.

Returns:
Status code returned from hokuyo device.

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.

Parameters:
port_nameA character array containing the name of the port
Todo:
tcsetattr returns true if at least one attribute was set. Hence, we might not have set everything on success.

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.

Parameters:
scanA reference to the LaserScan which will be populated
min_angMinimal angle of the scan
max_angMaximum angle of the scan
clusteringNumber of adjascent ranges to be clustered into a single measurement.
timeoutTimeout in milliseconds.
Returns:
Status code returned from hokuyo device.

Definition at line 661 of file hokuyo.cpp.

bool hokuyo::Laser::portOpen ( ) [inline]

Check whether the port is open.

Definition at line 157 of file hokuyo.h.

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.

<

Todo:
, Should this be an Infinity Instead?

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.

Parameters:
intensityWhether or not intensity data should be provided
min_angMinimal angle of the scan (radians)
max_angMaximum angle of the scan (radians)
clusteringNumber of adjascent ranges to be clustered into a single measurement
skipNumber of scans to skip between returning measurements
numNumber of scans to return (0 for indefinite)
timeoutTimeout in milliseconds.
Returns:
Status code returned from hokuyo device.
Todo:
check that values are within range?

Definition at line 738 of file hokuyo.cpp.

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.

Parameters:
cmdCommand and arguments in a character array
timeoutTimeout in milliseconds.
Returns:
Status code returned from hokuyo device.

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.

Parameters:
scanA reference to the LaserScan which will be populated.
timeoutTimeout in milliseconds.
Returns:
0 on succes, Status code returned from hokuyo device on failure. (Normally 99 is used for success)

Definition at line 798 of file hokuyo.cpp.

Sends an SCIP2.0 command to the hokuyo device.

Definition at line 235 of file hokuyo.cpp.

Stop retrieving scans.

Returns:
Status code returned from hokuyo device.

Definition at line 723 of file hokuyo.cpp.


Member Data Documentation

int hokuyo::Laser::afrt_ [private]

Definition at line 372 of file hokuyo.h.

int hokuyo::Laser::amax_ [private]

Definition at line 371 of file hokuyo.h.

int hokuyo::Laser::amin_ [private]

Definition at line 370 of file hokuyo.h.

int hokuyo::Laser::ares_ [private]

Definition at line 369 of file hokuyo.h.

int hokuyo::Laser::dmax_ [private]

Definition at line 368 of file hokuyo.h.

int hokuyo::Laser::dmin_ [private]

Definition at line 367 of file hokuyo.h.

std::string hokuyo::Laser::firmware_version_ [private]

Definition at line 389 of file hokuyo.h.

int hokuyo::Laser::laser_fd_ [private]

Definition at line 383 of file hokuyo.h.

unsigned int hokuyo::Laser::last_time_ [private]

Definition at line 377 of file hokuyo.h.

long long hokuyo::Laser::offset_ [private]

Definition at line 381 of file hokuyo.h.

std::string hokuyo::Laser::product_name_ [private]

Definition at line 386 of file hokuyo.h.

std::string hokuyo::Laser::protocol_version_ [private]

Definition at line 388 of file hokuyo.h.

int hokuyo::Laser::rate_ [private]

Definition at line 373 of file hokuyo.h.

char hokuyo::Laser::read_buf[256] [private]

Definition at line 391 of file hokuyo.h.

Definition at line 393 of file hokuyo.h.

Definition at line 392 of file hokuyo.h.

std::string hokuyo::Laser::serial_number_ [private]

Definition at line 387 of file hokuyo.h.

unsigned int hokuyo::Laser::time_repeat_count_ [private]

Definition at line 379 of file hokuyo.h.

std::string hokuyo::Laser::vendor_name_ [private]

Definition at line 385 of file hokuyo.h.

int hokuyo::Laser::wrapped_ [private]

Definition at line 375 of file hokuyo.h.


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


hokuyo_node
Author(s): Brian P. Gerkey, Jeremy Leibs, Blaise Gassend
autogenerated on Tue Apr 22 2014 18:56:48