hokuyo
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
URG Class Reference

#include <hokuyo.hh>

Inheritance diagram for URG:

Classes

struct  DeviceInfo
 
struct  SimpleCommand
 
struct  StatusCode
 

Public Types

enum  ERROR_CODES {
  OK = 0, INTERNAL_COM_FAILED = 2, DEVICE_BUFFER_OVERFLOW = 3, BAD_COMMAND = 4,
  STRING_TOO_LONG = 5, BAD_STRING = 6, FIRMWARE_UPDATE = 7, LASER_MALFUNCTION = 8,
  HARDWARE_FAILURE = 9, NON_APPLICABLE = 10, BAD_REPLY = 100, DRIVER_BUFFER_OVERFLOW = 121,
  PROVIDED_BUFFER_TOO_SMALL = 122, BAD_STATE = 123, READ_FAILED = 124, BAD_RATE = 125,
  WRITE_FAILED = 126, READ_TIMEOUT = 127, NOT_SCIP2_CAPABLE = 128, BAD_HOST_RATE = 129,
  INCONSISTEN_RANGE_COUNT = 130, WRITE_TIMEOUT = 131, DUPLICATE = 132, UNKNOWN = 200,
  INTERNAL_ERROR = 201, UNKNOWN_DEVICE_VERSION = 202, END = 500
}
 

Public Member Functions

 URG ()
 
 ~URG ()
 
void openURI (std::string const &filename)
 
bool open (std::string const &filename)
 
bool fullSerialReset ()
 
bool initCommunication (int timeout=1000)
 
bool measureCommunicationLatency (int timeout=1000)
 
void close ()
 
DeviceInfo getInfo () const
 
bool startAcquisition (int nScans, int startStep=-1, int endStep=-1, int scanInterval=0, int clusterCount=1, bool includeRemission=false)
 
bool stopAcquisition ()
 
bool readRanges (base::samples::LaserScan &range, int timeout=-1)
 
bool setBaudrate (int brate)
 
int getPacketCounter ()
 
ERROR_CODES error () const
 
char const * errorString () const
 

Static Public Member Functions

static char const * errorString (int error_code)
 

Static Public Attributes

static const int MDMS_COMMAND_LENGTH = 15
 
static const int MDMS_TIMESTAMP_OFFSET = MDMS_COMMAND_LENGTH + 5
 
static const int MDMS_DATA_OFFSET = MDMS_TIMESTAMP_OFFSET + 6
 

Protected Member Functions

int extractPacket (uint8_t const *buffer, size_t buffer_size) const
 

Detailed Description

This class implements a driver for the Hokuyo laser range finders.

Note on error handling: all methods return a boolean argument. If the returned value is true, everything is fine. Otherwise, an error occured and the exact error code is returned by URG::error(). URG::ERROR_CODES lists all error codes and URG::errorString(int) can return a string describing the exact error.

Member Enumeration Documentation

◆ ERROR_CODES

All the possible error codes that can be returned by URG::error()

Enumerator
OK 
INTERNAL_COM_FAILED 
DEVICE_BUFFER_OVERFLOW 
BAD_COMMAND 
STRING_TOO_LONG 
BAD_STRING 
FIRMWARE_UPDATE 
LASER_MALFUNCTION 
HARDWARE_FAILURE 
NON_APPLICABLE 
BAD_REPLY 
DRIVER_BUFFER_OVERFLOW 
PROVIDED_BUFFER_TOO_SMALL 
BAD_STATE 
READ_FAILED 
BAD_RATE 
WRITE_FAILED 
READ_TIMEOUT 
NOT_SCIP2_CAPABLE 
BAD_HOST_RATE 
INCONSISTEN_RANGE_COUNT 
WRITE_TIMEOUT 
DUPLICATE 
UNKNOWN 
INTERNAL_ERROR 
UNKNOWN_DEVICE_VERSION 
END 

Constructor & Destructor Documentation

◆ URG()

URG::URG ( )

◆ ~URG()

URG::~URG ( )

Member Function Documentation

◆ close()

void URG::close ( )

Closes the device

◆ error()

ERROR_CODES URG::error ( ) const
inline

Returns the last error code registered by the driver

◆ errorString() [1/2]

char const * URG::errorString ( int  error_code)
static

Returns the string describing the given error code

◆ errorString() [2/2]

char const* URG::errorString ( ) const
inline

Returns a string describing the current error

◆ extractPacket()

int URG::extractPacket ( uint8_t const *  buffer,
size_t  buffer_size 
) const
protected

◆ fullSerialReset()

bool URG::fullSerialReset ( )

Performs a full reset of the device. After this call, the device baud rate is 19200 and it is not scanning

◆ getInfo()

DeviceInfo URG::getInfo ( ) const
inline

Returns the device info structure. This does not access the device, as the structure is read at initialization in open()

◆ getPacketCounter()

int URG::getPacketCounter ( )

Returns the packet counter for the last received laser scan.

Note the packet counter is calculated from the internal time of the laser scanner.

◆ initCommunication()

bool URG::initCommunication ( int  timeout = 1000)

Initializes communication to the device

◆ measureCommunicationLatency()

bool URG::measureCommunicationLatency ( int  timeout = 1000)

Measures communication latency

◆ open()

bool URG::open ( std::string const &  filename)

Open the device, reset it and read device information. After this call, the baud rate is 19200 and the device is not scanning

◆ openURI()

void URG::openURI ( std::string const &  filename)

Open the device, reset it and read device information. After this call, the baud rate is 19200 and the device is not scanning

◆ readRanges()

bool URG::readRanges ( base::samples::LaserScan &  range,
int  timeout = -1 
)

Gets a range reading and decodes it into range. If timeout is positive, it is how much time, in milliseconds, we should wait for an answer. If it is -1, it is set to twice the scan duration

◆ setBaudrate()

bool URG::setBaudrate ( int  brate)

Sets the device baudrate (only possible for serial devices). +brate+ is the baud rate in bps, can be one of 19200, 57600 and 115200

If the device is not open yet, this baud rate will be set on startup (i.e. in open())

◆ startAcquisition()

bool URG::startAcquisition ( int  nScans,
int  startStep = -1,
int  endStep = -1,
int  scanInterval = 0,
int  clusterCount = 1,
bool  includeRemission = false 
)

Start continuous acquisition. Call readRanges() to get a frame.

  • nFrames the count of frames to acquire
  • startStep the step at which to start reading ranges. See the device information to get minimal and maximal readable steps. Set to -1 to use the first readable step defined for the device.
  • endStep the step at which to stop reading ranges. See the device information to get minimal and maximal readable steps. Set to -1 to use the first readable step defined for the device.
  • scanInterval the count of scans to ignore between two reported scans.
  • clusterCount how many ranges the device should merge into one reported range
  • includeRemission ask the device to also include remission values

◆ stopAcquisition()

bool URG::stopAcquisition ( )

Stop continuous acquisition

Member Data Documentation

◆ MDMS_COMMAND_LENGTH

const int URG::MDMS_COMMAND_LENGTH = 15
static

For internal use

◆ MDMS_DATA_OFFSET

const int URG::MDMS_DATA_OFFSET = MDMS_TIMESTAMP_OFFSET + 6
static

For internal use

◆ MDMS_TIMESTAMP_OFFSET

const int URG::MDMS_TIMESTAMP_OFFSET = MDMS_COMMAND_LENGTH + 5
static

For internal use


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