41 #include <px4_platform_common/px4_config.h> 43 #include <sys/types.h> 51 #include <px4_platform_common/getopt.h> 64 #include <board_config.h> 66 #include <trone/TROne.hpp> 78 DfTROneWrapper(uint8_t rotation = distance_sensor_s::ROTATION_DOWNWARD_FACING);
97 int _publish(
struct range_sensor_data &
data);
110 TROne(TRONE_DEVICE_PATH),
112 _range_topic(nullptr),
113 _orb_class_instance(-1)
129 PX4_ERR(
"TROne init fail: %d", ret);
136 PX4_ERR(
"TROne start fail: %d", ret);
149 PX4_ERR(
"TROne stop fail: %d", ret);
160 memset(&d, 0,
sizeof(d));
170 d.
type = distance_sensor_s::MAV_DISTANCE_SENSOR_LASER;
197 int start(uint8_t rotation);
208 if (g_dev ==
nullptr) {
209 PX4_ERR(
"failed instantiating DfTROneWrapper object");
213 int ret = g_dev->
start();
216 PX4_ERR(
"DfTROneWrapper start failed");
222 DevMgr::getHandle(TRONE_DEVICE_PATH, h);
225 DF_LOG_INFO(
"Error: unable to obtain a valid handle for the receiver at: %s (%d)",
226 TRONE_DEVICE_PATH, h.getError());
230 DevMgr::releaseHandle(h);
237 if (g_dev ==
nullptr) {
238 PX4_ERR(
"driver not running");
242 int ret = g_dev->
stop();
245 PX4_ERR(
"driver could not be stopped");
260 if (g_dev ==
nullptr) {
261 PX4_ERR(
"driver not running");
265 PX4_DEBUG(
"state @ %p", g_dev);
278 if (g_dev ==
nullptr) {
279 ret =
start(distance_sensor_s::ROTATION_DOWNWARD_FACING);
282 PX4_ERR(
"Failed to start");
287 ret = g_dev->probe();
290 PX4_ERR(
"Failed to probe");
294 PX4_DEBUG(
"state @ %p", g_dev);
303 PX4_WARN(
"Usage: df_trone_wrapper 'start', 'info', 'stop'");
315 const char *myoptarg = NULL;
316 uint8_t rotation = distance_sensor_s::ROTATION_DOWNWARD_FACING;
319 while ((ch = px4_getopt(argc, argv,
"R:", &myoptind, &myoptarg)) != EOF) {
322 rotation = (uint8_t)atoi(myoptarg);
323 PX4_INFO(
"Setting distance sensor orientation to %d", (
int)rotation);
337 const char *verb = argv[myoptind];
340 if (!strcmp(verb,
"start")) {
344 else if (!strcmp(verb,
"stop")) {
348 else if (!strcmp(verb,
"info")) {
352 else if (!strcmp(verb,
"probe")) {
int stop()
Stop the driver.
API for the uORB lightweight object broker.
void usage(const char *reason)
Print the correct usage.
High-resolution timer with callouts and timekeeping.
int start()
Start automatic measurement.
void usage()
Prints info about the driver argument usage.
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
void init()
Activates/configures the hardware registers.
int _publish(struct range_sensor_data &data)
Simple error/warning functions, heavily inspired by the BSD functions of the same names...
__EXPORT int df_trone_wrapper_main(int argc, char *argv[])
orb_advert_t _range_topic
__BEGIN_DECLS typedef void * orb_advert_t
ORB topic advertiser handle.
DfTROneWrapper(uint8_t rotation=distance_sensor_s::ROTATION_DOWNWARD_FACING)
int orb_publish(const struct orb_metadata *meta, orb_advert_t handle, const void *data)
int stop()
Stop automatic measurement.
int info()
Print a little info about the driver.
orb_advert_t orb_advertise_multi(const struct orb_metadata *meta, const void *data, int *instance, int priority)
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
int start(uint8_t rotation)
Performance measuring tools.