Top Banner
Department of Computing and Information Sciences Kansas State University Design Methodology for State based Embedded Systems Case Study: Robot Controller Phaneendra Vanka Graduate Student (Masters’ Program)
34

Design Methodology for State based Embedded Systems Case Study: Robot Controller

Feb 12, 2016

Download

Documents

tirza

Design Methodology for State based Embedded Systems Case Study: Robot Controller. Phaneendra Vanka Graduate Student (Masters’ Program). Contents. Introduction Demo Design Methodology for Time-Triggered State Machine based systems Case Study: Robot Controller Questions. Introduction. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Design Methodology for

State based Embedded SystemsCase Study: Robot Controller

Phaneendra VankaGraduate Student (Masters’

Program)

Page 2: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Contents

Introduction Demo Design Methodology for Time-

Triggered State Machine based systems

Case Study: Robot Controller Questions

Page 3: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Introduction

Page 4: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Behavior Control

Behavior – tasks that process external/internal sensory information and issues an action.

Reactive robot control architecture. Complex behavior – series of

alternations of simple behaviors. Hierarchical Model.

Page 5: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

LEGO MINDSTORMS Robotics Invention System Kit consists of

motors, touch sensors, light sensors, bricks, gears etc.

RCX Brick - Hitachi H8/3292 series microcontroller.

- 16 MHz of clock speed.- 16Kb ROM.- 32 Kb external RAM.

Page 6: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

leJOS

Java Platform for the RCX Brick. leJOS API

- java.lang, java.util and java.io- classes to control motors,

sensors, buttons, IR communication, navigation etc.

Page 7: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Behavior Control API

Behaviorboolean takeControl( )void action( )void suppress( )

Arbitratorpublic Arbitrator (Behavior[ ] behaviors)

Page 8: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Robot Controller

A modification of the Navigator robot as given in Brian Bagnall’s book “Core Lego Mindstorms Programming”.

Sensors and Inputs: Touch sensor, Timer and two Rotation Sensors.

Actuators: Three motors.

Page 9: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Behavior’s of Robot Controller MOVE (true):

Travel to a random point COMMAND (Input from IR transceiver):

Travel to a predefined point. If there is an obstacle go around that obstacle

BUMP (Input from touch sensor): Travels 20 units in backward direction.

GO HOME (Timer as input): Travel to the starting point

ARM ROTATE (Timer as input): Rotate the arm

.

Page 10: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Robot Controller’s Behavior Model

GO HOME

COMMAND

MOVE

Timer

Command

Motors

S

S

S Point of Suppression

Default

Touch Sensor

BUMP S

Timer ARM ROTATE

Page 11: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

DEMO

Page 12: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Design Methodology for Time-Triggered State Machine based

systems

Page 13: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Rational Unified Process

Actors

Use-Cases

Class Diagrams

Use-Case realizations

Implementation

Use-Case Model

(what)

Analysis/Design

(how)

Actual code

Page 14: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Use-Case realizations

WAIT WAKEUP

Page 15: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Use-Case realizations with asynchronous waits Allocating a thread for each scenario

with synchronization code Finite State Machine based

implementation

Page 16: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Allocating a thread for each scenario

Actors

Use-Cases

Class Diagrams

Use-Case realizations

Component code

Identify regions in which synchronization is required

Complete code

Global invariant

s(patterns

)

Coarse-grained solution

Fine-grained

code

A Structured Approach to Develop Concurrent Programs in UML,Masaaki Mizuno, Gurdip Singh, Mitchell Nielsen

Page 17: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Finite State Machine based implementation

Actors

Use-cases

Class Diagrams

Use-case realizations

Revised Class Diagram

Scenarios for threads

Implementation

Original Class

Diagram + State

information + Active ClassesTime

Triggered

Page 18: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Event Triggered Systems

Boundary Class Other Classes

Page 19: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Time Triggered Systems

Boundary Class Active Class Other Classes

Page 20: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

From the above discussion we have the following combinations Time Triggered State Machine

based implementation

Event Triggered Thread for each scenario

Page 21: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Case Study : Robot Controller

Page 22: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Use Cases for Robot Controller MOVE (true):

Pick up a random point (x,y) to reach. Calculate the angle and distance to (x,y). Rotate for the angle and travel the distance in straight line.

COMMAND (Input from IR transceiver): Calculate the angle and distance to (MAXX, MAXY). Rotate for the angle and travel the distance in straight line.

BUMP (Input from touch sensor): Travel 20 units in backward direction.

GO HOME (Timer as input): Calculate the angle and distance for initial point (0,0). Rotate for the angle and travel the distance in straight line.

ARM ROTATE (Timer as input): Rotate the arm in forward direction for 2 seconds Rotate the arm in backward direction for 2 seconds

STEER (Inputs from Rotation Sensors): Uses rotation sensor to find angle rotated and distance traveled. Keeps the travel in straight line.

Page 23: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Use Case Model for Robot Controller

Tippy SeniorMove Behavior

Bump Behavior

GoHome Behavior

default

bump

Left Rotational Sensor

Steer

Left Motor

Right Motor

1..1

1..1 1..1 1..11..1

1..11..1

1..1

1..1

1..1

1..1

1..1

1..1

1..1

1..1

1..1

1..1

1..1

Right Rotational Sensor

1..1

1..11..1

1..1

1..1

1..11..11..1

1..1

1..1

1..1

1..1

1..1

1..1

1..1

1..1

1..1

1..1

1..1

1..1

Command Behavior

Command

1..1

1..1 1..1

1..1

1..1

1..1

Arm Rotate

Arm Motor

1..11..1

Arm timer

GoHome timer

1..1

1..1

Page 24: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Class Diagram +getX() : int+getY() : int+getAngle() : double+rotate()+gotoPoint()+travel()+forward()+backward()+updateCoordinate()+updateAngle()+halt()+stop()+setCommand()+checkRotate()+checkForward()+checkBackward()

RotationNavigator

Motor

Touch Sensor1

3

1

1

Navigator

Move Command Bump GoHome ArmRotate

1

1

1

1

1

1

1

1

1

1

+takecontrol() : bool+action()+suppress()

«interface»Behavior

Timer

1

11

1

RotationSensor

2

1

IRTransceiver

11

Page 25: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Use Case Realization Example

Wait Until MOVE is triggeredPick a new point (x, y)Calculate angle and distanceStart the motorsWait Until required angle is rotated Stop motorsUpdate geometryStart the motorsWait Until required distance is traveledStop motorsUpdate geometry

Robot Controller : MOVE Behavior

Page 26: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Use Case Realization Example

Wait Until MOVE is triggeredPick a new point (x, y)Calculate angle and distanceStart the motorsWait Until required angle is rotated Stop motorsUpdate geometryStart the motorsWait Until required distance is traveledStop motorsUpdate geometry

Robot Controller : MOVE Behavior Asynchronous waits

Page 27: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

actions

Behavior Action

Each behavior is a set of actions. After completing one action it goes to the next action

of the behavior. Describe the entire system using finite state machine. Allocate threads to traverse through the state

machine. Needs only mutual exclusion of shared variables.

Finite State Machine Method

Page 28: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Use Case Realization Example

Wait Until MOVE is triggeredPick a new point (x, y)Calculate angle and distanceStart the motorsWait Until required angle is rotated Stop motorsUpdate geometryStart the motorsWait Until required distance is traveledStop motorsUpdate geometry

Tippy Senior : MOVE Behavior

States

Page 29: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Revised Class Diagram

+getNextState() : byte+getActionToBeTaken() : Action+setNextState()+setActionToBeTaken()

StateTable

+getX() : int+getY() : int+getAngle() : double+rotate()+gotoPoint()+travel()+forward()+backward()+updateCoordinate()+updateAngle()+halt()+stop()+setCommand()+checkRotate()+checkForward()+checkBackward()

RotationNavigator

1

1

Motor

Touch Sensor1

3

1

1

Navigator

Move Command Bump GoHome ArmRotate

1

1

1

1

1

1

1

1

1

1

+takecontrol() : bool+action()+suppress()

«interface»Behavior

Arbitrator

Timer

1

11

1

+getCurrentState() : byte+setCurrentState()+nextState()

Rotation Sensor ThreadCurrentState

ArmState

111

1

1

1

1

1

11

RotationSensor

21

11

IRTransceiver

11

1

*

Page 30: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Use Case Realization Example

Wait Until MOVE is triggeredPick a new point (x, y)Calculate angle and distanceStart the motorsWait until required angle is rotated Stop motorsUpdate geometryStart the motorsWait Until required distance is traveled Stop motorsUpdate geometry

Tippy Senior : MOVE Behavior

Arbitrator

Rotation Sensor Thread

Page 31: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

takeControlGO HOME

takeControlBUMP

takeControlCOMMAND

Action (COMMAND)

Action (GO HOME)

Action (BUMP)

DONE

Arbitrator thread

takeControlMOVE

Action (MOVE)

Page 32: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

takeControlGO HOME

takeControlBUMP

takeControlCOMMAND

Action (COMMAND)

Action (GO HOME)

Action (BUMP)

DONE

Rotation Sensor Thread

takeControlMOVE

Action (MOVE)

Page 33: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Acknowledgement Dr. Masaaki Mizuno Dr. Gurdip Singh Dr. Mitchell Nielsen

Page 34: Design Methodology  for  State based Embedded Systems Case Study: Robot Controller

Department of Computing and Information SciencesKansas State University

Questions ???