ICreateMoveToLoc.haskellExtraction
Instantiating the parameters
Definition rotSpeedRadPerSec : Qpos := QposMake 1 2.
Definition linSpeedMetresPerSec : Qpos := QposMake 1 10.
Require Import RoshaskMsg.
RoshaskMsg.delayResolutionSecInv denotes the timing resolution of our Haskell shim,
which is currently 1 microsecond.
Definition delResSecInv : positive := RoshaskMsg.delayResolutionSecInv.
Definition delEpsSec : Qpos := QposMake 1 delResSecInv.
Definition initDelayLin : Qpos := QposMake 1 1.
Require Import message.
Definition SwProcessInstance : Process Message (list Message):=
@SwProcess
rotSpeedRadPerSec
linSpeedMetresPerSec
delResSecInv
delEpsSec
initDelayLin.
Definition delEpsSec : Qpos := QposMake 1 delResSecInv.
Definition initDelayLin : Qpos := QposMake 1 1.
Require Import message.
Definition SwProcessInstance : Process Message (list Message):=
@SwProcess
rotSpeedRadPerSec
linSpeedMetresPerSec
delResSecInv
delEpsSec
initDelayLin.
Providing an instance of RosHaskImplementable
Extraction Language Haskell.
Require Import ExtrHaskellBasic.
Require Import RoshaskImpl.
Require Import RoshaskTypes.
Require Import Vector.
Require Import Ros.Geometry_msgs.Vector3.
Definition toVector3 (x:Q) (y:Q) : Vector3 :=
{| _x := toRoshaskFloat x ; _y := toRoshaskFloat y; _z:= toRoshaskFloat 0|}.
Definition CQtoVector3 (pq :Cart2D Q) : Vector3 :=
toVector3 (X pq) (Y pq).
Definition PQtoVector3 (pq :Polar2D Q) : Vector3 :=
toVector3 (rad pq) (θ pq).
Definition fromVector3 (v: Vector3) : Q × Q :=
(fromRoshaskFloat (_x v), fromRoshaskFloat (_y v)).
Definition CQfromVector3 (v: Vector3) : Cart2D Q :=
let (x,y) := fromVector3 v in
{| X := x; Y:= y|}.
Definition PQfromVector3 (v: Vector3) : Polar2D Q :=
let (x,y) := fromVector3 v in
{| rad := x; θ := y|}.
Require Import String.
let (x,y) := fromVector3 v in
{| X := x; Y:= y|}.
Definition PQfromVector3 (v: Vector3) : Polar2D Q :=
let (x,y) := fromVector3 v in
{| rad := x; θ := y|}.
Require Import String.
Finally, here is the instance
Interconvert between the payload types and implementation types.
These are used by the shim when sending and receiving messages.
toImpl := λ t : Topic,
match t as t0 return (topicType t0 → Vector3) with
| VELOCITY ⇒ PQtoVector3
| TARGETPOS ⇒ CQtoVector3
end;
fromImpl := λ t : Topic,
match t as t0 return (Vector3 → topicType t0) with
| VELOCITY ⇒ PQfromVector3
| TARGETPOS ⇒ CQfromVector3
end;
In the Robot Operating System, each topic is identified by a string.
We have to provided such strings for each of the ROSCoq topics
rosQualName := λ t : Topic,
match t with
| VELOCITY ⇒ "/icreate_cmd_vel"%string
| TARGETPOS ⇒ "/targetpos"%string
end |}.
match t with
| VELOCITY ⇒ "/icreate_cmd_vel"%string
| TARGETPOS ⇒ "/targetpos"%string
end |}.
Composing a ROSCoq software agent with the ROSCoq shim
Require Import MCInstances.
Require Import RoshaskNodeMonad.
Definition icreateRoshaskSwNode : Node unit :=
let prf := decAuto (0 < Datatypes.length (fst (locTopics SWNODE)))%nat I in
runSwNode Topic SwProcessInstance (locTopics SWNODE) prf.
Extraction "icreateMoveToLoc.hs" icreateRoshaskSwNode.