Table of Contents
leishen_m10p_open
Opens a Leishen M10P ranging sensor.
Description
The leishen_m10p_open function opens a particular Leishen M10P sensor. The handle to the sensor returned by this function is used by the other Leishen M10P functions in the Devices API to refer to the LIDAR sensor. This handle must be closed using the leishen_m10p_close function when the sensor is no longer in use.
Prototype
t_error leishen_m10p_open(const char * uri, t_ranging_distance range, t_ranging_sensor * sensor);
Parameters
const char * uri
A string containing the URI identifying the communication protocol and associated parameters to use to communicate with the ranging sensor. For example, serial://localhost:1?baud=512000 connects to the LIDAR through serial port 1 (e.g. COM1 or /dev/ttyS1) at 512000 baud.
On the QBot Platform, for example, a suitable URI for the Leishen M10P A2 M8 is serial://localhost:0?baud='512000',word='8',parity='none',stop='1',flow='none',device='/dev/lidar'.
t_ranging_distance range
The ranging distance parameter is used to optimize the sensor settings for a particular range of distances. For each sensor, the corresponding ranges will differ. For example, for the VL53L1X Time-of-Flight sensor, the distance ranges for a 100 ms timing budget are:
Ranging Distance |
Maximum distance in dark (cm) |
Maximum distance under strong ambient light (cm) |
---|---|---|
RANGING_DISTANCE_SHORT |
136 |
135 |
RANGING_DISTANCE_MEDIUM |
290 |
76 |
RANGING_DISTANCE_LONG |
360 |
73 |
t_ranging_sensor * sensor
A handle to the sensor is returned in the t_ranging_sensor variable passed in this parameter. This argument cannot be NULL. Pass the address of a variable of type t_ranging_sensor.
Return value
The return value is 0 if the sensor is opened 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
One of the arguments is invalid.
QERR_OUT_OF_MEMORY
There is not enough memory to complete the operation.
QERR_TIMED_OUT
The function timed out waiting for the sensor to respond. Make sure the URI represents the proper interface to the sensor and that the sensor is connected.
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 = leishen_m10p_open("serial://localhost:0?baud='512000',word='8',parity='none',stop='1',flow='none',device='/dev/lidar'", RANGING_DISTANCE_LONG, &lidar); if (result == 0) { ... leishen_m10p_close(lidar); } else { TCHAR message[512]; msg_get_error_message(NULL, result, message, sizeof(message)); _tprintf(_T("Failed to open Leishen M10P. %s (error %d)\n"), message, -result); }
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.