docs: laser.md article

This commit is contained in:
sfalexrog
2019-06-19 21:47:22 +03:00
parent 2090f0a1ae
commit 6a17217fbd

View File

@@ -1,6 +1,6 @@
# Working with a laser rangefinder
## Rangefinder VL53L1X
## VL53L1X Rangefinder
The rangefinder model recommended for Clever is STM VL53L1X. This rangefinder can measure distances from 0 to 4 m while ensuring high measurement accuracy.
@@ -8,7 +8,7 @@ The [image for Raspberry Pi](microsd_images.md) contains pre-installed correspon
### Connecting to Raspberry Pi
> **Note** For correct operation of a laser rangefinder with a flight countroller <a id="download-firmware" href="https://github.com/CopterExpress/Firmware/releases">custom PX4 firmware</a> is needed. See more about firmware in [corresponding article](firmware.md).
> **Note** You need to flash a <a id="download-firmware" href="https://github.com/CopterExpress/Firmware/releases">custom PX4 firmware</a> on your flight controller for the rangefinder to work correctly. See more about firmware in the [corresponding article](firmware.md).
<script type="text/javascript">
fetch('https://api.github.com/repos/CopterExpress/Firmware/releases').then(res => res.json()).then(function(data) {
@@ -21,44 +21,44 @@ The [image for Raspberry Pi](microsd_images.md) contains pre-installed correspon
});
</script>
Connect the rangefinder to pins 3V, GND, SCL and SDA via the I²C interface:
Connect the rangefinder to the 3V, GND, SCL and SDA pins via the I²C interface:
<img src="../assets/raspberry-vl53l1x.png" alt="Connecting VL53L1X" height=600>
If the pin marked GND is occupied, you can use another free one using the [pinout](https://pinout.xyz).
If the pin marked GND is occupied, you can use any other ground pin (look at the [pinout](https://pinout.xyz) for reference).
> **Hint** Via the I²C interface, you can connect several peripheral devices simultaneously. For this purpose, use a parallel connection.
> **Hint** You can connect several peripheral devices via the I²C interface simultaneously. Use a parallel connection for that.
### Enabling
### Enabling the rangefinder
[Connect via SSH](ssh.md) and edit file `~/catkin_ws/src/clever/clever/launch/clever.launch` so that driver VL53L1X is enabled:
[Connect via SSH](ssh.md) and edit file `~/catkin_ws/src/clever/clever/launch/clever.launch` so that the VL53L1X driver is enabled:
```xml
<arg name="rangefinder_vl53l1x" default="true"/>
```
By default, the rangefinder driver sends the data to Pixhawk (via topic `/mavros/distance_sensor/rangefinder_sub`). To view data from the topic, use command:
By default, the rangefinder driver sends the data to Pixhawk via the `/mavros/distance_sensor/rangefinder_sub` topic. To view data from the topic, use the following command:
```(bash)
```bash
rostopic echo mavros/distance_sensor/rangefinder_sub
```
### PX4 settings
To use the rangefinder data in [PX4 must be configured](px4_parameters.md).
PX4 should be properly [configured](px4_parameters.md) to use the rangefinder data.
When using EKF2 (`SYS_MC_EST_GROUP` = `ekf2`):
Set the following parameters when EKF2 is used (`SYS_MC_EST_GROUP` = `ekf2`):
* `EKF2_HGT_MODE` = `2` (Range sensor) when flying over horizontal floor;
* `EKF2_HGT_MODE` = `2` (Range sensor) for flights over horizontal floor;
* `EKF2_RNG_AID` = `1` (Range aid enabled) in other cases.
When using LPE (`SYS_MC_EST_GROUP` = `local_position_estimator, attitude_estimator_q`):
Set the following parameters when LPE is used (`SYS_MC_EST_GROUP` = `local_position_estimator, attitude_estimator_q`):
* The "pub agl as lpos down" flag is ticked in the `LPE_FUSION` parameter when flying over horizontal floor.
* The "pub agl as lpos down" flag should be set in the `LPE_FUSION` parameter for flights over horizontal floor.
### Obtaining data from Python
### Receiving data in Python
To obtain data from the topic, create a subscriber:
In order to receive data from the topic, create a subscriber:
```python
from sensor_msgs.msg import Range
@@ -66,7 +66,7 @@ from sensor_msgs.msg import Range
# ...
def range_callback(msg):
# Processing new data from the rangefinder
# Process data from the rangefinder
print 'Rangefinder distance:', msg.range
rospy.Subscriber('mavros/distance_sensor/rangefinder_sub', Range, range_callback)
@@ -74,13 +74,13 @@ rospy.Subscriber('mavros/distance_sensor/rangefinder_sub', Range, range_callback
### Data visualization
To build a chart using the data from the rangefinder, one can use rqt_multiplot.
You may use rqt_multiplot tool to plot rangefinder data.
rviz may be used for data visualization. To do this, add a topic of the `sensor_msgs/Range` type to visualization:
<img src="../assets/rviz-range.png" alt="Range in rviz">
See [read more about rviz and rqt](rviz.md).
Read more [about rviz and rqt](rviz.md).
<!--
### Connecting to Pixhawk / Pixracer