Skip to content

Commit 0e6b904

Browse files
AlexKlimajdakejahl
andauthored
LightwareLaser: add SF1XX rotation parameter (#26428)
* Add SF1XX rotation parameter and update orientation in LightwareLaser driver * remove rotation opt arg, update docs about supported lightware --------- Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
1 parent 864df9f commit 0e6b904

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

src/drivers/distance_sensor/lightware_laser_i2c/lightware_laser_i2c.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ class LightwareLaser : public device::I2C, public I2CSPIDriver<LightwareLaser>,
162162

163163
DEFINE_PARAMETERS(
164164
(ParamInt<px4::params::SENS_EN_SF1XX>) _param_sens_en_sf1xx,
165-
(ParamInt<px4::params::SF1XX_MODE>) _param_sf1xx_mode
165+
(ParamInt<px4::params::SF1XX_MODE>) _param_sf1xx_mode,
166+
(ParamInt<px4::params::SF1XX_ROT>) _param_sf1xx_rot
166167
)
167168
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
168169
uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)};
@@ -178,7 +179,7 @@ LightwareLaser::LightwareLaser(const I2CSPIDriverConfig &config) :
178179
I2C(config),
179180
I2CSPIDriver(config),
180181
ModuleParams(nullptr),
181-
_px4_rangefinder(get_device_id(), config.rotation)
182+
_px4_rangefinder(get_device_id())
182183
{
183184
_px4_rangefinder.set_device_type(DRV_DIST_DEVTYPE_LIGHTWARE_LASER);
184185
}
@@ -194,6 +195,9 @@ int LightwareLaser::init()
194195
{
195196
int ret = PX4_ERROR;
196197
updateParams();
198+
199+
_px4_rangefinder.set_orientation(_param_sf1xx_rot.get());
200+
197201
const int32_t hw_model = _param_sens_en_sf1xx.get();
198202

199203
switch (hw_model) {
@@ -630,7 +634,7 @@ void LightwareLaser::print_usage()
630634
R"DESCR_STR(
631635
### Description
632636
633-
I2C bus driver for Lightware SFxx series LIDAR rangefinders: SF10/a, SF10/b, SF10/c, SF11/c, SF/LW20, SF30/d.
637+
I2C bus driver for Lightware LIDAR rangefinders: SF10/a, SF10/b, SF10/c, SF11/c, SF/LW20, SF/LW30/d, GRF250, GRF500.
634638
635639
Setup/usage information: https://docs.px4.io/main/en/sensor/sfxx_lidar.html
636640
)DESCR_STR");
@@ -640,28 +644,17 @@ Setup/usage information: https://docs.px4.io/main/en/sensor/sfxx_lidar.html
640644
PRINT_MODULE_USAGE_COMMAND("start");
641645
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(true, false);
642646
PRINT_MODULE_USAGE_PARAMS_I2C_ADDRESS(0x66);
643-
PRINT_MODULE_USAGE_PARAM_INT('R', 25, 0, 25, "Sensor rotation - downward facing by default", true);
644647
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
645648
}
646649

647650
extern "C" __EXPORT int lightware_laser_i2c_main(int argc, char *argv[])
648651
{
649-
int ch;
650652
using ThisDriver = LightwareLaser;
651653
BusCLIArguments cli{true, false};
652-
cli.rotation = (Rotation)distance_sensor_s::ROTATION_DOWNWARD_FACING;
653654
cli.default_i2c_frequency = 400000;
654655
cli.i2c_address = LIGHTWARE_LASER_BASEADDR;
655656

656-
while ((ch = cli.getOpt(argc, argv, "R:")) != EOF) {
657-
switch (ch) {
658-
case 'R':
659-
cli.rotation = (Rotation)atoi(cli.optArg());
660-
break;
661-
}
662-
}
663-
664-
const char *verb = cli.optArg();
657+
const char *verb = cli.parseDefaultArguments(argc, argv);
665658

666659
if (!verb) {
667660
ThisDriver::print_usage();

src/drivers/distance_sensor/lightware_laser_i2c/parameters.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
****************************************************************************/
3333

3434
/**
35-
* Lightware SF1xx/SF20/LW20 laser rangefinder (i2c)
35+
* Lightware laser rangefinder (i2c)
3636
*
3737
* @reboot_required true
3838
* @min 0
@@ -52,7 +52,7 @@
5252
PARAM_DEFINE_INT32(SENS_EN_SF1XX, 0);
5353

5454
/**
55-
* Lightware SF1xx/SF20/LW20 Operation Mode
55+
* Lightware laser rangefinder Operation Mode
5656
*
5757
* @value 0 Disabled
5858
* @value 1 Enabled
@@ -62,3 +62,22 @@ PARAM_DEFINE_INT32(SENS_EN_SF1XX, 0);
6262
* @max 2
6363
*/
6464
PARAM_DEFINE_INT32(SF1XX_MODE, 1);
65+
66+
/**
67+
* Lightware laser rangefinder Rotation
68+
*
69+
* Distance sensor orientation as MAV_SENSOR_ORIENTATION enum.
70+
* Applies to all models supported by SENS_EN_SF1XX.
71+
*
72+
* @reboot_required true
73+
* @min 0
74+
* @max 25
75+
* @group Sensors
76+
* @value 0 Forward
77+
* @value 2 Right
78+
* @value 4 Backward
79+
* @value 6 Left
80+
* @value 24 Upward
81+
* @value 25 Downward
82+
*/
83+
PARAM_DEFINE_INT32(SF1XX_ROT, 25);

0 commit comments

Comments
 (0)