Difference between revisions of "Helicopter flight and mission"

From BP Wiki
Jump to: navigation, search
(LSC Integration)
Line 101: Line 101:
  
 
The BPJ-based system was then integrated with the LSC language via PlayGo.
 
The BPJ-based system was then integrated with the LSC language via PlayGo.
For details how  to integrate a BPJ application with LSC see a separate section in this documentation.  
+
For details how  to integrate a BPJ application with LSC see a separate section in this documentation.
  
 
The following LSC (scenario) was added
 
The following LSC (scenario) was added
Line 124: Line 124:
 
** External events should not be blocked (enforced by convention only).
 
** External events should not be blocked (enforced by convention only).
 
** When external events are produced by simulator, the concepts of Logical Execution Time should be enforced by convention, where all internal events reacting to the last external event should be processed before generating the next external event.
 
** When external events are produced by simulator, the concepts of Logical Execution Time should be enforced by convention, where all internal events reacting to the last external event should be processed before generating the next external event.
 +
 +
= Download =
 +
# Click [[Media:Helicopter.zip | here]] to download the helicopter example.
 +
# Installation Instructions:
 +
##Import the downloaded project to your workspace:
 +
###From the 'File' menu choose 'Import'-->'General'-->'Existing Projects into Workspace'.
 +
###Click the 'Next' button.
 +
###Click the 'Select archive file' option and then click the 'Browse...' button to select the downloaded zip file.
 +
###Click 'Finish'.
 +
##The helicopter example projects are now part of your workspace.
 +
### The example includes three projects:
 +
#### BDrone - The main project that includes the b-threads that implement the drawing/scanning tasks.
 +
#### HeliSim - A simple java-based simulator.
 +
#### il.ac.wis.cs.rovtool.blender - A blender-based simulator.
 +
##Refer to the BDrone/HowToRun.txt file for execution instructions.

Revision as of 11:16, 17 April 2014

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: This is an event class of which there are four events, indicating a request to change the painting color to the corresponding one in the event name:
    • eChangeColorBLACK
    • eChangeColorRED
    • eChangeColorBLUE
    • eChangeColorGreen
  • 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
  • MoveDown: Move down a fixed number of pixels
  • MoveLeft: Move left a fixed number of pixels
  • MoveRight: Move right a fixed number of pixels

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

The following 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

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

Incremental Development Notes

With only basic movements and no color change b-threads

Black - thin.jpg


Basic movements with color changes

Color-thin.jpg

Adding horizontal brush movements

Color-thick.jpg

Random movements due to wind, and return by horizontal movement and then vertical to last known location

FixWind.jpg


LSC Integration

The BPJ-based system was then integrated with the LSC language via PlayGo. For details how to integrate a BPJ application with LSC see a separate section in this documentation.

The following LSC (scenario) was added

  • PaintCanEmpty: Waits for a certain number of movements with a given color and block subsequent changes to that color, simulating and empty can, until an event of PaintFilled arrives. This event is generated by the user clicking on a corresponding GUI Button.

Design Notes

The following design patterns and choices can be seen throughout the example.

  • Events can be distinguishes from each other by
    • Class - different classes of events
    • Name - multiple instances of an events of the same class distinguished by their name (e.g. the color change events).
    • Data field - Two instances of events of the same class, with arbitrary names can be distinguished by a value in one of the event data fields (e.g. the maintenance vs. mission indicator in the move events).
  • One activity can interfere with another by using
    • priority - (relative priority among b-thread)
    • blocking the events of the other activity (which can be distinguished as described above)
  • Distinguishing internal and external events - those generated by the system/application and those generated by the environment (and which may be reported by sensors).
    • External events should not be blocked (enforced by convention only).
    • When external events are produced by simulator, the concepts of Logical Execution Time should be enforced by convention, where all internal events reacting to the last external event should be processed before generating the next external event.

Download

  1. Click here to download the helicopter example.
  2. Installation Instructions:
    1. Import the downloaded project to your workspace:
      1. From the 'File' menu choose 'Import'-->'General'-->'Existing Projects into Workspace'.
      2. Click the 'Next' button.
      3. Click the 'Select archive file' option and then click the 'Browse...' button to select the downloaded zip file.
      4. Click 'Finish'.
    2. The helicopter example projects are now part of your workspace.
      1. The example includes three projects:
        1. BDrone - The main project that includes the b-threads that implement the drawing/scanning tasks.
        2. HeliSim - A simple java-based simulator.
        3. il.ac.wis.cs.rovtool.blender - A blender-based simulator.
    3. Refer to the BDrone/HowToRun.txt file for execution instructions.