LightWare LW20 ArduPilot Support

I’d like to present a brief overview of ArduPilot support for the LightWare LW20/SF20.

The LW20 is LightWare’s next generation small form factor and lightweight rangefinder solution for drones. The multitude of operational features (signal stats, low power mode, full servo driven 2D scanning, and more) have been exposed through an open source C based cross-platform API. ArduPilot continues to be a flight controller we are interested in supporting and as such we have integrated the LW20 API.

(Showing an SF20 - open case version of the LW20 - connected to a Pixhawk via Serial)

Here is an example of the extended capabilities of the LW20 on the Pixhawk:

The above graph shows two different signal pulses detected per distance reading. The red line represents the first distance detected, while the green line represents the last distance detected. This can happen when the laser is able to hit multiple targets, for example, if you are looking down at a bush. The first detection could be from the leaves and the last detection could be from the ground beneath.

We hope that over time the full range of LW20 capabilities will have functional use within ArduPilot, but for now we have built the framework for exposing the functionality and providing a base to work from.

Please feel free to contact me for early release versions of the LW20 ArduPilot firmware or C API.


I have a request (or need info about how I might accomplish this). I understand that the LW-20 can drive a servo to either scan in a sweeping pattern or move the unit from pointing at the ground for altimeter use to pointing straight ahead for obstacle avoidance.

What I would like to do is use an available output channel on my pixhawk mini to drive a servo that controls the up/down motion to get the best of both worlds: sweeping side to side & still able to use for altimeter.

I have already done the CAD drawings for the mount to accomplish this & am willing to share.



I was lucky enough to get one of the first production run units. However, I’m having trouble getting it to talk with my pixhawk 2.1. The manual seems to indicate a default baud rate of 921000. I believe my wiring is correct, also based on the LW20 manual + P2.1 pinouts. Anything special on this unit?

My AC version is: 3.4.6 Quad

Hi Jeff,

If the 921600 baud rate does not work, I’d suggest trying 115200 (115200 is the new default baud rate, but some units did make it out the door with 921600).

I have just run a test of ArduCopter 3.4.6 and the LW20 does work there, however we don’t have any Pixhawk2’s to test on.

Have you been able to connect your LW20 to a PC via USB? If so, you can check the baud rate there.

Thanks Rob; I was trying to debug via a TTL 3v USB dongle. Will try more tomorrow… :slight_smile:

Turns out I had my rx/tx wires swapped. I thought I had tried both combinations.

Furthermore, my PC setup was busted; I had a 3.3v dongle and a 5v dongle, both have same signal and Vcc levels. I had to “mix” them to provide Vcc at 5v but then use the 3.3v FDTI chip for the actual TX/RX, with a common gnd. It was special but worked :slight_smile:

@RobGowans I would like to integrate my LW20 with a UAV payload. I’ll put a Pixhawk with an airspeed sensor, LW20, GPS Reciever, and RFD900. I need to get

  • wind speed (airspeed sensor, GPS)
  • ground/vegetation height (LW20)
  • attitude info (Pixhawk IMU)
  • in real time (RFD900)
    Do you have Arduplane firmware that will give me these? I haven’t confirmed it, but I seem to remember Arducopter doesn’t handle the wind speed. This will all be for post processing and real time reporting, not for controlling the platform in any way.

The firmware we have uses the LW20 to directly drive the Ardupilot altitude. There may be a version in the future that will simply log the data.

Hi Rob, Would it be possible to have access to the modified firmware? I’m guessing if the communication is already in place between the LW20 and the Pixhawk, I might be able to figure out the logging. I’ll be using this with a payload, so there are no motors or servos to control and then I feel ok about hacking something together. But I would be lost without an example in front of me.

I’ll see what I can find for you.


I have installed an LW20 serial on an APM plane 3.8.0. All settings are as per APM guides.On the ground
it works quite fine, measuring tape confirms… But in flight sonarrange is consistent with plane altitude until about 10 meters and then goes to something like 2.4 meters and stays there all flight.

Is there anything I have to do to make it work?

RNGFND_MAX_CM 9500.000000
RNGFND_MIN_CM 5.000000
RNGFND_PIN -1.000000
RNGFND_POS_X 0.000000
RNGFND_POS_Y 0.000000
RNGFND_POS_Z 0.000000
RNGFND_TYPE 8.000000

Hi Rob, sorry to bug you but do could you find the firmware that logs the two returns from the LW20? I would like to start testing it with our payload. Thanks,

@RobGowans I think there is a problem with the LightWare serial driver. When it parses the device output, it looks for numbers and decimal points only:

66         } else if (isdigit(c) || c == '.') {

However, the device outputs a value of -1.0 when it is out of range or doesn’t have a valid reading and the negative sign is ignored, so these bad readings leak into the average measured distance as 1.0 meters leading to severe inaccuracies, especially when the lidar is near its maximum range.

Hello Rob.If still “on the case” can you answer a few questions ?

If I get LW20 and put it on rover with Pixhawk 2.4.8 mounted and wired to servo sweeping horizontally, would i get ranging info together with heading.I mean is the current driver on rover 3.5 able to read direction of obstacle when LW20 is sweeping ? Thanks

Hi Anton,

As far as I understand the current driver does not take into account the LW20’s scanning capabilities.

Ok, thanks, do you think i could use an arduino as an interface and fool the pixhawk presenting it as some of the 3d or 360 lidars which are supported ?

Yes you could do that. Do you have any programming experience? If so you could look over how the Pixhawk is interacting with these devices.

Thanks, not really a programmer, i would seek help for that, but i just like an idea as i managed to solve some problems that way.