PX4:main
← PX4:pr-posctrl-reference
opened 08:38PM - 30 Oct 22 UTC
## Describe problem solved by this pull request
For fixedwing position control,… waypoint coordinates projected on to the local frame are logged as local position setpoints. While this makes sense for waypoints, NPFG is capable of tracking paths, and logging what position reference the vehicle is trying to track would be much more informative. For example, when the vehicle is flying on a loiter path, we want to know how close the vehicle is to the closest point on the circle, rather than the center of the loiter circle.
## Describe your solution
This commit adds a state in the NPFG library which keeps the position setpoint reference so that it can be published as part of the `vehicle_local_position_setpoint` message.
When passing arbitrary references with a path in offboard mode, comparing the position reference and the current position provides better insights into how well the vehicle is tracking the path.
## Test data / coverage
Tested in SITL Gazebo
```
make px4_sitl gazebo_plane
```
**Before PR**
- Flight log: [log](https://review.px4.io/plot_app?log=1f580ba6-8e1a-4c79-886a-76215c045744)
![bokeh_plot (6)](https://user-images.githubusercontent.com/5248102/198900676-df52f6ff-2eb5-4d3e-a6f8-07de6519aa48.png)
![bokeh_plot (7)](https://user-images.githubusercontent.com/5248102/198900674-908f0dc3-d888-4ad7-aa77-3fa0452c9f53.png)
**After PR**
- Flight log: [log](https://review.px4.io/plot_app?log=c1b856a9-3240-432e-bac8-0570388a6c95)
- Part of the log shows a continuous position references from a loiter waypoint
![bokeh_plot (4)](https://user-images.githubusercontent.com/5248102/198900586-69efd7a6-e3ba-416d-9e70-3794f21ade0e.png)
![bokeh_plot (5)](https://user-images.githubusercontent.com/5248102/198900582-8c695568-fb9f-40ff-964c-222ec6221ffe.png)
## Additional context
Add any other related context or media.