roscoq: robots powered by constructive realsaa755/roscoq/itp.pdfroscoq: robots powered by...

72
ROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper ) ITP, 27-Aug-2015, Nanjing

Upload: others

Post on 20-Jun-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

ROSCoq: Robots powered by Constructive Reals

Abhishek Anand(joint work with Ross Knepper )

ITP, 27-Aug-2015, Nanjing

Page 2: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

ROSCoq: Robots powered by Constructive Reals

Abhishek Anand(joint work with Ross Knepper ⇑ 1)

ITP, 27-Aug-2015, Nanjing

This is joint work with Ross Knepper,who works on designing roboticsystems where multiple robotscollaborate on various tasks.

1The symbol ⇑ occurs at many places in this PDF. On a modern PDF reader (withsupport for OCG) such as Adobe Reader, Evince (Linux), Foxit Reader (Windows),PDF XChange viewer clicking such a symbol will open/close a popup containing extraexplanation, e.g. what I said while describing that slide)

Page 3: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Motivation

Collaborating Robots2 ⇑Keyboard finding robot3 ⇑

Here is a video from his work.Two robots are collaborating

to move furniture. It is hard toget such robotic programs right.

In previous work, I found it hard toget robotic programs for even single

robots right. The ROSCoq frameworkis an attempt to solve this problem

2Mehmet Dogar, Ross A. Knepper, Andrew Spielberg, Changhyun Choi,Henrik I. Christensen, and Daniela Rus. “Towards Coordinated Precision Assemblywith Robot Teams”. In: ISER. 2014.

3Abhishek Anand, Hema Swetha Koppula, Thorsten Joachims, andAshutosh Saxena. “Contextually guided semantic labeling and search forthree-dimensional point clouds”. In: IJRR (2012).

Page 4: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Goals

I Write robotic programs in CoqI “Run” them on actual robots using a shim:I Specify the behavior of the shim, physics, and hardware in a realistic

wayI develop Coq proofs of properties about the overall behavior

Page 5: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Goals

I Write robotic programs in CoqI “Run” them on actual robots using a shim:I Specify the behavior of the shim, physics, and hardware in a realistic

wayI develop Coq proofs of properties about the overall behavior

Page 6: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Goals

I Write robotic programs in CoqI “Run” them on actual robots using a shim:

I Specify the behavior of the shim, physics, and hardware in a realisticway

I develop Coq proofs of properties about the overall behavior

Page 7: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Goals

I Write robotic programs in CoqI “Run” them on actual robots using a shim:I Specify the behavior of the shim, physics, and hardware in a realistic

wayI develop Coq proofs of properties about the overall behavior

Page 8: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Logic of Events framework

I Cyber Physical systems are distributed systemsI where agents have fancy sensing and/or actuation actuation

capabilities.

Page 9: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Logic of Events framework

λ s m. . . . λ s m. . . . λ s m. . . .

Nicolas Schiper, Vincent Rahli, Robbert Van Renesse, Marck Bickford,and Robert L. Constable. “Developing correctly replicated databasesusing formal tools”. In: DSN. IEEE, 2014, pp. 395–406 ⇑

My colleagues at the Nuprl group havespent several years in developing

certified distributed systems(DSs). Because CPSs are special

kind of DSs (prev. slide), theirwork was a nice starting pointfor me. A DS is a collection of

agents, each running a Nuprl FP

Page 10: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Logic of Events framework

these are functional reactive programswhich take the current state, theinput message and produce the

new state and the list of messagethat have to be sent in response.

λ s m. . . . λ s m. . . . λ s m. . . .

Page 11: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Logic of Events framework

Events capture the externallyobservable behaviour of agents.

Typically they denote . . .

λ s m. . . . λ s m. . . . λ s m. . . .

Page 12: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Logic of Events framework

⇑. . . receiving of messages

λ s m. . . . λ s m. . . . λ s m. . . .

Page 13: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Logic of Events framework

⇑. . . or sending of messages

λ s m. . . . λ s m. . . . λ s m. . . .

Page 14: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Logic of Events framework

An important notion is the causalordering between events. There isan edge between a send and the

corresponding receive event. Causalordering is well founded. One canprove properties about the system

by induction on this causal ordering

λ s m. . . . λ s m. . . . λ s m. . . .

Page 15: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

ROS : Even single robots are distributed systemsI Based on asynchronous message passing4

I Very popular, drivers (as DS agents) available for many robots 5

I uniform APII Running Example

4Morgan Quigley, Ken Conley, Brian Gerkey, Josh Faust, Tully Foote,Jeremy Leibs, Rob Wheeler, and Andrew Y. Ng. “ROS: an open-source RobotOperating System”. In: ICRA workshop on open source software. Vol. 3. 2009, p. 5.

5http://wiki.ros.org/Robots

Page 16: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

ROS : Even single robots are distributed systemsI Based on asynchronous message passing4

I Very popular, drivers (as DS agents) available for many robots 5

I uniform API ⇑

The API for controlling for a quadrotorand a roomba look exactly the same.One provides 2 3D vectors, specifying

respectively the translational androtational velocities along each axes

I Running Example4Morgan Quigley, Ken Conley, Brian Gerkey, Josh Faust, Tully Foote,

Jeremy Leibs, Rob Wheeler, and Andrew Y. Ng. “ROS: an open-source RobotOperating System”. In: ICRA workshop on open source software. Vol. 3. 2009, p. 5.

5http://wiki.ros.org/Robots

Page 17: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

ROS : Even single robots are distributed systems

I Based on asynchronous message passing4

I Very popular, drivers (as DS agents) available for many robots 5

I uniform APII Running Example

4Morgan Quigley, Ken Conley, Brian Gerkey, Josh Faust, Tully Foote,Jeremy Leibs, Rob Wheeler, and Andrew Y. Ng. “ROS: an open-source RobotOperating System”. In: ICRA workshop on open source software. Vol. 3. 2009, p. 5.

5http://wiki.ros.org/Robots

Page 18: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Running Example⇑

The hardware agent represents the robot and its ROS driverrunning inside the laptop, communicating to the robot via

USB. This driver listens on a topic for messages of a specialkind. Essentially, those messages specify 2 scalars : linear andangular velocity. When the driver receives such a message, it

adjusts the motors on the robot to achieve the requested velocity

represents the Coq program, being run bya shim. We will describe it in detail later

represents the Java program which receivesuser input in a GUI and sends ROS messages

Page 19: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

How to Specify a CPS in ROSCoq

I Define the physical model as a Coq typeI Define the collection of agentsI Specify the behavior of each agent

I S/w agent : Coq programI H/w agent : . . .

Page 20: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Physical Model of a CPS

Describes how the relevant physical quantities evolve over time

Page 21: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Physical Model of a CPS

Describes how the relevant physical quantities evolve over time

Record Cart2D (T : Type) : Type := {X : T ; Y: T}.Record iCreate : Type := {

position : Cart2D (Time →C R);theta : (Time →C R);

Page 22: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Physical Model of a CPS

Describes how the relevant physical quantities evolve over time

Record iCreate : Type := {position : Cart2D (Time →C R);theta : (Time →C R);linVel : (Time →C R);omega : (Time →C R);derivRot : isDerivativeOf omega theta;derivX : isDerivativeOf (linVel ∗ ( FCos theta)) (X position);derivY : isDerivativeOf (linVel ∗ ( FSin theta)) (Y position);

Page 23: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Physical Model of a CPS

Record iCreate : Type := {position : Cart2D (Time →C R);theta : (Time →C R);linVel : (Time →C R);omega : (Time →C R);derivRot : isDerivativeOf omega theta;derivX : isDerivativeOf (linVel ∗ ( FCos theta)) (X position);derivY : isDerivativeOf (linVel ∗ ( FSin theta)) (Y position);

In case there were 2 robots, we would use iCreate × iCreate

Page 24: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Semantics of Agents

After the physical model is specified,one specifies the collection ofagents and their behaviour ina mutually independent way

Page 25: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Semantics of Agents

Previously, each agent was runninga functional reactive program. This

indirectly specifies a predicate onthe sequence of events at an agent,namely one that can be generated

by the program. However, tospecify the behaviours of hardwareagents, e.g. sensors or actuators,one also needs to talk about how

the physical quantities change

Page 26: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Semantics of Agents

So, we generalize the semantic spacefor specifying agents. They are now

a relation between how physicalquantities evolved over time and

the sequence of events at the agent

Page 27: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Semantics of Agents

I PhysModelType → (N → option Event) → Prop

Page 29: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Semantics of Agents

I Can handle non-determinstic devices ⇑

The manuals of robotic hardware oftenonly incompletely specify the behaviour.

I Uniform treatment of both sensing and actuation devices ⇑For sensing devices, typically thephysical quantities influence the

(send) events. For actuation devicestypically the received messages influence

the evolution of physical quantities

Page 30: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Specification of an iCreate (hardware agent)

Definition HwAgent (ic: iCreate) (evs : nat → option Event): Prop :=

Page 31: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Specification of an iCreate (hardware agent)

Definition HwAgent (ic: iCreate) (evs : nat → option Event): Prop :=onlyRecvEvts evs ∧ ∀ t: QTime,

let (lastCmd , tm ) := latestVelPayloadAndTime evs t inlet a : Q := rad (lastCmd) inlet b : Q := θ (lastCmd) in ∃ tr : QTime, (tm ≤ tr ≤ tm + reacTime)∧ (∀ t’ : QTime, (tm ≤ t’ ≤ tr )→ ( Min ({linVel ic} tm) (a - εv a b)≤ {linVel ic} t’ ≤ Max ({linVel ic} tm) (a+ εv a b)))

∧ (∀ t’ : QTime, (tr ≤ t’ ≤ t) → |{linVel ic} t’ - a | ≤ εv a b )

Time

linVel ic

tm tr

a εv a b

Page 32: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Specification of an iCreate (hardware agent)

Definition HwAgent⇑

While its definition is complicated, itcan be best understood as a figure.Also, check that the type is right,as described in the previous slide.

(ic: iCreate) (evs : nat → option Event): Prop :=

Time

linVel ic

tm tr

a εv a b

{|v := a; w := b|} ⇑

this message requesting a linearvelocity of a and angular velocity ofb was received at time tm. By tr ,the transition to the new velocity

is complete. After time tr , thelinear velocity remains close (asspecified by the parameter εv )to a. The angular velocity alsochanges in a similar way to b

Page 33: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Software Agents

S → Message → (S × list Message). ⇑

Software agents can be specifiedindirectly by providing a program

of this type. S is the type of statemaintained by the program. These

programs take the current state,the input message and produce the

next state and a list of messagesthat have to be sent in response

Page 36: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Software Agentsp: S → Message → (S × list Message).SwSemantics : (S → Message → (S × list Message)) →(PhysModelType → (N → option Event) → Prop)

Given a program (p), SwSemanticsspecifies its behaviour. This is best

described as a picture. Messages have adelay field which can be used to send amessage at a specified amount of time.

Page 39: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Program in our running example

Definition robotPureProgam (target : Cart2D Q) : list (Q ×⇑

Each pair in this list represents a messagethat the software agent sends to the

hardware agent in our running example.The first component of each pair is thedelay field of the message. The secondcomponent is a polar pair specifying the

linear and angular velocity which thehardware agent should achieve on receipt.

Polar2D Q) :=let polarTarget : Polar2D R := Cart2Polar target inlet rotDuration : R := | θ polarTarget | / rotspeed inlet translDuration : R := (rad polarTarget) / speed in[

{ X := 1 ; Y := 1 ; }{ rad :=

√2 ; θ :=

π

4 ; }π

4√2

(0,{| rad:= 0 ; θ := ( polarθSign target ) * rotspeed |}); ( tapprox rotDuration delRes delEps , {| rad := 0 ; θ := 0 |}); (delay , {| rad := speed ; θ := 0 |}); ( tapprox translDuration res ε , {| rad := 0 ; θ := 0 |}) ].

Page 40: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Program in our running example

Definition robotPureProgam (target : Cart2D Q) : list (Q × Polar2D Q) :=let polarTarget : Polar2D R := Cart2Polar target inlet rotDuration : R := | θ polarTarget | / rotspeed inlet translDuration : R := (rad polarTarget) / speed in[

{ X := 1 ; Y := 1 ; }{ rad :=

√2 ; θ :=

π

4 ; }π

4√2

(0,{| rad:= 0 ; θ := ( polarθSign target ) * rotspeed |}); ( tapprox rotDuration delRes delEps , {| rad := 0 ; θ := 0 |}); (delay , {| rad := speed ; θ := 0 |}); ( tapprox translDuration res ε , {| rad := 0 ; θ := 0 |}) ].

Page 41: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Program in our running example

Definition robotPureProgam (target : Cart2D Q) : list (Q × Polar2D Q) :=let polarTarget : Polar2D R := Cart2Polar target inlet rotDuration : R := | θ polarTarget | / rotspeed inlet translDuration : R := (rad polarTarget) / speed in[

{ X := 1 ; Y := 1 ; }{ rad :=

√2 ; θ :=

π

4 ; }π

4√2

(0,{| rad:= 0 ; θ := ( polarθSign target ) * rotspeed |}); ( tapprox rotDuration delRes delEps , {| rad := 0 ; θ := 0 |}); (delay , {| rad := speed ; θ := 0 |}); ( tapprox translDuration res ε , {| rad := 0 ; θ := 0 |}) ].

Page 42: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Program in our running example

Definition robotPureProgam (target : Cart2D Q) : list (Q × Polar2D Q) :=let polarTarget : Polar2D R := Cart2Polar target inlet rotDuration : R := | θ polarTarget | / rotspeed inlet translDuration : R := (rad polarTarget) / speed in[

{ X := 1 ; Y := 1 ; }{ rad :=

√2 ; θ :=

π

4 ; }π

4√2

(0,{| rad:= 0 ; θ := ( polarθSign target ) * rotspeed |}); ( tapprox rotDuration delRes delEps , {| rad := 0 ; θ := 0 |}); (delay , {| rad := speed ; θ := 0 |}); ( tapprox translDuration res ε , {| rad := 0 ; θ := 0 |}) ].

Page 43: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Program in our running example

Definition robotPureProgam (target : Cart2D Q) : list (Q × Polar2D Q) :=let polarTarget : Polar2D R := Cart2Polar target inlet rotDuration : R := | θ polarTarget | / rotspeed inlet translDuration : R := (rad polarTarget) / speed in[

{ X := 1 ; Y := 1 ; }{ rad :=

√2 ; θ :=

π

4 ; }π

4√2

(0,{| rad:= 0 ; θ := ( polarθSign target ) * rotspeed |}); ( tapprox rotDuration delRes delEps , {| rad := 0 ; θ := 0 |}); (delay , {| rad := speed ; θ := 0 |}); ( tapprox translDuration res ε , {| rad := 0 ; θ := 0 |}) ].

Page 44: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Program in our running example

Definition robotPureProgam (target : Cart2D Q) : list (Q × Polar2D Q) :=let polarTarget : Polar2D R := Cart2Polar target inlet rotDuration : R := | θ polarTarget | / rotspeed inlet translDuration : R := (rad polarTarget) / speed in[

{ X := 1 ; Y := 1 ; }{ rad :=

√2 ; θ :=

π

4 ; }π

4√2

(0,{| rad:= 0 ; θ := ( polarθSign target ) * rotspeed |}); ( tapprox rotDuration delRes delEps , {| rad := 0 ; θ := 0 |}); (delay , {| rad := speed ; θ := 0 |}); ( tapprox translDuration res ε , {| rad := 0 ; θ := 0 |}) ].

Page 45: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Program in our running example

Definition robotPureProgam (target : Cart2D Q) : list (Q × Polar2D Q) :=let polarTarget : Polar2D R := Cart2Polar target inlet rotDuration : R := | θ polarTarget | / rotspeed inlet translDuration : R := (rad polarTarget) / speed in[

{ X := 1 ; Y := 1 ; }{ rad :=

√2 ; θ :=

π

4 ; }π

4√2

(0,{| rad:= 0 ; θ := ( polarθSign target ) * rotspeed |}); ( tapprox rotDuration delRes delEps , {| rad := 0 ; θ := 0 |}); (delay , {| rad := speed ; θ := 0 |}); ( tapprox translDuration res ε , {| rad := 0 ; θ := 0 |}) ].

Page 46: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Program in our running example

Definition robotPureProgam (target : Cart2D Q) : list (Q × Polar2D Q) :=let polarTarget : Polar2D R := Cart2Polar target inlet rotDuration : R := | θ polarTarget | / rotspeed inlet translDuration : R := (rad polarTarget) / speed in[

{ X := 1 ; Y := 1 ; }{ rad :=

√2 ; θ :=

π

4 ; }π

4√2

(0,{| rad:= 0 ; θ := ( polarθSign target ) * rotspeed |}); ( tapprox rotDuration delRes delEps , {| rad := 0 ; θ := 0 |}); (delay , {| rad := speed ; θ := 0 |}); ( tapprox translDuration res ε , {| rad := 0 ; θ := 0 |}) ].

Page 47: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Program in our running example

Definition robotPureProgam (target : Cart2D Q) : list (Q × Polar2D Q) :=let polarTarget : Polar2D R := Cart2Polar target inlet rotDuration : R := | θ polarTarget | / rotspeed inlet translDuration : R := (rad polarTarget) / speed in[

{ X := 1 ; Y := 1 ; }{ rad :=

√2 ; θ :=

π

4 ; }π

4√2

(0,{| rad:= 0 ; θ := ( polarθSign target ) * rotspeed |}); ( tapprox rotDuration delRes delEps , {| rad := 0 ; θ := 0 |}); (delay , {| rad := speed ; θ := 0 |}); ( tapprox translDuration res ε , {| rad := 0 ; θ := 0 |}) ].

Page 48: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

The Program in our running example

Definition robotPureProgam (target : Cart2D Q) : list (Q × Polar2D Q) :=let polarTarget : Polar2D R := Cart2Polar target inlet rotDuration : R := | θ polarTarget | / rotspeed inlet translDuration : R := (rad polarTarget) / speed in[

{ X := 1 ; Y := 1 ; }{ rad :=

√2 ; θ :=

π

4 ; }π

4√2

(0,{| rad:= 0 ; θ := ( polarθSign target ) * rotspeed |}); ( tapprox rotDuration delRes delEps , {| rad := 0 ; θ := 0 |}); (delay , {| rad := speed ; θ := 0 |}); ( tapprox translDuration res ε , {| rad := 0 ; θ := 0 |}) ].

tapprox r 1000 ε is a rational of the form ...1000

| tapprox r res ε - r | ≤ 1+2∗ε2∗res

Robbert Krebbers and Bas Spitters. “Type classes for efficient exact realarithmetic in Coq”. In: LMCS 9.1 (Feb. 14, 2013)

Page 49: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Constructive RealsCR u Q+ → Q

Robbert Krebbers and Bas Spitters. “Type classes for efficient exact realarithmetic in Coq”. In: LMCS 9.1 (Feb. 14, 2013)

Errett Bishop. Foundations of constructive analysis. McGraw-Hill, 1967.394 pp. r : CR

ε : Q+

r ε : Qr ε

≤ ε

r

+ : λ (r1 : CR) (r2 : CR).

Page 55: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Discrete computations over CR

if (r < π) then . . . else . . .

Page 56: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Discrete computations over CR

if (r < π) then . . . else . . .

Page 57: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Discrete computations over CR

if (r <ε π) then . . . else . . .

π - ε π + ε

true

false

Page 58: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Constructivity helps even in logical reasoning

√((cos 1

2 )) < exp(cos(sin(arctan π)))

a bqa qb

εa εb

Page 59: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Constructivity helps even in logical reasoning

√((cos 1

2 )) < exp(cos(sin(arctan π)))

a bqa qb

εa εb

Page 60: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Recap: How to Specify a CPS in ROSCoq

I Define the physical model as a Coq type

I Define the collection of agentsI Specify the behavior of each agent

I H/w agent : Coq relationI S/w agent : Coq message handler

Page 61: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Recap: How to Specify a CPS in ROSCoqI Define the physical model as a Coq typeI Define the collection of agents

I Specify the behavior of each agentI H/w agent : Coq relationI S/w agent : Coq message handler

Page 62: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Recap: How to Specify a CPS in ROSCoq

I Define the physical model as a Coq typeI Define the collection of agentsI Specify the behavior of each agent

I H/w agent : Coq relation

Time

linVel ic

tm tr

a εv a b

I S/w agent : Coq message handler

Page 63: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Recap: How to Specify a CPS in ROSCoq

I Define the physical model as a Coq typeI Define the collection of agentsI Specify the behavior of each agent

I H/w agent : Coq relationI S/w agent : Coq message handler

Definition robotPureProgam (target : Cart2D Q) : list (Q × Polar2D Q) :=let polarTarget : Polar2D R := Cart2Polar target inlet rotDuration : R := | θ polarTarget | / rotspeed inlet translDuration : R := (rad polarTarget) / speed in[

(0,{| rad:= 0 ; θ := ( polarθSign target ) * rotspeed |}); ( tapprox rotDuration delRes delEps , {| rad := 0 ; θ := 0 |}); (delay , {| rad := speed ; θ := 0 |}); ( tapprox translDuration res ε , {| rad := 0 ; θ := 0 |}) ].

Page 64: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Proved Property

X

Y

Y’

X’

idealθ

Our specification of the iCreate h/w isvery conservative. For example, whenit is asked to go straight and not turnat all, it might actually turn a bit. Togo perfectly straight, the two wheels

might need to be of exactly samesize, . . . so on. This weak assumption

complicates some of our integrals.

Definition ErrY’: R := (εv 0 w) * ( reacTime + Ev01TimeGapUB)+ (Sin (θErrTrans + θErrTurn)) * ( | target | + speed*timeErr

+ Ev23TimeGapUB * (εv speed 0) ).

Page 66: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Ongoing/Future Work

I General Shim in Haskell67

I Importing ROS message types in CoqI Writing the main loop

I Library of formally specified robotsI Verifying multi-robot collaborationI Probabilistic reasoning8

6https://github.com/acowley/roshask7Anthony Cowley and Camillo J. Taylor. “Stream-oriented robotics programming:

The design of roshask”. In: IROS. IEEE, 2011, pp. 1048–1054.8Thierry Coquand and Erik Palmgren. “Metric Boolean algebras and constructive

measure theory”. In: Archive for Mathematical Logic 41.7 (Oct. 1, 2002),pp. 687–704.

Page 67: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Ongoing/Future Work

I General Shim in Haskell67

I Importing ROS message types in CoqI Writing the main loop

I Library of formally specified robotsI Verifying multi-robot collaborationI Probabilistic reasoning8

6https://github.com/acowley/roshask7Anthony Cowley and Camillo J. Taylor. “Stream-oriented robotics programming:

The design of roshask”. In: IROS. IEEE, 2011, pp. 1048–1054.8Thierry Coquand and Erik Palmgren. “Metric Boolean algebras and constructive

measure theory”. In: Archive for Mathematical Logic 41.7 (Oct. 1, 2002),pp. 687–704.

Page 68: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Ongoing/Future Work

I General Shim in Haskell67

I Importing ROS message types in CoqI Writing the main loop

I Library of formally specified robots

Pull requests Issues Gist

ROSCoq / robots / 

latest commit 9775cc56f1

some moving around. created a dedicated directory for robot specs

 Abhishek Anand authored on May 19

..

icreate.v some moving around. created a dedicated directory for robot specs 2 months ago

This repository   Search

12 03 Unwatch   Unstar  Forkaa755 / ROSCoq

   master branch:

Status  API  Training  Shop  Blog  About  Help© 2015 GitHub, Inc.  Terms  Privacy  Security  Contact

I Verifying multi-robot collaborationI Probabilistic reasoning8

6https://github.com/acowley/roshask7Anthony Cowley and Camillo J. Taylor. “Stream-oriented robotics programming:

The design of roshask”. In: IROS. IEEE, 2011, pp. 1048–1054.8Thierry Coquand and Erik Palmgren. “Metric Boolean algebras and constructive

measure theory”. In: Archive for Mathematical Logic 41.7 (Oct. 1, 2002),pp. 687–704.

Page 69: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Ongoing/Future WorkI General Shim in Haskell67

I Importing ROS message types in CoqI Writing the main loop

I Library of formally specified robots

I Verifying multi-robot collaborationI Probabilistic reasoning86https://github.com/acowley/roshask7Anthony Cowley and Camillo J. Taylor. “Stream-oriented robotics programming:

The design of roshask”. In: IROS. IEEE, 2011, pp. 1048–1054.8Thierry Coquand and Erik Palmgren. “Metric Boolean algebras and constructive

measure theory”. In: Archive for Mathematical Logic 41.7 (Oct. 1, 2002),pp. 687–704.

Page 70: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Ongoing/Future Work

I General Shim in Haskell67

I Importing ROS message types in CoqI Writing the main loop

I Library of formally specified robotsI Verifying multi-robot collaborationI Probabilistic reasoning8

6https://github.com/acowley/roshask7Anthony Cowley and Camillo J. Taylor. “Stream-oriented robotics programming:

The design of roshask”. In: IROS. IEEE, 2011, pp. 1048–1054.8Thierry Coquand and Erik Palmgren. “Metric Boolean algebras and constructive

measure theory”. In: Archive for Mathematical Logic 41.7 (Oct. 1, 2002),pp. 687–704.

Page 71: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Ongoing/Future Work

I General Shim in Haskell67

I Importing ROS message types in CoqI Writing the main loop

I Library of formally specified robotsI Verifying multi-robot collaborationI Probabilistic reasoning8

6https://github.com/acowley/roshask7Anthony Cowley and Camillo J. Taylor. “Stream-oriented robotics programming:

The design of roshask”. In: IROS. IEEE, 2011, pp. 1048–1054.8Thierry Coquand and Erik Palmgren. “Metric Boolean algebras and constructive

measure theory”. In: Archive for Mathematical Logic 41.7 (Oct. 1, 2002),pp. 687–704.

Page 72: ROSCoq: Robots powered by Constructive Realsaa755/ROSCoq/ITP.pdfROSCoq: Robots powered by Constructive Reals Abhishek Anand (joint work with Ross Knepper 1) ITP, 27-Aug-2015, Nanjing

Questions

http://www.cs.cornell.edu/˜aa755/ROSCoq/http://github.com/aa755/ROSCoq