SIM001 › Beyond the cockpit › Flying by plan
Tag by plan
In a game of tag, the scripted ground control agent flies the three computer pilots by plan. It does what the computer pilots do in the simulator, but with plans. Each plane gets a new plan once a second. Each plan is good for 2.5 s.
The plane that is it gets a pursue plan. The other planes get a band plan each, with a height band of their own: Kestrel from 20 m to 30 m, Merlin from 35 m to 45 m and Swift from 50 m to 58 m. The bands start 15 m apart, so that the planes do not meet by chance. When the chaser comes near, a plane gets an evade plan. A plane that flies out of the arena gets a go to plan back to the middle.
The runner plays the game with three ArduPlane SITL planes. Start it with SIM001_BIN=.ardupilot-agent/build/sitl/bin cargo run --release -p cognition_runner -- --agent --speedup 10. The planes take off in QHOVER and change to FBWA at 15 m. Then the ground switches them to AGENT mode and flies the game. Every 2 s, the runner prints the plan of each plane, in a line such as Kestrel sys 1 AGENT plan Pursue->2 #12 30m. At ten times real time, the game takes about 25 s.
The plane that is it pursues the plane it can catch soonest
The ground control agent estimates the time to catch each plane: the distance, divided by the speed that the chaser has more than the target. If the target is behind the chaser, it adds 3 s. Thus a slow plane ahead is a better target than a near plane behind. The chaser keeps its target until another target is clearly quicker to catch.
If the chaser Kestrel is behind Merlin and ahead of Swift, wait for the next decision of the ground control agent. Kestrel gets a pursue plan with Merlin, id 2, as its target.
How this is tested verified
Given the chaser Kestrel is behind Merlin and ahead of Swift When the ground control agent decides Then the plane that Kestrel pursues is Merlin
A plane that is not it holds its own height band
If the chaser Kestrel is far from the others, wait for the next decision of the ground control agent. Merlin gets a band plan. The plan of Merlin gives the band from 35 m to 45 m above home. Swift gets a band plan. The plan of Swift gives the band from 50 m to 58 m above home.
How this is tested verified
Given the chaser Kestrel is far from the others When the ground control agent decides Then the plan of Merlin is band And the band of Merlin is 35 to 45 m And the plan of Swift is band And the band of Swift is 50 to 58 m
A plane that is not it breaks away from a chaser that comes near
How far a plane sees the chaser depends on its pilot: Kestrel sees it at 80 m, Merlin at 60 m and Swift at 40 m. The evade plan gives the band of the plane, but the executor flies 20 m above or below the chaser. Thus an evade can take a plane out of its band.
If the chaser Kestrel is near Merlin, wait for the next decision of the ground control agent. Merlin gets an evade plan. The plan of Merlin gives the band from 35 m to 45 m above home. Swift gets a band plan.
How this is tested verified
Given the chaser Kestrel is near Merlin When the ground control agent decides Then the plan of Merlin is evade And the band of Merlin is 35 to 45 m And the plan of Swift is band
A plane that is not it never pursues
Scroll up to the report just above console ready. The report of the runner says RESULT pursue_not_it=0. Only the plane that is it got pursue plans.
See it in Watching a game of tag by plan.
How this is tested verified
When the planes play a game of tag Then the pursue plans for the planes not it are 0
Every plane plays in AGENT mode and accepts every command
Scroll up to the report just above console ready. The report of the runner says RESULT in_agent=3. All three planes played in AGENT mode. The report of the runner says RESULT refused=0. The planes accepted every plan, every game command and every mode change.
See it in Watching a game of tag by plan.
How this is tested verified
When the planes play a game of tag Then the planes in AGENT mode are 3 And the refused commands are 0
Each new plane that is it is reported
The game changes who is it when the chaser tags a plane, or when a plane leaves the arena. The runner reports each change, and it says which of the two it was.
Scroll up to the report just above console ready. For each new plane that is it, the runner printed a line. The line says who tagged whom, or who left the arena.
See it in Watching a game of tag by plan.
How this is tested verified
When the planes play a game of tag Then the reports of the hand-overs are complete