paparazzi-devel
[Top][All Lists]

Re: [Paparazzi-devel] Flight plan - circle the closer of two waypoints?

 From: Pascal Brisset Subject: Re: [Paparazzi-devel] Flight plan - circle the closer of two waypoints? Date: Mon, 29 Mar 2010 11:16:00 +0200 User-agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090706)

```Hi,

```
for example, from basic.xml, by moving the MOB waypoint to the closest among 1 and 2:
```

```
#define DistanceSquareToWP(_wp) { DistanceSquare(estimator_x, estimator_y, WaypointX(_wp), WaypointY(_wp)); } #define ChooseClosestWP(wp_1, wp_2, wp_closer) ({ uint8_t tmp = LessThan(DistanceSquareToWP(wp_1), DistanceSquareToWP(wp_2)) ? wp_1 : wp_2; waypoints[wp_closer] = waypoints[tmp]; FALSE; })
```
and a new block:

<block name="Goto closer (1 or 2)">
<call fun="ChooseClosestWP(WP_1, WP_2, WP_MOB)"/>
</block>

--Pascal

Jeremy Reinertsen wrote:
```
```Hi folks,
```
I am currently learning how to write flight plans and would like to create a block which will cause the aircraft to travel to the closer of two waypoints and circle it. Can anyone suggest some sample flight plan code to determine which waypoint is the closest? Cheers Jeremy
```

```