Skip to content

Commit effb9de

Browse files
committed
[tfmini] Configure range and FoV via parameters
1 parent 43ef690 commit effb9de

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

src/drivers/distance_sensor/tfmini/TFMINI.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#include "TFMINI.hpp"
3535

36+
#include <lib/parameters/param.h>
3637
#include <lib/drivers/device/Device.hpp>
3738
#include <fcntl.h>
3839

@@ -72,7 +73,8 @@ TFMINI::~TFMINI()
7273
int
7374
TFMINI::init()
7475
{
75-
int32_t hw_model = 1; // only one model so far...
76+
int32_t hw_model = 1;
77+
param_get(param_find("SENS_TFMINI_HW"), &hw_model);
7678

7779
switch (hw_model) {
7880
case 1: // TFMINI (12m, 100 Hz)
@@ -83,8 +85,19 @@ TFMINI::init()
8385
// So we set 0.4 as valid minimum.
8486
_px4_rangefinder.set_min_distance(0.4f);
8587
_px4_rangefinder.set_max_distance(12.0f);
86-
_px4_rangefinder.set_fov(math::radians(1.15f));
88+
_px4_rangefinder.set_fov(math::radians(2.3f));
89+
break;
90+
91+
case 2: // ISTRA24 (50m, 100 Hz)
92+
_px4_rangefinder.set_min_distance(0.3f);
93+
_px4_rangefinder.set_max_distance(50.0f);
94+
_px4_rangefinder.set_fov(math::radians(20));
95+
break;
8796

97+
case 3: // ISTRA24 (100m, 100 Hz)
98+
_px4_rangefinder.set_min_distance(0.3f);
99+
_px4_rangefinder.set_max_distance(100.0f);
100+
_px4_rangefinder.set_fov(math::radians(20));
88101
break;
89102

90103
default:

src/drivers/distance_sensor/tfmini/module.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,20 @@ serial_config:
44
port_config_param:
55
name: SENS_TFMINI_CFG
66
group: Sensors
7+
8+
parameters:
9+
- group: Sensors
10+
definitions:
11+
SENS_TFMINI_HW:
12+
description:
13+
short: Hardware Model
14+
long: Models differ in range and FoV.
15+
type: enum
16+
values:
17+
1: TFMINI
18+
2: ISTRA24
19+
3: ISTRA24_100m
20+
min: 1
21+
max: 3
22+
default: 1
23+
reboot_required: true

src/drivers/distance_sensor/tfmini/tfmini_main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ Stop driver
132132
PRINT_MODULE_USAGE_PARAM_INT('R', 25, 0, 25, "Sensor rotation - downward facing by default", true);
133133
PRINT_MODULE_USAGE_COMMAND_DESCR("status","Driver status");
134134
PRINT_MODULE_USAGE_COMMAND_DESCR("stop","Stop driver");
135-
PRINT_MODULE_USAGE_COMMAND_DESCR("test","Test driver (basic functional tests)");
136135
PRINT_MODULE_USAGE_COMMAND_DESCR("status","Print driver status");
137136
return PX4_OK;
138137
}

0 commit comments

Comments
 (0)