URG sensor control. More...
#include <UrgCtrl.h>
Public Types | |
enum | { DefaultBaudrate = 115200, DefaultRetryTimes = 8, Infinity = 0, Off = 0, On = 1 } |
Parameter of options. More... | |
Public Member Functions | |
int | capture (std::vector< long > &data, long *timestamp=NULL) |
Get data. | |
RangeCaptureMode | captureMode (void) |
Data acquisition mode. | |
int | captureWithIntensity (std::vector< long > &data, std::vector< long > &intensity_data, long *timestamp=NULL) |
bool | connect (const char *device, long baudrate=DefaultBaudrate) |
Connection. | |
Connection * | connection (void) |
Get connection object. | |
void | disconnect (void) |
Disconnect. | |
double | index2rad (const int index) const |
Radian to angle conversion of data index. | |
bool | isConnected (void) const |
Returns connection status. | |
bool | loadParameter (void) |
Again read the URG parameter. | |
long | maxDistance (void) const |
Get valid maximum distance. | |
int | maxScanLines (void) const |
Get Max scan index. | |
long | minDistance (void) const |
Get valid minimum distance. | |
RangeSensorParameter | parameter (void) const |
Get URG parameter. | |
int | rad2index (const double radian) const |
radian Convert angle in radian to data index | |
bool | reboot (void) |
Reboot URG. | |
long | recentTimestamp (void) const |
Latest time stamp value. | |
size_t | remainCaptureTimes (void) |
Get number of remaining capture times. | |
bool | reset (void) |
Reboot URG. | |
int | scanMsec (void) const |
Time taken for 1scan. | |
void | setCaptureFrameInterval (size_t interval) |
Acquisition interval of scanning data. | |
void | setCaptureMode (RangeCaptureMode mode) |
Specification of data acquisition mode. | |
void | setCaptureRange (int begin_index, int end_index) |
Specifies the range of data acquisition. | |
void | setCaptureSkipLines (size_t skip_lines) |
Specify the number of scanline to be skipped. | |
void | setCapturesSize (size_t size) |
Set number of scan data stored internally. | |
void | setCaptureTimes (size_t times) |
Specify the frequency of data acquisition. | |
void | setConnection (Connection *con) |
Specifies the connection object. | |
bool | setLaserOutput (bool on) |
Laser turn Off/ turn On. | |
void | setParameter (const RangeSensorParameter ¶meter) |
Update URG parameter. | |
void | setRetryTimes (size_t times) |
Set number of retry times when connection failed. | |
bool | setTimestamp (int timestamp=0, int *response_msec=NULL, int *force_delay_msec=NULL) |
Sets the timestamp value. Sensor returs this timestamp value. | |
void | stop (void) |
Stop data acquisition. | |
UrgCtrl (void) | |
bool | versionLines (std::vector< std::string > &lines) |
Get version information. | |
const char * | what (void) const |
Returns internal status. | |
virtual | ~UrgCtrl (void) |
Protected Member Functions | |
virtual void | captureReceived (void) |
Private Member Functions | |
UrgCtrl & | operator= (const UrgCtrl &rhs) |
UrgCtrl (const UrgCtrl &rhs) | |
Private Attributes | |
std::auto_ptr< pImpl > | pimpl |
URG sensor control.
Definition at line 23 of file UrgCtrl.h.
anonymous enum |
qrk::UrgCtrl::UrgCtrl | ( | void | ) |
virtual qrk::UrgCtrl::~UrgCtrl | ( | void | ) | [virtual] |
qrk::UrgCtrl::UrgCtrl | ( | const UrgCtrl & | rhs | ) | [private] |
int qrk::UrgCtrl::capture | ( | std::vector< long > & | data, | |
long * | timestamp = NULL | |||
) | [virtual] |
Get data.
Get data and store it in buffer.
[out] | data | Buffer to store data |
[out] | timestamp | Time stamp |
<0 | Receiving failed |
Implements qrk::RangeSensor.
RangeCaptureMode qrk::UrgCtrl::captureMode | ( | void | ) | [virtual] |
Data acquisition mode.
Implements qrk::RangeSensor.
virtual void qrk::UrgCtrl::captureReceived | ( | void | ) | [protected, virtual] |
int qrk::UrgCtrl::captureWithIntensity | ( | std::vector< long > & | data, | |
std::vector< long > & | intensity_data, | |||
long * | timestamp = NULL | |||
) | [virtual] |
Implements qrk::RangeSensor.
bool qrk::UrgCtrl::connect | ( | const char * | device, | |
long | baudrate = DefaultBaudrate | |||
) | [virtual] |
[in] | device | Connected device name |
[in] | baudrate | Baudrate |
true | Success | |
false | Failure |
Example
const char device[] = "/dev/ttyACM0"; const long baudrate = 115200; UrgCtrl sensor; // Connect to specified device if (! sensor.connect(device, baudrate)) { printf("connect: %s\n", sensor.what()); exit(1); }
Implements qrk::RangeSensor.
Connection* qrk::UrgCtrl::connection | ( | void | ) | [virtual] |
void qrk::UrgCtrl::disconnect | ( | void | ) | [virtual] |
Disconnect.
Implements qrk::RangeSensor.
double qrk::UrgCtrl::index2rad | ( | const int | index | ) | const [virtual] |
Radian to angle conversion of data index.
Front of sensor is considered as 0.0 in radians.
[in] | index | Data index |
upper view
Implements qrk::RangeSensor.
bool qrk::UrgCtrl::isConnected | ( | void | ) | const [virtual] |
Returns connection status.
true | If connected. | |
false | if disconnected. |
Implements qrk::RangeSensor.
bool qrk::UrgCtrl::loadParameter | ( | void | ) |
Again read the URG parameter.
true | success | |
false | error |
long qrk::UrgCtrl::maxDistance | ( | void | ) | const [virtual] |
int qrk::UrgCtrl::maxScanLines | ( | void | ) | const [virtual] |
long qrk::UrgCtrl::minDistance | ( | void | ) | const [virtual] |
RangeSensorParameter qrk::UrgCtrl::parameter | ( | void | ) | const [virtual] |
int qrk::UrgCtrl::rad2index | ( | const double | radian | ) | const [virtual] |
radian Convert angle in radian to data index
Front of sensor is considered as 0.0 in radians.
[in] | radian | angle [radian] |
Implements qrk::RangeSensor.
bool qrk::UrgCtrl::reboot | ( | void | ) |
Reboot URG.
long qrk::UrgCtrl::recentTimestamp | ( | void | ) | const [virtual] |
size_t qrk::UrgCtrl::remainCaptureTimes | ( | void | ) |
Get number of remaining capture times.
bool qrk::UrgCtrl::reset | ( | void | ) |
Reboot URG.
int qrk::UrgCtrl::scanMsec | ( | void | ) | const [virtual] |
void qrk::UrgCtrl::setCaptureFrameInterval | ( | size_t | interval | ) |
Acquisition interval of scanning data.
The data traffic between URG and the library can be decreased by lowering the frequency of data acquisition. refer to scip_capture_parameter_section
[in] | interval | capture interval |
void qrk::UrgCtrl::setCaptureMode | ( | RangeCaptureMode | mode | ) | [virtual] |
Specification of data acquisition mode.
[in] | mode | The mode defined by RangeCaptureMode can be specified |
Implements qrk::RangeSensor.
void qrk::UrgCtrl::setCaptureRange | ( | int | begin_index, | |
int | end_index | |||
) |
Specifies the range of data acquisition.
Refer to scip_capture_parameter_section.
[in] | begin_index | Measurement beginning position |
[in] | end_index | Measurement end position |
void qrk::UrgCtrl::setCaptureSkipLines | ( | size_t | skip_lines | ) |
Specify the number of scanline to be skipped.
The number of thinning out of acquisition data in one scanning is specified.
[in] | skip_lines | number of scanline to be skipped. |
For example, if number of scan lines to be skipped = 1 , then will be
100, 101, 103, 104, 105, 100, ...
In case, number of scanlines to be skipped = 2, then acquired data will be
100, 103, 100, ...
(The shortest distance data is returned. )
As a result, the data traffic between URG and the library can be decreased. However, the volume of data that capture() returns doesnot change. Returns
100, 100, 103, 103, 100, 100, ...
To guarantee the operation of rad2index() and index2rad(), volume of data does not changing :.
void qrk::UrgCtrl::setCapturesSize | ( | size_t | size | ) |
Set number of scan data stored internally.
[in] | size | Number of scanning data to be stored |
void qrk::UrgCtrl::setCaptureTimes | ( | size_t | times | ) |
Specify the frequency of data acquisition.
Refer to scip_capture_parameter_section
[in] | times | Frequency of data acquisition |
void qrk::UrgCtrl::setConnection | ( | Connection * | con | ) | [virtual] |
Specifies the connection object.
[in] | con | Connection object |
Implements qrk::RangeSensor.
bool qrk::UrgCtrl::setLaserOutput | ( | bool | on | ) | [virtual] |
Laser turn Off/ turn On.
[in] | on | true to turn On , false to turn off |
Implements qrk::RangeSensor.
void qrk::UrgCtrl::setParameter | ( | const RangeSensorParameter & | parameter | ) | [virtual] |
Update URG parameter.
[in] | parameter | data used to update URG parameter |
Implements qrk::RangeSensor.
void qrk::UrgCtrl::setRetryTimes | ( | size_t | times | ) |
Set number of retry times when connection failed.
The retry counter is cleared when connect normaly.
[in] | times | retry times |
bool qrk::UrgCtrl::setTimestamp | ( | int | timestamp = 0 , |
|
int * | response_msec = NULL , |
|||
int * | force_delay_msec = NULL | |||
) | [virtual] |
Sets the timestamp value. Sensor returs this timestamp value.
Sets the time stamp that can be acquired with capture().
[in] | ticks | Set value of time stamp at that time |
[out] | response_msec | Response time for sending and receiving message [msec] |
[in] | force_delay_msec | Forced delay |
true | Success | |
false | Failure |
Implements qrk::RangeSensor.
void qrk::UrgCtrl::stop | ( | void | ) |
Stop data acquisition.
bool qrk::UrgCtrl::versionLines | ( | std::vector< std::string > & | lines | ) |
Get version information.
[out] | lines | Storage location of version information |
true | success | |
false | error |
Example
const char* qrk::UrgCtrl::what | ( | void | ) | const [virtual] |
Returns internal status.
Example
UrgCtrl sensor; if (! sensor.connect(device, baudrate)) { // Displays error message when connection is failed. printf("connect: %s\n", sensor.what()); exit(1); }
Implements qrk::RangeSensor.
std::auto_ptr<pImpl> qrk::UrgCtrl::pimpl [private] |
Reimplemented from qrk::Coordinate.