SIM001

SIM001 › Beyond the cockpit › Flying by plan

What each primitive does

Each agent plan has one primitive. The primitive tells the plane how to fly: to a point, round a point, in a height band, after another aircraft or away from it. The plane holds each primitive until a new plan comes or the plan runs out.

The points of the plans are latitude and longitude, with the altitude above home. The console of the runner takes metres north and east of home, and changes them for you. The plane moves a circle in from the fence if the whole circle does not fit inside it.

We measured the distances and the heights on this page in a simulation of the T1-S that uses the same executor. The plane starts at 30 m over the arena centre, to the north, at 15 m/s. The console does not show these distances and heights. In the simulation, the other aircraft is a model plane too.

The other aircraft come from tracks. The ground sends each one as an ADSB_VEHICLE message. The low byte of its ICAO address is the id that a plan names as its target. The plane ignores a track that it has not heard for 3 s. In the runner, the ids of the planes are 1 for Kestrel, 2 for Merlin and 3 for Swift. After the game, the console sends the tracks of Merlin and Swift to Kestrel twice a second. Type silent to stop them, and heard to send them again.

Go to flies over the point, then circles it

The plane flies straight to the point. When it is over the point, it circles the point at the loiter radius, about 35 m for the T1-S. It holds the height of the plan.

If the reported primitive is go to and the time to live of the plan is 600 s, type wait 120 in the console. The plane flies over the point, within 10 m of it. In the last minute, the plane stays within 45 m of the point. In the last minute, the plane is always at least 38 m above home. In the last minute, the plane is never more than 42 m above home.

If the reported primitive is go to and the time to live of the plan is 600 s, type wait 120 in the console. The plane flies over the point, within 10 m of it. In the last minute, the plane stays within 45 m of the point. In the last minute, the plane is always at least 38 m above home. In the last minute, the plane is never more than 42 m above home.
How this is tested verified
Given the reported primitive is go to
  And the time to live of the plan is 600 s
When the plane flies on for 2 minutes
Then the closest approach to the point is at most 10 m
  And the greatest distance from the point in the last minute is at most 45 m
  And the lowest height in the last minute is at least 38 m
  And the highest height in the last minute is at most 42 m
Follows
AGENT mode takes a go-to plan
Tested by
Reaching «Go to flies over the point, then circles it» passed

An orbit plan circles a point

If the flight mode of the plane is AGENT, type plan orbit 70 0 45 45 600 in the console. This plan tells the plane to circle the arena centre at 45 m from it, at 45 m. The plane replies with COMMAND_ACK, result 0 (ACCEPTED). The console shows ack with result=0. AG_PLAN goes up by 1, to the id of the new plan (plan= in the console). AG_PRIM is 4, orbit (prim=4). The plan is good for 600 s.

If the flight mode of the plane is AGENT, type plan orbit 70 0 45 45 600 in the console. This plan tells the plane to circle the arena centre at 45 m from it, at 45 m. The plane replies with COMMAND_ACK, result 0 (ACCEPTED). The console shows ack with result=0. AG_PLAN goes up by 1, to the id of the new plan (plan= in the console). AG_PRIM is 4, orbit (prim=4). The plan is good for 600 s.

See it in Sending your first plan.

How this is tested verified
Given the flight mode of the plane is AGENT
When the ground sends an orbit plan
Then the reply to the plan is accepted
  And the reported plan goes up by 1
  And the reported primitive is orbit
  And the time to live of the plan is 600 s
Follows
the section's setup
Leads to
Orbit holds its radius and its height, The envelope leaves a safe plan alone
Tested by
Sending your first plan › Send a plan passed, Reaching «Orbit holds its radius and its height» passed, Reaching «The envelope leaves a safe plan alone» failed

Orbit holds its radius and its height

The plane circles the point at the radius of the plan, in the direction that it already turns. A radius that is too small for the plane becomes the smallest circle that it can fly.

If the reported primitive is orbit, type wait 120 in the console. In the last minute, the plane is always at least 40 m from the point. In the last minute, the plane stays within 50 m of the point. In the last minute, the plane is always at least 43 m above home. In the last minute, the plane is never more than 47 m above home.

If the reported primitive is orbit, type wait 120 in the console. In the last minute, the plane is always at least 40 m from the point. In the last minute, the plane stays within 50 m of the point. In the last minute, the plane is always at least 43 m above home. In the last minute, the plane is never more than 47 m above home.
How this is tested verified
Given the reported primitive is orbit
When the plane flies on for 2 minutes
Then the least distance from the point in the last minute is at least 40 m
  And the greatest distance from the point in the last minute is at most 50 m
  And the lowest height in the last minute is at least 43 m
  And the highest height in the last minute is at most 47 m
Follows
An orbit plan circles a point
Tested by
Reaching «Orbit holds its radius and its height» passed

A band plan holds a height band

If the flight mode of the plane is AGENT, type plan band 70 0 35 10 600 in the console. This plan tells the plane to stay between 35 m and 45 m over the arena. The plane replies with COMMAND_ACK, result 0 (ACCEPTED). The console shows ack with result=0. AG_PLAN goes up by 1, to the id of the new plan (plan= in the console). AG_PRIM is 5, band (prim=5). The plan is good for 600 s.

If the flight mode of the plane is AGENT, type plan band 70 0 35 10 600 in the console. This plan tells the plane to stay between 35 m and 45 m over the arena. The plane replies with COMMAND_ACK, result 0 (ACCEPTED). The console shows ack with result=0. AG_PLAN goes up by 1, to the id of the new plan (plan= in the console). AG_PRIM is 5, band (prim=5). The plan is good for 600 s.
How this is tested verified
Given the flight mode of the plane is AGENT
When the ground sends a band plan
Then the reply to the plan is accepted
  And the reported plan goes up by 1
  And the reported primitive is band
  And the time to live of the plan is 600 s
Follows
the section's setup
Leads to
Band keeps the plane between its two heights
Tested by
Reaching «A band plan holds a height band» passed, Reaching «Band keeps the plane between its two heights» passed

Band keeps the plane between its two heights

The altitude of a band plan is the bottom of the band, and its radius is the thickness of the band. The plane climbs or sinks into the band. Then it circles over the arena, inside the fence. In tag, each plane has its own band, so that two planes do not meet by chance.

If the reported primitive is band, type wait 120 in the console. In the last minute, the plane is always at least 34 m above home. In the last minute, the plane is never more than 46 m above home. The plane never goes out of the fence, 85 m round the arena centre.

If the reported primitive is band, type wait 120 in the console. In the last minute, the plane is always at least 34 m above home. In the last minute, the plane is never more than 46 m above home. The plane never goes out of the fence, 85 m round the arena centre.
How this is tested verified
Given the reported primitive is band
When the plane flies on for 2 minutes
Then the lowest height in the last minute is at least 34 m
  And the highest height in the last minute is at most 46 m
  And the farthest distance from the arena centre is at most 85 m
Follows
A band plan holds a height band
Tested by
Reaching «Band keeps the plane between its two heights» passed

A loiter plan circles where the plane is

If the flight mode of the plane is AGENT, type plan loiter 0 0 0 0 600 in the console. This plan tells the plane to circle where it is. The plane replies with COMMAND_ACK, result 0 (ACCEPTED). The console shows ack with result=0. AG_PLAN goes up by 1, to the id of the new plan (plan= in the console). AG_PRIM is 6, loiter (prim=6). The plan is good for 600 s.

If the flight mode of the plane is AGENT, type plan loiter 0 0 0 0 600 in the console. This plan tells the plane to circle where it is. The plane replies with COMMAND_ACK, result 0 (ACCEPTED). The console shows ack with result=0. AG_PLAN goes up by 1, to the id of the new plan (plan= in the console). AG_PRIM is 6, loiter (prim=6). The plan is good for 600 s.
How this is tested verified
Given the flight mode of the plane is AGENT
When the ground sends a loiter plan
Then the reply to the plan is accepted
  And the reported plan goes up by 1
  And the reported primitive is loiter
  And the time to live of the plan is 600 s
Follows
the section's setup
Leads to
Loiter stays round the place where it began
Tested by
Reaching «A loiter plan circles where the plane is» passed, Reaching «Loiter stays round the place where it began» passed

Loiter stays round the place where it began

The plane circles the place where it got the plan, at the loiter radius and at its height. Near the fence, the circle moves in until it fits.

If the reported primitive is loiter, type wait 120 in the console. In the last minute, the plane is always at least 25 m from the point. In the last minute, the plane stays within 45 m of the point.

If the reported primitive is loiter, type wait 120 in the console. In the last minute, the plane is always at least 25 m from the point. In the last minute, the plane stays within 45 m of the point.
How this is tested verified
Given the reported primitive is loiter
When the plane flies on for 2 minutes
Then the least distance from the point in the last minute is at least 25 m
  And the greatest distance from the point in the last minute is at most 45 m
Follows
A loiter plan circles where the plane is
Tested by
Reaching «Loiter stays round the place where it began» passed

A pursue plan chases another aircraft

If the flight mode of the plane is AGENT and the other aircraft is round the arena, type plan pursue 0 0 0 0 600 2 in the console. The plane chases Merlin, the aircraft with the id 2. The plane replies with COMMAND_ACK, result 0 (ACCEPTED). The console shows ack with result=0. AG_PLAN goes up by 1, to the id of the new plan (plan= in the console). AG_PRIM is 1, pursue (prim=1). The plan is good for 600 s.

If the flight mode of the plane is AGENT and the other aircraft is round the arena, type plan pursue 0 0 0 0 600 2 in the console. The plane chases Merlin, the aircraft with the id 2. The plane replies with COMMAND_ACK, result 0 (ACCEPTED). The console shows ack with result=0. AG_PLAN goes up by 1, to the id of the new plan (plan= in the console). AG_PRIM is 1, pursue (prim=1). The plan is good for 600 s.
How this is tested verified
Given the flight mode of the plane is AGENT
  And the other aircraft is round the arena
When the ground sends a pursue plan
Then the reply to the plan is accepted
  And the reported plan goes up by 1
  And the reported primitive is pursue
  And the time to live of the plan is 600 s
Follows
the section's setup
Leads to
Pursue closes on the target and stays on its tail, A target that goes silent ends the chase
Tested by
Reaching «A pursue plan chases another aircraft» passed, Reaching «Pursue closes on the target and stays on its tail» passed, Reaching «A target that goes silent ends the chase» passed

Pursue closes on the target and stays on its tail

The plane flies to the place where the target will be, and it matches the speed of the target. It stays just outside the separation zone, behind the target. Then the target cannot turn away from it easily.

If the reported primitive is pursue and the other aircraft is round the arena, type wait 120 in the console. In the last minute, the plane stays within 25 m of the other aircraft. The other aircraft never comes within 4 m, across or above and below.

If the reported primitive is pursue and the other aircraft is round the arena, type wait 120 in the console. In the last minute, the plane stays within 25 m of the other aircraft. The other aircraft never comes within 4 m, across or above and below.
How this is tested verified
Given the reported primitive is pursue
  And the other aircraft is round the arena
When the plane flies on for 2 minutes
Then the greatest distance from the other aircraft in the last minute is at most 25 m
  And the closest distance to the other aircraft is above 4 m
Follows
A pursue plan chases another aircraft
Tested by
Reaching «Pursue closes on the target and stays on its tail» passed

An evade plan breaks away from another aircraft

If the flight mode of the plane is AGENT and the other aircraft is after your plane, type plan evade 0 0 0 0 600 2 in the console. The plane breaks away from Merlin, id 2. The plane replies with COMMAND_ACK, result 0 (ACCEPTED). The console shows ack with result=0. AG_PLAN goes up by 1, to the id of the new plan (plan= in the console). AG_PRIM is 2, evade (prim=2). The plan is good for 600 s.

If the flight mode of the plane is AGENT and the other aircraft is after your plane, type plan evade 0 0 0 0 600 2 in the console. The plane breaks away from Merlin, id 2. The plane replies with COMMAND_ACK, result 0 (ACCEPTED). The console shows ack with result=0. AG_PLAN goes up by 1, to the id of the new plan (plan= in the console). AG_PRIM is 2, evade (prim=2). The plan is good for 600 s.
How this is tested verified
Given the flight mode of the plane is AGENT
  And the other aircraft is after your plane
When the ground sends an evade plan
Then the reply to the plan is accepted
  And the reported plan goes up by 1
  And the reported primitive is evade
  And the time to live of the plan is 600 s
Follows
the section's setup
Leads to
Evade opens the distance from a chaser
Tested by
Reaching «An evade plan breaks away from another aircraft» passed, Reaching «Evade opens the distance from a chaser» passed

Evade opens the distance from a chaser

The plane turns away from the other aircraft and flies fast, 20 m above or below it. Near the edge of the arena, it turns back in, so that it does not fly out.

If the reported primitive is evade and the other aircraft is after your plane, type wait 10 in the console. The other aircraft is now at least 35 m away.

If the reported primitive is evade and the other aircraft is after your plane, type wait 10 in the console. The other aircraft is now at least 35 m away.
How this is tested verified
Given the reported primitive is evade
  And the other aircraft is after your plane
When the plane flies on for 10 seconds
Then the distance to the other aircraft is at least 35 m
Follows
An evade plan breaks away from another aircraft
Tested by
Reaching «Evade opens the distance from a chaser» passed

A target that goes silent ends the chase

If the plane does not hear its target for 3 s, it cannot chase it or break away from it. It circles where it is, as for a plan that runs out.

If the reported primitive is pursue, stop the ADSB_VEHICLE messages of the other aircraft: type silent in the console. Then type wait 5 in the console. AG_FALL is 1 (fall=1), and the plane circles where it is.

If the reported primitive is pursue, stop the ADSB_VEHICLE messages of the other aircraft: type silent in the console. Then type wait 5 in the console. AG_FALL is 1 (fall=1), and the plane circles where it is.
How this is tested verified
Given the reported primitive is pursue
When the track of the other aircraft is not heard
  And the plane flies on for 5 seconds
Then the reported fallback is plan expired
Follows
A pursue plan chases another aircraft
Tested by
Reaching «A target that goes silent ends the chase» passed