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 122 of file hokuyo.h.


Constructor & Destructor Documentation

hokuyo::Laser::Laser (  ) 

Constructor.

Definition at line 74 of file hokuyo.cpp.

hokuyo::Laser::~Laser (  ) 

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:
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.
Returns:
Median latency in nanoseconds

Definition at line 949 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 285 of file hokuyo.h.

void hokuyo::Laser::close (  ) 

Close the port.

This call essentiall wraps fclose.

Definition at line 210 of file hokuyo.cpp.

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.

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

Definition at line 279 of file hokuyo.cpp.

std::string hokuyo::Laser::getFirmwareVersion (  ) 

Return firmware version.

Returns:
Firmware version of hokuyo.

Definition at line 821 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 900 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 921 of file hokuyo.cpp.

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

Return hokuyo serial number.

Returns:
Serial number of hokuyo.

Definition at line 810 of file hokuyo.cpp.

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

Returns the latency that is in use.

Returns:
Latency in nanoseconds.

Definition at line 292 of file hokuyo.h.

std::string hokuyo::Laser::getProductName (  ) 

Return hokuyo product name.

Returns:
Product name of hokuyo.

Definition at line 854 of file hokuyo.cpp.

std::string hokuyo::Laser::getProtocolVersion (  ) 

Return hokuyo protocol version.

Returns:
Protocol version of hokuyo.

Definition at line 832 of file hokuyo.cpp.

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

Get status message from the hokuyo.

Returns:
Status message

Definition at line 865 of file hokuyo.cpp.

std::string hokuyo::Laser::getVendorName (  ) 

Return hokuyo vendor name.

Returns:
Vendor name of hokuyo.

Definition at line 843 of file hokuyo.cpp.

bool hokuyo::Laser::isIntensitySupported (  ) 

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 669 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.

Returns:
Status code returned from hokuyo device.

Definition at line 620 of file hokuyo.cpp.

int hokuyo::Laser::laserOn (  ) 

Turn the laser on.

Returns:
Status code returned from hokuyo device.

Definition at line 612 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_name A 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:
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.
Returns:
Status code returned from hokuyo device.

Definition at line 563 of file hokuyo.cpp.

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

Check whether the port is open.

Definition at line 156 of file hokuyo.h.

void hokuyo::Laser::querySensorConfig (  )  [private]

Query the sensor configuration of the hokuyo.

Definition at line 414 of file hokuyo.cpp.

void hokuyo::Laser::queryVersionInformation (  ) 

Call VV and store the returned version information Use other methods to read the information.

Definition at line 772 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.

Parameters:
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.
Returns:
Status code returned from hokuyo device.

Todo:
check that values are within range?

Definition at line 640 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.

Parameters:
cmd Command and arguments in a character array
timeout Timeout 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:
scan A reference to the LaserScan which will be populated.
timeout Timeout in milliseconds.
Returns:
0 on succes, Status code returned from hokuyo device on failure. (Normally 99 is used for success)

Definition at line 700 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.

Returns:
Status code returned from hokuyo device.

Definition at line 625 of file hokuyo.cpp.


Member Data Documentation

int hokuyo::Laser::afrt_ [private]

Definition at line 371 of file hokuyo.h.

int hokuyo::Laser::amax_ [private]

Definition at line 370 of file hokuyo.h.

int hokuyo::Laser::amin_ [private]

Definition at line 369 of file hokuyo.h.

int hokuyo::Laser::ares_ [private]

Definition at line 368 of file hokuyo.h.

int hokuyo::Laser::dmax_ [private]

Definition at line 367 of file hokuyo.h.

int hokuyo::Laser::dmin_ [private]

Definition at line 366 of file hokuyo.h.

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

Definition at line 388 of file hokuyo.h.

int hokuyo::Laser::laser_fd_ [private]

Definition at line 382 of file hokuyo.h.

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

Definition at line 376 of file hokuyo.h.

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

Definition at line 380 of file hokuyo.h.

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

Definition at line 385 of file hokuyo.h.

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

Definition at line 387 of file hokuyo.h.

int hokuyo::Laser::rate_ [private]

Definition at line 372 of file hokuyo.h.

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

Definition at line 390 of file hokuyo.h.

Definition at line 392 of file hokuyo.h.

Definition at line 391 of file hokuyo.h.

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

Definition at line 386 of file hokuyo.h.

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

Definition at line 378 of file hokuyo.h.

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

Definition at line 384 of file hokuyo.h.

int hokuyo::Laser::wrapped_ [private]

Definition at line 374 of file hokuyo.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines


hokuyo_node
Author(s): Brian P. Gerkey, Jeremy Leibs, Blaise Gassend
autogenerated on Fri Jan 11 09:40:51 2013