INTRODUCTION
Overview
Download and Install
Documentation
Publications

REPOSITORY
Libraries

DEVELOPER
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

hokuyo_aist::HokuyoLaser Class Reference

Hokuyo laser scanner class. More...

#include <hokuyo_aist.h>

List of all members.

Public Member Functions

void Open (std::string portOptions)
 Open the laser scanner and begin scanning.
unsigned int OpenWithProbing (std::string portOptions)
 Open the laser scanner and begin scanning, probing the baud rate as necessary.
void Close ()
 Close the connection to the laser scanner.
bool IsOpen () const
 Checks if the connection to the laser scanner is open.
void SetPower (bool on)
 Switch the laser scanner on or off.
void SetBaud (unsigned int baud)
 Change the baud rate when using a serial connection.
void Reset ()
 Reset the laser scanner to its default settings.
void SetMotorSpeed (unsigned int speed)
 Set the speed at which the scanner's sensor spins.
void SetHighSensitivity (bool on)
 Switch the scanner between normal and high sensitivity modes.
void GetSensorInfo (HokuyoSensorInfo *info)
 Get various information about the scanner.
unsigned int GetTime ()
 Get the current value of the scanner's clock in milliseconds.
unsigned int GetRanges (HokuyoData *data, int startStep=-1, int endStep=-1, unsigned int clusterCount=1)
 Get the latest scan data from the scanner.
unsigned int GetRangesByAngle (HokuyoData *data, double startAngle, double endAngle, unsigned int clusterCount=1)
 Get the latest scan data from the scanner.
unsigned int GetNewRanges (HokuyoData *data, int startStep=-1, int endStep=-1, unsigned int clusterCount=1)
 Get a new scan from the scanner.
unsigned int GetNewRangesByAngle (HokuyoData *data, double startAngle, double endAngle, unsigned int clusterCount=1)
 Get a new scan from the scanner.
unsigned int GetNewRangesAndIntensities (HokuyoData *data, int startStep=-1, int endStep=-1, unsigned int clusterCount=1)
 Get a new scan from the scanner with intensity data.
unsigned int GetNewRangesAndIntensitiesByAngle (HokuyoData *data, double startAngle, double endAngle, unsigned int clusterCount=1)
 Get a new scan from the scanner with intensity data.
uint8_t SCIPVersion () const
 Return the major version of the SCIP protocol in use.
void SetVerbose (bool verbose)
 Turns on and off printing of verbose operating information to stderr. Default is off.
void IgnoreUnknowns (bool ignore)
 Enables/disables ignoring unknown lines in sensor info messages. Default is off.
double StepToAngle (unsigned int step)
 A convenience function to convert a step index to an angle.
unsigned int AngleToStep (double angle)
 A convenience function to convert an angle to a step (rounded towards the front).

Detailed Description

Hokuyo laser scanner class.

Provides an interface for interacting with a Hokuyo laser scanner using SCIP protocol version 1 or 2. The FlexiPort library is used to implement the data communications with the scanner. See its documentation for details on controlling the connection.

To use a serial connection, ensure that you do not also have a USB cable connected, as this will force the scanner into USB mode, preventing the serial connection from functioning correctly.

All functions may throw instances of HokuyoError or its children. Exceptions from FlexiPort may also occur.


Member Function Documentation

unsigned int hokuyo_aist::HokuyoLaser::GetNewRanges ( HokuyoData data,
int  startStep = -1,
int  endStep = -1,
unsigned int  clusterCount = 1 
)

Get a new scan from the scanner.

Unlike GetRanges, which returns the most recent scan the scanner took, this function will request a new scan. This means it will wait while the scanner performs the scan, which means the rate at which scans can be retrieved using this function is less than with GetRanges. Otherwise behaves identicallty to GetRanges.

Not available with the SCIP v1 protocol.

Note:
The command used to retrieve a fresh scan is also used for the continuous scanning mode (not yet supported by this library). After completing a scan, it will turn the laser off (in anticipation of another continuous scan command being sent, which will automatically turn the laser back on again). If you want to mix GetNewRanges and GetRanges, you will need to turn the laser on after each call to GetNewRanges.
Parameters:
dataPointer to a HokuyoData object to store the range readings in.
clusterCountThe number of readings to cluster together into a single reading. The minimum value from a cluster is returned as the range for that cluster.
startStepThe first step to get ranges from. Set to -1 for the first scannable step.
endStepThe last step to get ranges from. Set to -1 for the last scannable step.
Returns:
The number of range readings read into data.

References hokuyo_aist::HOKUYO_ERR_NODATA, hokuyo_aist::HOKUYO_ERR_NODESTINATION, hokuyo_aist::HOKUYO_ERR_PROTOCOL, hokuyo_aist::HOKUYO_ERR_SCIPVERSION, and hokuyo_aist::HOKUYO_ERR_UNSUPPORTED.

Referenced by GetNewRangesByAngle().

unsigned int hokuyo_aist::HokuyoLaser::GetNewRangesAndIntensities ( HokuyoData data,
int  startStep = -1,
int  endStep = -1,
unsigned int  clusterCount = 1 
)

Get a new scan from the scanner with intensity data.

Unlike GetRanges, which returns the most recent scan the scanner took, this function will request a new scan. This means it will wait while the scanner performs the scan. Otherwise behaves identicallty to GetRanges.

Not available with the SCIP v1 protocol.

Note:
The command used to retrieve a fresh scan is also used for the continuous scanning mode (not yet supported by this library). After completing a scan, it will turn the laser off (in anticipation of another continuous scan command being sent, which will automatically turn the laser back on again). If you want to mix GetNewRanges and GetRanges, you will need to turn the laser on after each call to GetNewRanges.
Parameters:
dataPointer to a HokuyoData object to store the range readings in.
clusterCountThe number of readings to cluster together into a single reading. The minimum value from a cluster is returned as the range for that cluster.
startStepThe first step to get ranges from. Set to -1 for the first scannable step.
endStepThe last step to get ranges from. Set to -1 for the last scannable step.
Returns:
The number of range readings read into data.

References hokuyo_aist::HOKUYO_ERR_NODATA, hokuyo_aist::HOKUYO_ERR_NODESTINATION, hokuyo_aist::HOKUYO_ERR_PROTOCOL, hokuyo_aist::HOKUYO_ERR_SCIPVERSION, and hokuyo_aist::HOKUYO_ERR_UNSUPPORTED.

Referenced by GetNewRangesAndIntensitiesByAngle().

unsigned int hokuyo_aist::HokuyoLaser::GetNewRangesAndIntensitiesByAngle ( HokuyoData data,
double  startAngle,
double  endAngle,
unsigned int  clusterCount = 1 
)

Get a new scan from the scanner with intensity data.

Not available with the SCIP v1 protocol.

Parameters:
dataPointer to a HokuyoData object to store the range readings in.
startAngleThe angle to get range readings from. Exclusive; if this falls between two steps the step inside the angle will be returned, but the step outside won't.
endAngleThe angle to get range readings to. Exclusive; if this falls between two steps the step inside the angle will be returned, but the step outside won't.
clusterCountThe number of readings to cluster together into a single reading. The minimum value from a cluster is returned as the range for that cluster.
Returns:
The number of range readings read into data.

References AngleToStep(), GetNewRangesAndIntensities(), hokuyo_aist::HOKUYO_ERR_BADARG, hokuyo_aist::HOKUYO_ERR_NODESTINATION, and hokuyo_aist::HOKUYO_ERR_UNSUPPORTED.

unsigned int hokuyo_aist::HokuyoLaser::GetNewRangesByAngle ( HokuyoData data,
double  startAngle,
double  endAngle,
unsigned int  clusterCount = 1 
)

Get a new scan from the scanner.

Not available with the SCIP v1 protocol.

Parameters:
dataPointer to a HokuyoData object to store the range readings in.
startAngleThe angle to get range readings from. Exclusive; if this falls between two steps the step inside the angle will be returned, but the step outside won't.
endAngleThe angle to get range readings to. Exclusive; if this falls between two steps the step inside the angle will be returned, but the step outside won't.
clusterCountThe number of readings to cluster together into a single reading. The minimum value from a cluster is returned as the range for that cluster.
Returns:
The number of range readings read into data.

References AngleToStep(), GetNewRanges(), hokuyo_aist::HOKUYO_ERR_BADARG, hokuyo_aist::HOKUYO_ERR_NODESTINATION, and hokuyo_aist::HOKUYO_ERR_UNSUPPORTED.

unsigned int hokuyo_aist::HokuyoLaser::GetRanges ( HokuyoData data,
int  startStep = -1,
int  endStep = -1,
unsigned int  clusterCount = 1 
)

Get the latest scan data from the scanner.

This function requires a pointer to a HokuyoData object. It will allocate space in this object as necessary for storing range data. If the passed-in HokuyoData object already has the correct quantity of space to store the range data, it will not be re-allocated. If it does not have any space, it will be allocated. If it has space, but it is the wrong size, it will be re-allocated. This means you can repeatedly send the same HokuyoData object without having to worry about allocating its data, whether it will change or not, while also avoiding excessive allocations.

Parameters:
dataPointer to a HokuyoData object to store the range readings in.
clusterCountThe number of readings to cluster together into a single reading. The minimum value from a cluster is returned as the range for that cluster.
startStepThe first step to get ranges from. Set to -1 for the first scannable step.
endStepThe last step to get ranges from. Set to -1 for the last scannable step.
Returns:
The number of range readings read into data.

References hokuyo_aist::HOKUYO_ERR_NODATA, hokuyo_aist::HOKUYO_ERR_NODESTINATION, and hokuyo_aist::HOKUYO_ERR_SCIPVERSION.

Referenced by GetRangesByAngle().

unsigned int hokuyo_aist::HokuyoLaser::GetRangesByAngle ( HokuyoData data,
double  startAngle,
double  endAngle,
unsigned int  clusterCount = 1 
)

Get the latest scan data from the scanner.

Parameters:
dataPointer to a HokuyoData object to store the range readings in.
startAngleThe angle to get range readings from. Exclusive; if this falls between two steps the step inside the angle will be returned, but the step outside won't.
endAngleThe angle to get range readings to. Exclusive; if this falls between two steps the step inside the angle will be returned, but the step outside won't.
clusterCountThe number of readings to cluster together into a single reading. The minimum value from a cluster is returned as the range for that cluster.
Returns:
The number of range readings read into data.

References AngleToStep(), GetRanges(), hokuyo_aist::HOKUYO_ERR_BADARG, and hokuyo_aist::HOKUYO_ERR_NODESTINATION.

unsigned int hokuyo_aist::HokuyoLaser::GetTime ( )

Get the current value of the scanner's clock in milliseconds.

Not available with the SCIP v1 protocol.

References hokuyo_aist::HOKUYO_ERR_SCIPVERSION, and hokuyo_aist::HOKUYO_ERR_UNSUPPORTED.

unsigned int hokuyo_aist::HokuyoLaser::OpenWithProbing ( std::string  portOptions)

Open the laser scanner and begin scanning, probing the baud rate as necessary.

If the port is a serial connection and communication with the laser fails at the given baud rate, the alternative baud rates supported by the device are tried (see SetBaud for these) in order from fastest to slowest.

Returns:
The baud rate at which connection with the laser succeeded, or 0 for non-serial connections.

References flexiport::CreatePort(), flexiport::Port::Flush(), flexiport::Port::GetPortType(), flexiport::Port::GetStatus(), and flexiport::Port::Open().

void hokuyo_aist::HokuyoLaser::Reset ( )

Reset the laser scanner to its default settings.

Not available with the SCIP v1 protocol.

References hokuyo_aist::HOKUYO_ERR_SCIPVERSION, and hokuyo_aist::HOKUYO_ERR_UNSUPPORTED.

void hokuyo_aist::HokuyoLaser::SetBaud ( unsigned int  baud)

Change the baud rate when using a serial connection.

Valid rates are 19.2Kbps, 38.4Kbps, 57.6Kbps, 115.2Kbps, 250.0Kbps, 500.0Kbps, 750.0Kbps (dependent on those available in FlexiPort).

References flexiport::Port::GetPortType(), hokuyo_aist::HOKUYO_ERR_BADARG, hokuyo_aist::HOKUYO_ERR_NOTSERIAL, and hokuyo_aist::HOKUYO_ERR_SCIPVERSION.

void hokuyo_aist::HokuyoLaser::SetMotorSpeed ( unsigned int  speed)

Set the speed at which the scanner's sensor spins.

Set the speed to 0 to have it reset to the default value, and 99 to reset it to the initial (startup) value. Values between 1 and 10 specify a ratio of the default speed. The speeds in revolutions per minute that these correspond to will depend on the scanner model. For example, for a URG-04LX, they are (from 1 to 10) 594, 588, 576, 570, 564, 558, 552, 546, and 540 rpm.

Not available with the SCIP v1 protocol.

References hokuyo_aist::HOKUYO_ERR_BADARG, hokuyo_aist::HOKUYO_ERR_SCIPVERSION, and hokuyo_aist::HOKUYO_ERR_UNSUPPORTED.


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

Generated for GearBox by  doxygen 1.4.5