Difference between revisions of "Helicopter flight and mission"

From BP Wiki
Jump to: navigation, search
(Actuator b-threads)
(LSC Integration)
Line 98: Line 98:
  
  
= LSC Integration =  
+
= LSC Integration =
  
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.
  
The following LSCs (scenarios) were added
+
The following LSC (scenario) was added
  
PaintCanEmpty:  Checks
+
* 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.

Revision as of 09:43, 15 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.

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.