# How to adjust the sample rate of distance sensor (rangefinder)

**URL:** <https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575>\
**Category:** PX4 Autopilot\
**Created:** [January 27, 2023, 8:16am UTC](https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575 "2023-01-27T08:16:53Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexWUrobot](https://discuss.px4.io/user_avatar/discuss.px4.io/alexwurobot/32/11387_2.png) [@AlexWUrobot](https://discuss.px4.io/u/AlexWUrobot)\
**Post date:** [January 27, 2023, 8:16am UTC](https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575/1 "2023-01-27T08:16:53Z")

</div>

I follow the Pixhawk instruction (by this link:[Distance Sensors (Rangefinders) · PX4 v1.9.0 User Guide](https://docs.px4.io/v1.9.0/en/sensor/rangefinders.html))  
and run the rangefinder successfully.

The sensor type is Lidar-Lite

I am curious about how to increase the sampling rate.  
Now my sample rate is only 2 hz

 ![image](https://discuss.px4.io/uploads/default/original/2X/f/f1b5ba83df3fcd5513a83dba057090e1d8656570.jpeg)

Also, I am confused why the QGroundControl Analyze Tools detect the distance sensor only 0.2~0.8 Hz, no matter in real world or simulation ( the simulation and real Lidar should be 10 hz)

 ![image](https://discuss.px4.io/uploads/default/original/2X/2/266477f665c1c96f2554257ebdd1fd6f9efa1aef.png)  
 ![image](https://discuss.px4.io/uploads/default/original/2X/f/f8a92d76fd386096b2b3f63d360cedf47ce2d047.png)  
 ![image](https://discuss.px4.io/uploads/default/original/2X/0/0d2500afa2eee4de5e264f973d9299d3cdf1388f.png)  
 ![image](https://discuss.px4.io/uploads/default/original/2X/2/2ba8147be910c825eac0444dc605ce1437439aaf.png)

> **[LIDAR\_Lite\_v3\_Operation\_Manual\_and\_Technical\_Specifications.pdf](https://static.garmin.com/pumac/LIDAR_Lite_v3_Operation_Manual_and_Technical_Specifications.pdf)**
>
> 749.72 KB

Thanks a lot

P.S  
I enable rangefinder in MAVROS by this way: [How to Read Distance Sensor Data from MAVROS Topic](https://discuss.px4.io/t/how-to-read-distance-sensor-data-from-mavros-topic/21944)  
I set the I2C connection in QGroundControl by this way: [Cannnot find the distance\_sensor in the QGround control](https://discuss.px4.io/t/cannnot-find-the-distance-sensor-in-the-qground-control/30114)

In Ardupilot firmware, people suggest,

```auto
rosrun mavros mavsys message_interval --id XX --rate YY

```

by this way: [How to adjust the sample rate of distance sensor (rangefinder) - ArduCopter - ArduPilot Discourse](https://discuss.ardupilot.org/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/95567)

I also examine `mavlink_main.cpp` by this way: [Increase stream rate of HIGHRES\_IMU message](https://discuss.px4.io/t/increase-stream-rate-of-highres-imu-message/4789)

 ![image](https://discuss.px4.io/uploads/default/original/2X/4/42febb4f5b17e049a2fad5d79392bfaaf60aa360.png)

Someone change the sampling rate of IMU by edit this file `/fs/microsd/etc/extras.txt`  
ref:[System Startup | PX4 User Guide](https://docs.px4.io/main/en/concept/system_startup.html)

Increase the sampling rate in Gazebo simulation [increase sensor rate SITL · Issue #980 · mavlink/mavros · GitHub](https://github.com/mavlink/mavros/issues/980)

How to change the correct publisher name: [How to use distance\_sensor? send distance Sensor data to FCU for use as altitude · Issue #664 · mavlink/mavros · GitHub](https://github.com/mavlink/mavros/issues/664)

---

<div class="post-metadata">

**Author:** ![sibujacob](https://discuss.px4.io/user_avatar/discuss.px4.io/sibujacob/32/9673_2.png) [@sibujacob](https://discuss.px4.io/u/sibujacob)\
**Post date:** [January 27, 2023, 1:40pm UTC](https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575/2 "2023-01-27T13:40:29Z")

</div>

@AlexWUrobot …I am also trying to put my distance sensor VL53L0x into operation for collision prevention. QGC shows the distance measured but the drone in **POSITION** mode does not handle collision detection !! Any clues ?

In your case, you have to make sure that the drone is flying in POSITION MODE for the distance sensor to work .

Where did you install MAVROS. is it on a Raspberry Pi ?

---

<div class="post-metadata">

**Author:** ![AlexWUrobot](https://discuss.px4.io/user_avatar/discuss.px4.io/alexwurobot/32/11387_2.png) [@AlexWUrobot](https://discuss.px4.io/u/AlexWUrobot)\
**Post date:** [January 27, 2023, 4:36pm UTC](https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575/3 "2023-01-27T16:36:37Z")

</div>

Thanks for the reply  
I install MAVROS on Jetson TX1. (with Ubuntu 18.04 and Python 2.7)  
I fly the drone through offboard mode (means that Jetson TX1 computer controls the Pixhawk FMUv5 version to fly the drone)  
I ran the Python script so I can subscribe the /mavros/distance\_sensor/hrlv\_ez4\_pub  
ref: [MAVROS Offboard control example (Python) | PX4 User Guide](https://docs.px4.io/main/en/ros/mavros_offboard_python.html)

---

<div class="post-metadata">

**Author:** ![sibujacob](https://discuss.px4.io/user_avatar/discuss.px4.io/sibujacob/32/9673_2.png) [@sibujacob](https://discuss.px4.io/u/sibujacob)\
**Post date:** [January 27, 2023, 4:51pm UTC](https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575/4 "2023-01-27T16:51:12Z")

</div>

great info !! Actually i am a bit confused . Is it better to go the MavROS way or the MAVSDK way to control the Quadcopter in offboard mode …

---

<div class="post-metadata">

**Author:** ![AlexWUrobot](https://discuss.px4.io/user_avatar/discuss.px4.io/alexwurobot/32/11387_2.png) [@AlexWUrobot](https://discuss.px4.io/u/AlexWUrobot)\
**Post date:** [January 27, 2023, 5:05pm UTC](https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575/5 "2023-01-27T17:05:08Z")

</div>

I have not tried MAVSDK, but I think this link will be helpful:[Difference MAVLink and MAVROS](https://discuss.px4.io/t/difference-mavlink-and-mavros/11017)

She said:

MAVROS is the bridge between MAVLink and ROS. If you’re using ROS for whatever robotics you’re doing, then MAVROS is great.  
If all you want is to write a simple C++ program to talk to a PX4 drone, then you should consider using [the Dronecode SDK](https://sdk.dronecode.org/en)

---

<div class="post-metadata">

**Author:** ![sibujacob](https://discuss.px4.io/user_avatar/discuss.px4.io/sibujacob/32/9673_2.png) [@sibujacob](https://discuss.px4.io/u/sibujacob)\
**Post date:** [January 27, 2023, 6:16pm UTC](https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575/6 "2023-01-27T18:16:02Z")

</div>

thank you for the info…

---

<div class="post-metadata">

**Author:** ![AlexWUrobot](https://discuss.px4.io/user_avatar/discuss.px4.io/alexwurobot/32/11387_2.png) [@AlexWUrobot](https://discuss.px4.io/u/AlexWUrobot)\
**Post date:** [January 28, 2023, 6:19am UTC](https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575/7 "2023-01-28T06:19:42Z")

</div>

The solution may be to edit the SD card in the Pixhawk  
But I only find how to change the IMU instead of the distance sensor now.

```auto
cd /fs/microsd/etc
echo "mavlink stream -d /dev/ttyACM0 -s HIGHRES_IMU -r 100" > extras.txt

```

> <https://github.com/mavlink/mavros/issues/1346>
>
> \### Issue details
> 
> I need to change the update rate of my 3DR Pixhawk IMU from… 50 Hz to 100 Hz. I've tried with \`rosrun mavros mavsys rate --all 100\` from terminal but it still remains at 50. 
> Can somebody show me how to do this? Thanks.
> 
> 
> \### MAVROS version and platform
> 
> Mavros: ?0.18.4?
> ROS: Melodic
> Ubuntu: 18.04
> 
> 
> \### Autopilot type and version
> 
> \[\] ArduPilot
> \[X \] PX4
> 
> Version: Fimware 1.9.2
> 
> 
> \### Node logs
> 
> \`\`\`
> $ roslaunch mavros px4.launch
> ... logging to /home/francesco/.ros/log/9f8841d2-0631-11ea-bf51-7cb0c2639a2f/roslaunch-Enterprise-Ubuntu-5233.log
> Checking log directory for disk usage. This may take awhile.
> Press Ctrl-C to interrupt
> Done checking log file disk usage. Usage is \<1GB.
> 
> /opt/ros/melodic/lib/python2.7/dist-packages/roslaunch/loader.py:412: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
> data = yaml.load(text)
> started roslaunch server http://Enterprise-Ubuntu:42721/
> 
> SUMMARY
> ========
> 
> CLEAR PARAMETERS
> \* /mavros/
> 
> PARAMETERS
> \* /mavros/cmd/use\_comp\_id\_system\_control: False
> \* /mavros/conn/heartbeat\_rate: 1.0
> \* /mavros/conn/system\_time\_rate: 1.0
> \* /mavros/conn/timeout: 10.0
> \* /mavros/conn/timesync\_rate: 10.0
> \* /mavros/distance\_sensor/hrlv\_ez4\_pub/field\_of\_view: 0.0
> \* /mavros/distance\_sensor/hrlv\_ez4\_pub/frame\_id: hrlv\_ez4\_sonar
> \* /mavros/distance\_sensor/hrlv\_ez4\_pub/id: 0
> \* /mavros/distance\_sensor/hrlv\_ez4\_pub/orientation: PITCH\_270
> \* /mavros/distance\_sensor/hrlv\_ez4\_pub/send\_tf: True
> \* /mavros/distance\_sensor/hrlv\_ez4\_pub/sensor\_position/x: 0.0
> \* /mavros/distance\_sensor/hrlv\_ez4\_pub/sensor\_position/y: 0.0
> \* /mavros/distance\_sensor/hrlv\_ez4\_pub/sensor\_position/z: -0.1
> \* /mavros/distance\_sensor/laser\_1\_sub/id: 3
> \* /mavros/distance\_sensor/laser\_1\_sub/orientation: PITCH\_270
> \* /mavros/distance\_sensor/laser\_1\_sub/subscriber: True
> \* /mavros/distance\_sensor/lidarlite\_pub/field\_of\_view: 0.0
> \* /mavros/distance\_sensor/lidarlite\_pub/frame\_id: lidarlite\_laser
> \* /mavros/distance\_sensor/lidarlite\_pub/id: 1
> \* /mavros/distance\_sensor/lidarlite\_pub/orientation: PITCH\_270
> \* /mavros/distance\_sensor/lidarlite\_pub/send\_tf: True
> \* /mavros/distance\_sensor/lidarlite\_pub/sensor\_position/x: 0.0
> \* /mavros/distance\_sensor/lidarlite\_pub/sensor\_position/y: 0.0
> \* /mavros/distance\_sensor/lidarlite\_pub/sensor\_position/z: -0.1
> \* /mavros/distance\_sensor/sonar\_1\_sub/id: 2
> \* /mavros/distance\_sensor/sonar\_1\_sub/orientation: PITCH\_270
> \* /mavros/distance\_sensor/sonar\_1\_sub/subscriber: True
> \* /mavros/fake\_gps/eph: 2.0
> \* /mavros/fake\_gps/epv: 2.0
> \* /mavros/fake\_gps/fix\_type: 3
> \* /mavros/fake\_gps/geo\_origin/alt: 408.0
> \* /mavros/fake\_gps/geo\_origin/lat: 47.3667
> \* /mavros/fake\_gps/geo\_origin/lon: 8.55
> \* /mavros/fake\_gps/gps\_rate: 5.0
> \* /mavros/fake\_gps/mocap\_transform: True
> \* /mavros/fake\_gps/satellites\_visible: 5
> \* /mavros/fake\_gps/tf/child\_frame\_id: fix
> \* /mavros/fake\_gps/tf/frame\_id: map
> \* /mavros/fake\_gps/tf/listen: False
> \* /mavros/fake\_gps/tf/rate\_limit: 10.0
> \* /mavros/fake\_gps/tf/send: False
> \* /mavros/fake\_gps/use\_mocap: True
> \* /mavros/fake\_gps/use\_vision: False
> \* /mavros/fcu\_protocol: v2.0
> \* /mavros/fcu\_url: /dev/ttyACM0:57600
> \* /mavros/gcs\_url: 
> \* /mavros/global\_position/child\_frame\_id: base\_link
> \* /mavros/global\_position/frame\_id: map
> \* /mavros/global\_position/gps\_uere: 1.0
> \* /mavros/global\_position/rot\_covariance: 99999.0
> \* /mavros/global\_position/tf/child\_frame\_id: base\_link
> \* /mavros/global\_position/tf/frame\_id: map
> \* /mavros/global\_position/tf/global\_frame\_id: earth
> \* /mavros/global\_position/tf/send: False
> \* /mavros/global\_position/use\_relative\_alt: True
> \* /mavros/image/frame\_id: px4flow
> \* /mavros/imu/angular\_velocity\_stdev: 0.0003490659 // 0...
> \* /mavros/imu/frame\_id: base\_link
> \* /mavros/imu/linear\_acceleration\_stdev: 0.0003
> \* /mavros/imu/magnetic\_stdev: 0.0
> \* /mavros/imu/orientation\_stdev: 1.0
> \* /mavros/landing\_target/camera/fov\_x: 2.0071286398
> \* /mavros/landing\_target/camera/fov\_y: 2.0071286398
> \* /mavros/landing\_target/image/height: 480
> \* /mavros/landing\_target/image/width: 640
> \* /mavros/landing\_target/land\_target\_type: VISION\_FIDUCIAL
> \* /mavros/landing\_target/listen\_lt: False
> \* /mavros/landing\_target/mav\_frame: LOCAL\_NED
> \* /mavros/landing\_target/target\_size/x: 0.3
> \* /mavros/landing\_target/target\_size/y: 0.3
> \* /mavros/landing\_target/tf/child\_frame\_id: camera\_center
> \* /mavros/landing\_target/tf/frame\_id: landing\_target
> \* /mavros/landing\_target/tf/listen: False
> \* /mavros/landing\_target/tf/rate\_limit: 10.0
> \* /mavros/landing\_target/tf/send: True
> \* /mavros/local\_position/frame\_id: map
> \* /mavros/local\_position/tf/child\_frame\_id: base\_link
> \* /mavros/local\_position/tf/frame\_id: map
> \* /mavros/local\_position/tf/send: False
> \* /mavros/local\_position/tf/send\_fcu: False
> \* /mavros/mission/pull\_after\_gcs: True
> \* /mavros/mocap/use\_pose: True
> \* /mavros/mocap/use\_tf: False
> \* /mavros/odometry/in/child\_frame\_id: base\_link
> \* /mavros/odometry/in/frame\_id: odom
> \* /mavros/odometry/in/frame\_tf/body\_frame\_orientation: flu
> \* /mavros/odometry/in/frame\_tf/local\_frame: local\_origin\_ned
> \* /mavros/odometry/out/frame\_tf/body\_frame\_orientation: frd
> \* /mavros/odometry/out/frame\_tf/local\_frame: vision\_ned
> \* /mavros/plugin\_blacklist: \['safety\_area', '...
> \* /mavros/plugin\_whitelist: \[\]
> \* /mavros/px4flow/frame\_id: px4flow
> \* /mavros/px4flow/ranger\_fov: 0.118682
> \* /mavros/px4flow/ranger\_max\_range: 5.0
> \* /mavros/px4flow/ranger\_min\_range: 0.3
> \* /mavros/safety\_area/p1/x: 1.0
> \* /mavros/safety\_area/p1/y: 1.0
> \* /mavros/safety\_area/p1/z: 1.0
> \* /mavros/safety\_area/p2/x: -1.0
> \* /mavros/safety\_area/p2/y: -1.0
> \* /mavros/safety\_area/p2/z: -1.0
> \* /mavros/setpoint\_accel/send\_force: False
> \* /mavros/setpoint\_attitude/reverse\_thrust: False
> \* /mavros/setpoint\_attitude/tf/child\_frame\_id: target\_attitude
> \* /mavros/setpoint\_attitude/tf/frame\_id: map
> \* /mavros/setpoint\_attitude/tf/listen: False
> \* /mavros/setpoint\_attitude/tf/rate\_limit: 100.0
> \* /mavros/setpoint\_attitude/use\_quaternion: False
> \* /mavros/setpoint\_position/mav\_frame: LOCAL\_NED
> \* /mavros/setpoint\_position/tf/child\_frame\_id: target\_position
> \* /mavros/setpoint\_position/tf/frame\_id: map
> \* /mavros/setpoint\_position/tf/listen: False
> \* /mavros/setpoint\_position/tf/rate\_limit: 100.0
> \* /mavros/setpoint\_raw/thrust\_scaling: 1.0
> \* /mavros/setpoint\_velocity/mav\_frame: LOCAL\_NED
> \* /mavros/startup\_px4\_usb\_quirk: True
> \* /mavros/sys/disable\_diag: False
> \* /mavros/sys/min\_voltage: 10.0
> \* /mavros/target\_component\_id: 1
> \* /mavros/target\_system\_id: 1
> \* /mavros/tdr\_radio/low\_rssi: 40
> \* /mavros/time/time\_ref\_source: fcu
> \* /mavros/time/timesync\_avg\_alpha: 0.6
> \* /mavros/time/timesync\_mode: MAVLINK
> \* /mavros/vibration/frame\_id: base\_link
> \* /mavros/vision\_pose/tf/child\_frame\_id: vision\_estimate
> \* /mavros/vision\_pose/tf/frame\_id: map
> \* /mavros/vision\_pose/tf/listen: False
> \* /mavros/vision\_pose/tf/rate\_limit: 10.0
> \* /mavros/vision\_speed/listen\_twist: True
> \* /mavros/vision\_speed/twist\_cov: True
> \* /mavros/wheel\_odometry/child\_frame\_id: base\_link
> \* /mavros/wheel\_odometry/count: 2
> \* /mavros/wheel\_odometry/frame\_id: map
> \* /mavros/wheel\_odometry/send\_raw: True
> \* /mavros/wheel\_odometry/send\_twist: False
> \* /mavros/wheel\_odometry/tf/child\_frame\_id: base\_link
> \* /mavros/wheel\_odometry/tf/frame\_id: map
> \* /mavros/wheel\_odometry/tf/send: True
> \* /mavros/wheel\_odometry/use\_rpm: False
> \* /mavros/wheel\_odometry/vel\_error: 0.1
> \* /mavros/wheel\_odometry/wheel0/radius: 0.05
> \* /mavros/wheel\_odometry/wheel0/x: 0.0
> \* /mavros/wheel\_odometry/wheel0/y: -0.15
> \* /mavros/wheel\_odometry/wheel1/radius: 0.05
> \* /mavros/wheel\_odometry/wheel1/x: 0.0
> \* /mavros/wheel\_odometry/wheel1/y: 0.15
> \* /rosdistro: melodic
> \* /rosversion: 1.14.3
> 
> NODES
> /
> mavros (mavros/mavros\_node)
> 
> auto-starting new master
> process\[master\]: started with pid \[5243\]
> ROS\_MASTER\_URI=http://localhost:11311
> 
> setting /run\_id to 9f8841d2-0631-11ea-bf51-7cb0c2639a2f
> process\[rosout-1\]: started with pid \[5254\]
> started core service \[/rosout\]
> process\[mavros-2\]: started with pid \[5262\]
> \[INFO\] \[1573662079.656099451\]: FCU URL: /dev/ttyACM0:57600
> \[INFO\] \[1573662079.657818878\]: serial0: device: /dev/ttyACM0 @ 57600 bps
> \[INFO\] \[1573662079.658671139\]: GCS bridge disabled
> \[INFO\] \[1573662079.668287823\]: Plugin 3dr\_radio loaded
> \[INFO\] \[1573662079.670016509\]: Plugin 3dr\_radio initialized
> \[INFO\] \[1573662079.670234880\]: Plugin actuator\_control loaded
> \[INFO\] \[1573662079.673824565\]: Plugin actuator\_control initialized
> \[INFO\] \[1573662079.676823138\]: Plugin adsb loaded
> \[INFO\] \[1573662079.679591729\]: Plugin adsb initialized
> \[INFO\] \[1573662079.679736826\]: Plugin altitude loaded
> \[INFO\] \[1573662079.680577553\]: Plugin altitude initialized
> \[INFO\] \[1573662079.680694493\]: Plugin cam\_imu\_sync loaded
> \[INFO\] \[1573662079.681215995\]: Plugin cam\_imu\_sync initialized
> \[INFO\] \[1573662079.681369384\]: Plugin command loaded
> \[INFO\] \[1573662079.686094142\]: Plugin command initialized
> \[INFO\] \[1573662079.686310664\]: Plugin companion\_process\_status loaded
> \[INFO\] \[1573662079.688988588\]: Plugin companion\_process\_status initialized
> \[INFO\] \[1573662079.689143500\]: Plugin debug\_value loaded
> \[INFO\] \[1573662079.692692067\]: Plugin debug\_value initialized
> \[INFO\] \[1573662079.692721989\]: Plugin distance\_sensor blacklisted
> \[INFO\] \[1573662079.692852557\]: Plugin fake\_gps loaded
> \[INFO\] \[1573662079.703168760\]: Plugin fake\_gps initialized
> \[INFO\] \[1573662079.703309628\]: Plugin ftp loaded
> \[INFO\] \[1573662079.709523824\]: Plugin ftp initialized
> \[INFO\] \[1573662079.709638065\]: Plugin global\_position loaded
> \[INFO\] \[1573662079.720811903\]: Plugin global\_position initialized
> \[INFO\] \[1573662079.720962746\]: Plugin gps\_rtk loaded
> \[INFO\] \[1573662079.722741699\]: Plugin gps\_rtk initialized
> \[INFO\] \[1573662079.722921430\]: Plugin hil loaded
> \[INFO\] \[1573662079.731383343\]: Plugin hil initialized
> \[INFO\] \[1573662079.731495199\]: Plugin home\_position loaded
> \[INFO\] \[1573662079.733835446\]: Plugin home\_position initialized
> \[INFO\] \[1573662079.733994260\]: Plugin imu loaded
> \[INFO\] \[1573662079.739424375\]: Plugin imu initialized
> \[INFO\] \[1573662079.739531799\]: Plugin landing\_target loaded
> \[INFO\] \[1573662079.747782105\]: Plugin landing\_target initialized
> \[INFO\] \[1573662079.747929336\]: Plugin local\_position loaded
> \[INFO\] \[1573662079.753258482\]: Plugin local\_position initialized
> \[INFO\] \[1573662079.753415197\]: Plugin log\_transfer loaded
> \[INFO\] \[1573662079.756249202\]: Plugin log\_transfer initialized
> \[INFO\] \[1573662079.756393930\]: Plugin manual\_control loaded
> \[INFO\] \[1573662079.759077952\]: Plugin manual\_control initialized
> \[INFO\] \[1573662079.759176190\]: Plugin mocap\_pose\_estimate loaded
> \[INFO\] \[1573662079.761567698\]: Plugin mocap\_pose\_estimate initialized
> \[INFO\] \[1573662079.761662659\]: Plugin mount\_control loaded
> \[INFO\] \[1573662079.763184661\]: Plugin mount\_control initialized
> \[INFO\] \[1573662079.763270277\]: Plugin obstacle\_distance loaded
> \[INFO\] \[1573662079.764577824\]: Plugin obstacle\_distance initialized
> \[INFO\] \[1573662079.764663047\]: Plugin odom loaded
> \[INFO\] \[1573662079.769220272\]: Plugin odom initialized
> \[INFO\] \[1573662079.769407834\]: Plugin param loaded
> \[INFO\] \[1573662079.771911625\]: Plugin param initialized
> \[INFO\] \[1573662079.772008356\]: Plugin px4flow loaded
> \[INFO\] \[1573662079.777775497\]: Plugin px4flow initialized
> \[INFO\] \[1573662079.777832945\]: Plugin rangefinder blacklisted
> \[INFO\] \[1573662079.778001135\]: Plugin rc\_io loaded
> \[INFO\] \[1573662079.782147715\]: Plugin rc\_io initialized
> \[INFO\] \[1573662079.782185354\]: Plugin safety\_area blacklisted
> \[INFO\] \[1573662079.782305933\]: Plugin setpoint\_accel loaded
> \[INFO\] \[1573662079.785404626\]: Plugin setpoint\_accel initialized
> \[INFO\] \[1573662079.785592574\]: Plugin setpoint\_attitude loaded
> \[INFO\] \[1573662079.793386243\]: Plugin setpoint\_attitude initialized
> \[INFO\] \[1573662079.793545462\]: Plugin setpoint\_position loaded
> \[INFO\] \[1573662079.801512386\]: Plugin setpoint\_position initialized
> \[INFO\] \[1573662079.801628355\]: Plugin setpoint\_raw loaded
> \[INFO\] \[1573662079.807218690\]: Plugin setpoint\_raw initialized
> \[INFO\] \[1573662079.807359336\]: Plugin setpoint\_velocity loaded
> \[INFO\] \[1573662079.811608805\]: Plugin setpoint\_velocity initialized
> \[INFO\] \[1573662079.811879909\]: Plugin sys\_status loaded
> \[INFO\] \[1573662079.818481006\]: Plugin sys\_status initialized
> \[INFO\] \[1573662079.818604306\]: Plugin sys\_time loaded
> \[INFO\] \[1573662079.822532412\]: TM: Timesync mode: MAVLINK
> \[INFO\] \[1573662079.823434894\]: Plugin sys\_time initialized
> \[INFO\] \[1573662079.823557027\]: Plugin trajectory loaded
> \[INFO\] \[1573662079.827016129\]: Plugin trajectory initialized
> \[INFO\] \[1573662079.827122485\]: Plugin vfr\_hud loaded
> \[INFO\] \[1573662079.827564281\]: Plugin vfr\_hud initialized
> \[INFO\] \[1573662079.827587796\]: Plugin vibration blacklisted
> \[INFO\] \[1573662079.827679201\]: Plugin vision\_pose\_estimate loaded
> \[INFO\] \[1573662079.832146564\]: Plugin vision\_pose\_estimate initialized
> \[INFO\] \[1573662079.832230922\]: Plugin vision\_speed\_estimate loaded
> \[INFO\] \[1573662079.834574641\]: Plugin vision\_speed\_estimate initialized
> \[INFO\] \[1573662079.834694576\]: Plugin waypoint loaded
> \[INFO\] \[1573662079.839075768\]: Plugin waypoint initialized
> \[INFO\] \[1573662079.839138598\]: Plugin wheel\_odometry blacklisted
> \[INFO\] \[1573662079.839311319\]: Plugin wind\_estimation loaded
> \[INFO\] \[1573662079.839938926\]: Plugin wind\_estimation initialized
> \[INFO\] \[1573662079.840002397\]: Autostarting mavlink via USB on PX4
> \[INFO\] \[1573662079.840114082\]: Built-in SIMD instructions: SSE, SSE2
> \[INFO\] \[1573662079.840133882\]: Built-in MAVLink package version: 2019.9.9
> \[INFO\] \[1573662079.840199602\]: Known MAVLink dialects: common ardupilotmega ASLUAV autoquad icarous matrixpilot paparazzi slugs standard uAvionix ualberta
> \[INFO\] \[1573662079.840240252\]: MAVROS started. MY ID 1.240, TARGET ID 1.1
> \[INFO\] \[1573662079.935933482\]: IMU: Scaled IMU message used.
> \[ERROR\] \[1573662079.944128361\]: ODOM: Ex: Could not find a connection between 'local\_origin\_ned' and 'fcu' because they are not part of the same tree.Tf has two or more unconnected trees.
> \[INFO\] \[1573662080.004054503\]: IMU: High resolution IMU detected!
> \[INFO\] \[1573662080.005016911\]: IMU: Attitude quaternion IMU detected!
> \[INFO\] \[1573662080.487696816\]: CON: Got HEARTBEAT, connected. FCU: PX4 Autopilot
> \[INFO\] \[1573662080.514897068\]: IMU: High resolution IMU detected!
> \[INFO\] \[1573662080.515470700\]: IMU: Attitude quaternion IMU detected!
> \[ERROR\] \[1573662080.814692169\]: FCU: Data link lost
> \[INFO\] \[1573662080.906314290\]: FCU: Onboard controller regained
> \[ERROR\] \[1573662080.980156568\]: ODOM: Ex: Could not find a connection between 'local\_origin\_ned' and 'fcu' because they are not part of the same tree.Tf has two or more unconnected trees.
> \[INFO\] \[1573662081.493774084\]: VER: 1.1: Capabilities 0x000000000000e4ef
> \[INFO\] \[1573662081.493921415\]: VER: 1.1: Flight software: 010902ff (106905871d000000)
> \[INFO\] \[1573662081.493999177\]: VER: 1.1: Middleware software: 010902ff (106905871d000000)
> \[INFO\] \[1573662081.494088606\]: VER: 1.1: OS software: 071c00ff (423371c7d4012e72)
> \[INFO\] \[1573662081.494167688\]: VER: 1.1: Board hardware: 00000011
> \[INFO\] \[1573662081.494232908\]: VER: 1.1: VID/PID: 26ac:0011
> \[INFO\] \[1573662081.494285964\]: VER: 1.1: UID: 3034510736353832
> \[WARN\] \[1573662081.496977880\]: CMD: Unexpected command 520, result 0
> \[ERROR\] \[1573662081.996994591\]: ODOM: Ex: Could not find a connection between 'local\_origin\_ned' and 'fcu' because they are not part of the same tree.Tf has two or more unconnected trees.
> \[ERROR\] \[1573662083.027204250\]: ODOM: Ex: Could not find a connection between 'local\_origin\_ned' and 'fcu' because they are not part of the same tree.Tf has two or more unconnected trees.
> \[ERROR\] \[1573662084.027444532\]: ODOM: Ex: Could not find a connection between 'local\_origin\_ned' and 'fcu' because they are not part of the same tree.Tf has two or more unconnected trees.
> \[ERROR\] \[1573662085.061106727\]: ODOM: Ex: Could not find a connection between 'local\_origin\_ned' and 'fcu' because they are not part of the same tree.Tf has two or more unconnected trees.
> \[ERROR\] \[1573662086.095190534\]: ODOM: Ex: Could not find a connection between 'local\_origin\_ned' and 'fcu' because they are not part of the same tree.Tf has two or more unconnected trees.
> \[ERROR\] \[1573662087.096480620\]: ODOM: Ex: Could not find a connection between 'local\_origin\_ned' and 'fcu' because they are not part of the same tree.Tf has two or more unconnected trees.
> \[ERROR\] \[1573662088.097932593\]: ODOM: Ex: Could not find a connection between 'local\_origin\_ned' and 'fcu' because they are not part of the same tree.Tf has two or more unconnected trees.
> \[ERROR\] \[1573662089.128315701\]: ODOM: Ex: Could not find a connection between 'local\_origin\_ned' and 'fcu' because they are not part of the same tree.Tf has two or more unconnected trees.
> \[ERROR\] \[1573662090.129052823\]: ODOM: Ex: Could not find a connection between 'local\_origin\_ned' and 'fcu' because they are not part of the same tree.Tf has two or more unconnected trees.
> \[INFO\] \[1573662090.488257328\]: HP: requesting home position
> 
> \`\`\`
> 
> \### Diagnostics
> 
> \`\`\`
> header: 
> seq: 8
> stamp: 
> secs: 1573662083
> nsecs: 341054933
> frame\_id: ''
> status: 
> - 
> level: 0
> name: "mavros: FCU connection"
> message: "connected"
> hardware\_id: "/dev/ttyACM0:57600"
> values: 
> - 
> key: "Received packets:"
> value: "1175"
> - 
> key: "Dropped packets:"
> value: "0"
> - 
> key: "Buffer overruns:"
> value: "0"
> - 
> key: "Parse errors:"
> value: "0"
> - 
> key: "Rx sequence number:"
> value: "128"
> - 
> key: "Tx sequence number:"
> value: "71"
> - 
> key: "Rx total bytes:"
> value: "66885"
> - 
> key: "Tx total bytes:"
> value: "1896"
> - 
> key: "Rx speed:"
> value: "34703.000000"
> - 
> key: "Tx speed:"
> value: "835.000000"
> - 
> level: 2
> name: "mavros: GPS"
> message: "No satellites"
> hardware\_id: "/dev/ttyACM0:57600"
> values: 
> - 
> key: "Satellites visible"
> value: "0"
> - 
> key: "Fix type"
> value: "0"
> - 
> key: "EPH (m)"
> value: "Unknown"
> - 
> key: "EPV (m)"
> value: "Unknown"
> - 
> level: 0
> name: "mavros: Heartbeat"
> message: "Normal"
> hardware\_id: "/dev/ttyACM0:57600"
> values: 
> - 
> key: "Heartbeats since startup"
> value: "3"
> - 
> key: "Frequency (Hz)"
> value: "0.850095"
> - 
> key: "Vehicle type"
> value: "Quadrotor"
> - 
> key: "Autopilot type"
> value: "PX4 Autopilot"
> - 
> key: "Mode"
> value: "MANUAL"
> - 
> key: "System status"
> value: "Standby"
> - 
> level: 2
> name: "mavros: System"
> message: "Sensor health"
> hardware\_id: "/dev/ttyACM0:57600"
> values: 
> - 
> key: "Sensor present"
> value: "0x0006002F"
> - 
> key: "Sensor enabled"
> value: "0x0021000F"
> - 
> key: "Sensor health"
> value: "0x0006002F"
> - 
> key: "3D gyro"
> value: "Ok"
> - 
> key: "3D accelerometer"
> value: "Ok"
> - 
> key: "3D magnetometer"
> value: "Ok"
> - 
> key: "absolute pressure"
> value: "Ok"
> - 
> key: "rc receiver"
> value: "Fail"
> - 
> key: "AHRS subsystem health"
> value: "Fail"
> - 
> key: "CPU Load (%)"
> value: "47.9"
> - 
> key: "Drop rate (%)"
> value: "0.0"
> - 
> key: "Errors comm"
> value: "0"
> - 
> key: "Errors count #1"
> value: "0"
> - 
> key: "Errors count #2"
> value: "0"
> - 
> key: "Errors count #3"
> value: "0"
> - 
> key: "Errors count #4"
> value: "0"
> - 
> level: 0
> name: "mavros: Battery"
> message: "Normal"
> hardware\_id: "/dev/ttyACM0:57600"
> values: 
> - 
> key: "Voltage"
> value: "65.54"
> - 
> key: "Current"
> value: "-0.0"
> - 
> key: "Remaining"
> value: "-1.0"
> - 
> level: 0
> name: "mavros: Time Sync"
> message: "Normal"
> hardware\_id: "/dev/ttyACM0:57600"
> values: 
> - 
> key: "Timesyncs since startup"
> value: "35"
> - 
> key: "Frequency (Hz)"
> value: "9.936432"
> - 
> key: "Last RTT (ms)"
> value: "1.598668"
> - 
> key: "Mean RTT (ms)"
> value: "1.001017"
> - 
> key: "Last remote time (s)"
> value: "392.844721000"
> - 
> key: "Estimated time offset (s)"
> value: "1573661690.480628252"
> \---
> 
> \`\`\`
> 
> \### Check ID
> 
> \`\`\`
> OK. I got messages from 1:1.
> 
> \---
> Received 6075 messages, from 1 addresses
> sys:comp list of messages
> 1:1 0, 1, 2, 4, 140, 141, 147, 26, 30, 31, 32, 36, 74, 331, 77, 83, 340, 230, 105, 111, 241, 116, 245
> 
> \`\`\`

---

<div class="post-metadata">

**Author:** ![sibujacob](https://discuss.px4.io/user_avatar/discuss.px4.io/sibujacob/32/9673_2.png) [@sibujacob](https://discuss.px4.io/u/sibujacob)\
**Post date:** [January 28, 2023, 3:04pm UTC](https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575/8 "2023-01-28T15:04:46Z")

</div>

What about accessing Lidarlite from the Mavlink console menu in QGC . There is an option to adjust the bus frequency

 ![Screenshot (449)](https://discuss.px4.io/uploads/default/original/2X/a/a5aed9f77ef3bb6d88773fd398373277c7305034.png)

---

<div class="post-metadata">

**Author:** ![AlexWUrobot](https://discuss.px4.io/user_avatar/discuss.px4.io/alexwurobot/32/11387_2.png) [@AlexWUrobot](https://discuss.px4.io/u/AlexWUrobot)\
**Post date:** [January 29, 2023, 4:41am UTC](https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575/9 "2023-01-29T04:41:52Z")

</div>

Thanks for the info. I also found this but the unit is kHz, so I guess it may be for communication rate, instead of sampling rate. [Distance Sensor · PX4 Developer Guide](https://dev.px4.io/master/en/middleware/modules_driver_distance_sensor.html)

I will still try that. Thanks for the reminder again.

---

<div class="post-metadata">

**Author:** ![AlexWUrobot](https://discuss.px4.io/user_avatar/discuss.px4.io/alexwurobot/32/11387_2.png) [@AlexWUrobot](https://discuss.px4.io/u/AlexWUrobot)\
**Post date:** [January 30, 2023, 5:04am UTC](https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575/10 "2023-01-30T05:04:04Z")

</div>

I found some people have the similar issue  
ref: [lidar lite slow read rate · Issue #367 · intel-aero/meta-intel-aero · GitHub](https://github.com/intel-aero/meta-intel-aero/issues/367)

My publish rate of (/mavros/distance\_sensor/lidarlite\_pub) is 10 hz in the simulation, but only 2 Hz in the real world, when readling from Pixhawk 4 (fmuV5).

If we assume the lidar-lite works well (default sampling rate 10Hz)  
I would like to guess the issue may be due to the setting on Pixhawk?

Thus, I screenshot the other parameters of distance sensor (rangefinder) in the QGroundControl

 ![image](https://discuss.px4.io/uploads/default/original/2X/e/ea968ae4ae30eec2f7e921e36ef8941a67263490.png)

---

<div class="post-metadata">

**Author:** ![AlexWUrobot](https://discuss.px4.io/user_avatar/discuss.px4.io/alexwurobot/32/11387_2.png) [@AlexWUrobot](https://discuss.px4.io/u/AlexWUrobot)\
**Post date:** [January 30, 2023, 6:17am UTC](https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575/11 "2023-01-30T06:17:33Z")

</div>

I also guess the issue may be due to this revision on **LidarLiteI2C.h**  
ref: [increased rate of Lidar Lite driver over I2C · PX4/PX4-Autopilot@7ca16cd · GitHub](https://github.com/PX4/PX4-Autopilot/commit/7ca16cd5040d8ee66262ecfe5485e4ea67a36570)

 ![image](https://discuss.px4.io/uploads/default/original/2X/1/1e89d3fac9f752bfa064e62aaee13f70b4dba682.png)  
 ![image](https://discuss.px4.io/uploads/default/original/2X/c/c8cfeb4ab16deec33f619c5b7af3c800a6dd0db4.png)

Maybe, I should change it to 10 ms and then

```auto
cd PX4-Autopilot
make px4_fmu-v5_default

```

ref: [Building PX4 Software | PX4 User Guide](https://docs.px4.io/main/en/dev_setup/building_px4.html)

---

<div class="post-metadata">

**Author:** ![sibujacob](https://discuss.px4.io/user_avatar/discuss.px4.io/sibujacob/32/9673_2.png) [@sibujacob](https://discuss.px4.io/u/sibujacob)\
**Post date:** [January 30, 2023, 6:43am UTC](https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575/12 "2023-01-30T06:43:46Z")

</div>

Great info…My concern is how do you built the px4 after changing the value …Do you have a complete procedure for doing this through Nuttx shell

---

<div class="post-metadata">

**Author:** ![AlexWUrobot](https://discuss.px4.io/user_avatar/discuss.px4.io/alexwurobot/32/11387_2.png) [@AlexWUrobot](https://discuss.px4.io/u/AlexWUrobot)\
**Post date:** [May 14, 2023, 12:38am UTC](https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575/13 "2023-05-14T00:38:01Z")

</div>

I am still working for this issue.  
I further tested the lidar-lite-v3 sensor with the arduino UNO by the below wiring  
 ![image](https://discuss.px4.io/uploads/default/original/2X/6/638cada7c817ac9cfb1751a2e508973bcba3113c.png)  
ref: [https://static.garmin.com/pumac/LIDAR\_Lite\_v3\_Operation\_Manual\_and\_Technical\_Specifications.pdf](https://static.garmin.com/pumac/LIDAR_Lite_v3_Operation_Manual_and_Technical_Specifications.pdf)

After Arduino measurement, the sampling rate is about 80~90 Hz.  
video: [Arduino Test Lidar lite v3 sampling rate 2023 05 13 - YouTube](https://youtu.be/ZarTXdL1HPg)

 ![image](https://discuss.px4.io/uploads/default/original/2X/b/b36815d3e9430a1ece98c827656e3da16984739b.png)  
The code is used from the link: [https://learn.sparkfun.com/tutorials/lidar-lite-v3-hookup-guide/all](https://learn.sparkfun.com/tutorials/lidar-lite-v3-hookup-guide/all)

````auto
/**
 * LIDARLite I2C Example
 * Author: Garmin
 * Modified by: Shawn Hymel (SparkFun Electronics)
 * Date: June 29, 2017
 * 
 * Read distance from LIDAR-Lite v3 over I2C
 * 
 * See the Operation Manual for wiring diagrams and more information:
 * http://static.garmin.com/pumac/LIDAR_Lite_v3_Operation_Manual_and_Technical_Specifications.pdf
 */

#include <Wire.h>
#include <LIDARLite.h>

// Globals
LIDARLite lidarLite;
int cal_cnt = 0;
unsigned long previousMillis = 0; // variable to store the previous time

void setup()
{
  Serial.begin(9600); // Initialize serial connection to display distance readings

  lidarLite.begin(0, true); // Set configuration to default and I2C to 400 kHz
  lidarLite.configure(0); // Change this number to try out alternate configurations
}

void loop()
{
  int dist;
  unsigned long currentMillis = millis(); // varia

  // At the beginning of every 100 readings,
  // take a measurement with receiver bias correction
  if ( cal_cnt == 0 ) {
    dist = lidarLite.distance(); // With bias correction
  } else {
    dist = lidarLite.distance(false); // Without bias correction
  }

  // Increment reading counter
  cal_cnt++;
  cal_cnt = cal_cnt % 100;

  // Display distance
  Serial.print(dist);
  Serial.println(" cm");

  Serial.println(currentMillis - previousMillis); // display time elapsed for line 1
  previousMillis = currentMillis;

  //delay(10);
}```
````

---

<div class="post-metadata">

**Author:** ![AlexWUrobot](https://discuss.px4.io/user_avatar/discuss.px4.io/alexwurobot/32/11387_2.png) [@AlexWUrobot](https://discuss.px4.io/u/AlexWUrobot)\
**Post date:** [May 16, 2023, 6:24pm UTC](https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575/14 "2023-05-16T18:24:23Z")

</div>

I think I find something useful in the QGroundcontrol.  
In the MAVlink tab, the telemetry stream rates for raw sensors is 2Hz

 ![image](https://discuss.px4.io/uploads/default/original/2X/f/ffd988f25c11b2666d9031ee7f639af0ff46ca9a.png)

rosrun mavros mavsys rate --all 50

ref: [increase/change mavros local\_position pose publish frequency - ROS Answers: Open Source Q&A Forum](https://answers.ros.org/question/361371/increasechange-mavros-local_position-pose-publish-frequency/)

I find  
If using wireless telemetry, the MAVLink Inspector can detect distance sensor about 0.8Hz  
If using micro usb, the MAVLink Inspector can detect distance sensor 10 Hz

 ![image](https://discuss.px4.io/uploads/default/original/2X/0/0192afb3def5330eedf33ebd2ec61ced16d2158a.png)

Thus, the lidar works well and QGroundcontrol works OK.  
The only issue may be MAVROS publisher frequency

---

<div class="post-metadata">

**Author:** ![AlexWUrobot](https://discuss.px4.io/user_avatar/discuss.px4.io/alexwurobot/32/11387_2.png) [@AlexWUrobot](https://discuss.px4.io/u/AlexWUrobot)\
**Post date:** [May 20, 2023, 12:49am UTC](https://discuss.px4.io/t/how-to-adjust-the-sample-rate-of-distance-sensor-rangefinder/30575/15 "2023-05-20T00:49:07Z")

</div>

There is the solution !!!  
To increase the sampling  
The SER\_TEL2\_BAUD need to be increased. (which was 115200)  
The MAV\_1\_RATE need to be increased.(which was 0)

 ![image](https://discuss.px4.io/uploads/default/original/2X/9/9fbb1754bc4463dd7aeb8006a37781f043d12b0b.png)

PX4-autopilot automatically [half-size the data](https://docs.px4.io/v1.11/en/peripherals/mavlink_peripherals.html), if the communication is too low.

 ![success_update_sampling_rate](https://discuss.px4.io/uploads/default/original/2X/9/95b8eaec51d696bfbf9d59e91900a0448f8662da.png)  
 ![image](https://discuss.px4.io/uploads/default/original/2X/3/32f2a98620e3384454d11d181ba9c4c726e5a3e5.png)

P.S.  
In a serial communication system, the data rate is measured in bits per second (baud rate). However, it’s important to note that a byte consists of 8 bits.  
At a baud rate of 921,600, the maximum number of bits that can be transmitted per second is 921,600. To determine the number of bytes transferred per second, you need to divide the baud rate by 8 (8 bits per byte).  
So, at a baud rate of 921,600, the maximum data transfer rate in bytes per second would be:  
921,600 bits/second / 8 bits/byte = 115,200 bytes/second  
Therefore, at a baud rate of 921,600, you can transfer a maximum of 115,200 bytes per second.
