rplidar_open End of trail navigation bar

Table of Contents

rplidar_close

Closes an RPLidar sensor.

Description

The rplidar_close function closes an RPLidar sensor, releasing any allocated resources. Once the sensor has been closed, the sensor handle is no longer valid and may not be used.

Prototype

t_error
rplidar_close(t_ranging_sensor sensor);
    

Parameters

t_ranging_sensor sensor

A handle to the sensor, as returned by rplidar_open.

Return value

The return value is 0 if the sensor is closed successfully. Otherwise a negative error code is returned. Error codes are defined in quanser_errors.h. A suitable error message may be retrieved using msg_get_error_message.

Error codes

QERR_INVALID_ARGUMENT

An invalid RPLidar sensor handle was passed as an argument. Once a sensor has been closed using rplidar_close the handle is invalid.

Requirements

Include Files

Libraries

quanser_ranging_sensor.h

quanser_devices.lib;quanser_communications.lib;quanser_runtime.lib;quanser_common.lib

Examples

t_ranging_sensor lidar;
t_error result =
    rplidar_open("serial-cpu://localhost:1?baud='256000',word='8',parity='none',stop='1',flow='none',dsr='on'", RANGING_DISTANCE_LONG, &lidar);
if (result == 0) {
    ...
    rplidar_close(lidar);
} else {
    TCHAR message[512];
    msg_get_error_message(NULL, result, message, sizeof(message));
    _tprintf(_T("Failed to open RPLidar. %s (error %d)\n"), message, -result);
}
    

See Also

 

navigation bar