Difference between revisions of "Helicopter flight and mission"
(→Helicopter Flight Example) |
(→General control b-threads) |
||
Line 45: | Line 45: | ||
== BPJ b-threads == | == BPJ b-threads == | ||
− | === General control b-threads === | + | === General control b-threads === |
− | DoColD2U: Controls coloring in the up direction; | + | DoColD2U: Controls coloring in the up direction; |
YAxis: Reports when helicopter reaches top or bottom end of wall (ceiling of floor) | YAxis: Reports when helicopter reaches top or bottom end of wall (ceiling of floor) | ||
− | EndColUp: Handle reaching of ceiling. Stop moving vertically, start moving right. | + | EndColUp: Handle reaching of ceiling. Stop moving vertically, start moving right. |
− | DoRowL2R: Left to right painting - waits for DoRowRight and then repeatedly requests movement to the right until end of right movement is reached. | + | DoRowL2R: Left to right painting - waits for DoRowRight and then repeatedly requests movement to the right until end of right movement is reached. |
− | XAxis: Monitor horizontal coordinates. Report reaching of right and left borders of wall, and report end of movement right to start a new column | + | XAxis: Monitor horizontal coordinates. Report reaching of right and left borders of wall, and report end of movement right to start a new column |
DoColU2D: Controls coloring in the up direction | DoColU2D: Controls coloring in the up direction | ||
EndColDown: Handles reaching the floor - requests a movement to the right | EndColDown: Handles reaching the floor - requests a movement to the right | ||
− | BrushMove: Move the brush right and left (horizontal moves) to create a thicker line and paint continuous area. This b-thread performs its actions between any two vertical moves. | + | BrushMove: Move the brush right and left (horizontal moves) to create a thicker line and paint continuous area. This b-thread performs its actions between any two vertical moves. |
− | === Actuator b-threads | + | === Actuator b-threads === |
− | MovingRight, MovingLeft, MovingDown, MovingUp: These b-threads wait for the corresponding move event and call the helicopter API (or the simulator) to cause the actual movement. | + | MovingRight, MovingLeft, MovingDown, MovingUp: These b-threads wait for the corresponding move event and call the helicopter API (or the simulator) to cause the actual movement. |
− | === Color control b-threads | + | === Color control b-threads === |
− | ChangePaintingColor: Waits for the need to change color and changes the color randomly. | + | ChangePaintingColor: Waits for the need to change color and changes the color randomly. |
− | + | ||
− | + | ||
− | + | ||
+ | === Location correction b-threads === | ||
+ | FixWind: When a report comes in that the helicopter is not where it is supposed to be - stop painting movement and return to last known location. | ||
=== Environment Simulation === | === Environment Simulation === |
Revision as of 09:21, 15 April 2014
Contents
Helicopter Flight Example
This example demonstrates the control of a toy helicopter. The mission here is to paint a wall with different colors. This can be considered as an analogy to a photography mission where a particular area as to be covered.
Requirements
The requirements below were added incrementally, and b-threads were added to deal with each requirement. In the simulator - the painting of the wall is by drawing a line on the screen.
- The helicopter should go up and down along the wall.
- When the helicopter reaches the ceiling or the floor it should move to the right
- Every fixed number of pixels the paint color should be changed
- Since the line drawn by the helicopter is thin, after every small vertical move, the helicopter should move right and left with horizontal brush strokes, before moving vertically again.
- The helicopter may move from its present location due to wind.
- If the helicopter is moved by wind, it should return to its last known location.
In the integration with LSC, two more requirements were added
- The amount of paint is limited. After a certain number of points is painted - the paint runs out.
- When paint of a certain color runs out, this color can no longer be used.
- When all paint colors run out, the helicopter must stop.
- Paint cans may be re-filled. This is simulated by a user clicking on a button on the screen.
Events
General control events
BeginPainting: Start the painting process StopPainting: End the painting process MoveDown: Move down a fixed number of pixels. EndOfColUp: End painting wall going up DoColDownL Start painting wall going down EndOfColDown: End painting wall going up DoRowRight: Start painting wall going right EndOfRowRight: Stop moving right. ChangeColor: The time has come to change color UpdateArrived: simulate information from a GPS with actual helicopter location
Move Events
The following events indicate the desire to move a fixed number of pixels in the desired direction. These events have a data field - indicating whether the movement is for a mission or for maintenance, which serves in correcting wind shifts.
MoveUp: Move down a fixed number of pixels MoveLeft: Move left a fixed number of pixels MoveRight: Move right a fixed number of pixels DoColUp: Start painting wall going up
BPJ b-threads
General control b-threads
DoColD2U: Controls coloring in the up direction; YAxis: Reports when helicopter reaches top or bottom end of wall (ceiling of floor) EndColUp: Handle reaching of ceiling. Stop moving vertically, start moving right. DoRowL2R: Left to right painting - waits for DoRowRight and then repeatedly requests movement to the right until end of right movement is reached. XAxis: Monitor horizontal coordinates. Report reaching of right and left borders of wall, and report end of movement right to start a new column DoColU2D: Controls coloring in the up direction EndColDown: Handles reaching the floor - requests a movement to the right BrushMove: Move the brush right and left (horizontal moves) to create a thicker line and paint continuous area. This b-thread performs its actions between any two vertical moves.
Actuator b-threads
MovingRight, MovingLeft, MovingDown, MovingUp: These b-threads wait for the corresponding move event and call the helicopter API (or the simulator) to cause the actual movement.
Color control b-threads
ChangePaintingColor: Waits for the need to change color and changes the color randomly.
Location correction b-threads
FixWind: When a report comes in that the helicopter is not where it is supposed to be - stop painting movement and return to last known location.
Environment Simulation
ColorControl: Counts movements and announces the need to change color. Wind: Every certain random number of steps, report a random location of the helicopter