generated from tpl/purs
option warning
This commit is contained in:
@@ -113,7 +113,7 @@ type Props_geom =
|
||||
, condim :: Int
|
||||
, group :: Int
|
||||
, priority :: Int
|
||||
, size :: Vec Real
|
||||
, size :: Array Real
|
||||
, material :: String
|
||||
, rgba :: Vec4 Real
|
||||
, friction :: Vec Real
|
||||
|
||||
@@ -102,7 +102,7 @@ type Props_option =
|
||||
, actuatorgroupdisable :: Array Int
|
||||
, solver :: Solver
|
||||
)
|
||||
option = tag @Props_option "option" :: Tag Props_option
|
||||
option = tag @Props_option "mjcf:option" :: Tag Props_option
|
||||
|
||||
type Props_flag =
|
||||
( constraint :: Enable
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module Mujoco.XML.Node.Prop (class Serialize, serialize, serializeProps, class SerializeProps', serializeProps', renames, unrenames) where
|
||||
module Mujoco.XML.Node.Prop (class Serialize, serialize, serializeProps, class SerializeProps', serializeProps', renames) where
|
||||
|
||||
import Prelude
|
||||
|
||||
@@ -10,7 +10,6 @@ import Data.Maybe (fromMaybe)
|
||||
import Data.Number.Format (toString) as Number
|
||||
import Data.Symbol (class IsSymbol, reflectSymbol)
|
||||
import Data.Tuple (Tuple)
|
||||
import Data.Tuple as Tuple
|
||||
import Data.Tuple.Nested ((/\))
|
||||
import Prim.Row (class Cons, class Union)
|
||||
import Prim.RowList (class RowToList, RowList)
|
||||
@@ -22,9 +21,6 @@ import Unsafe.Coerce (unsafeCoerce)
|
||||
renames :: Map String String
|
||||
renames = Map.fromFoldable ["size" /\ "mjcf:size"]
|
||||
|
||||
unrenames :: Map String String
|
||||
unrenames = Map.fromFoldable $ map Tuple.swap $ (Map.toUnfoldable renames :: Array _)
|
||||
|
||||
class Serialize a where
|
||||
serialize :: a -> String
|
||||
|
||||
|
||||
@@ -15,7 +15,11 @@ module Mujoco.XML.Node
|
||||
import Prelude
|
||||
|
||||
import Data.FoldableWithIndex (foldlWithIndex)
|
||||
import Data.Map (Map)
|
||||
import Data.Map as Map
|
||||
import Data.String as String
|
||||
import Data.Tuple as Tuple
|
||||
import Data.Tuple.Nested ((/\))
|
||||
import Elmish.HTML (empty, fragment, text) as HTML
|
||||
import Elmish.HTML.Internal (tag, tagNoContent) as HTML
|
||||
import Elmish.React (ReactElement)
|
||||
@@ -25,6 +29,14 @@ import Prim.Row (class Union)
|
||||
import Prim.RowList (class RowToList)
|
||||
import Unsafe.Coerce (unsafeCoerce)
|
||||
|
||||
unrenames :: Map String String
|
||||
unrenames =
|
||||
let
|
||||
props = Map.fromFoldable $ map Tuple.swap $ (Map.toUnfoldable Prop.renames :: Array _)
|
||||
tags = Map.fromFoldable ["mjcf:option" /\ "option"]
|
||||
in
|
||||
Map.union props tags
|
||||
|
||||
foreign import renderToString :: ReactElement -> String
|
||||
|
||||
type Tag props
|
||||
@@ -50,13 +62,13 @@ foreign import data Node :: Type
|
||||
render :: Node -> String
|
||||
render =
|
||||
let
|
||||
unrenameProps str =
|
||||
foldlWithIndex unrenameProp str Prop.unrenames
|
||||
unrename str =
|
||||
foldlWithIndex unrename' str unrenames
|
||||
|
||||
unrenameProp from str to =
|
||||
unrename' from str to =
|
||||
String.replaceAll (String.Pattern from) (String.Replacement to) str
|
||||
in
|
||||
unrenameProps <<< renderToString <<< toReact
|
||||
unrename <<< renderToString <<< toReact
|
||||
|
||||
fromReact :: ReactElement -> Node
|
||||
fromReact = unsafeCoerce
|
||||
|
||||
@@ -10,6 +10,7 @@ import Effect.Class (liftEffect)
|
||||
import Mujoco.MJCF as X
|
||||
import Mujoco.Wasm (renderSpec)
|
||||
import Mujoco.XML.Node (Node)
|
||||
import Mujoco.XML.Node as XML
|
||||
import Test.Assert (assertTrue)
|
||||
import Test.Spec (Spec, describe, it)
|
||||
|
||||
@@ -19,7 +20,7 @@ ok = void <<< renderSpec
|
||||
fail :: Node -> Aff Unit
|
||||
fail = (liftEffect <<< assertTrue <<< isLeft) <=< (try <<< renderSpec)
|
||||
|
||||
w :: Node -> Node
|
||||
w :: forall a. XML.Children a => a -> Node
|
||||
w = X.mujoco {} <<< X.worldbody {}
|
||||
|
||||
spec :: Spec Unit
|
||||
@@ -131,52 +132,52 @@ spec =
|
||||
it "hinge" $ ok $ w $
|
||||
X.body { name: "b1", pos: 0.0 /\ 0.0 /\ 0.5 }
|
||||
[ X.joint { type: X.Hinge, axis: 1.0 /\ 0.0 /\ 0.0 }
|
||||
, X.geom { type: X.GSphere, size: 0.1 /\ 0.0 /\ 0.0 } unit
|
||||
, X.geom { type: X.GSphere, size: [0.1, 0.0, 0.0] } unit
|
||||
]
|
||||
|
||||
it "slide with range" $ ok $ w $
|
||||
X.body { name: "slider", pos: 0.0 /\ 0.0 /\ 1.0 }
|
||||
[ X.joint { type: X.Slide, axis: 0.0 /\ 0.0 /\ 1.0, range: (-1.0) /\ 1.0, limited: X.AutoBoolTrue }
|
||||
, X.geom { type: X.GBox, size: 0.1 /\ 0.1 /\ 0.1 } unit
|
||||
, X.geom { type: X.GBox, size: [0.1, 0.1, 0.1] } unit
|
||||
]
|
||||
|
||||
it "stiffness + damping" $ ok $ w $
|
||||
X.body { pos: 0.0 /\ 0.0 /\ 0.0 }
|
||||
[ X.joint { type: X.Hinge, stiffness: 100.0, damping: 10.0, armature: 0.1 }
|
||||
, X.geom { type: X.GSphere, size: 0.05 /\ 0.0 /\ 0.0 } unit
|
||||
, X.geom { type: X.GSphere, size: [0.05, 0.0, 0.0] } unit
|
||||
]
|
||||
|
||||
describe "freejoint" do
|
||||
it "basic" $ ok $ w $
|
||||
X.body { name: "free_body", pos: 0.0 /\ 0.0 /\ 1.0 }
|
||||
[ X.freejoint { name: "fj" }
|
||||
, X.geom { type: X.GSphere, size: 0.1 /\ 0.0 /\ 0.0 } unit
|
||||
, X.geom { type: X.GSphere, size: [0.1, 0.0, 0.0] } unit
|
||||
]
|
||||
|
||||
describe "geom" do
|
||||
it "sphere" $ ok $ w $
|
||||
X.geom { type: X.GSphere, size: 1.0 /\ 0.0 /\ 0.0 } unit
|
||||
X.geom { type: X.GSphere, size: [1.0, 0.0, 0.0] } unit
|
||||
|
||||
it "capsule fromto" $ ok $ w $
|
||||
X.geom { type: X.GCapsule, fromto: [0.0, 0.0, 0.0, 0.0, 0.0, 1.0], size: 0.05 /\ 0.0 /\ 0.0 } unit
|
||||
X.geom { type: X.GCapsule, fromto: [0.0, 0.0, 0.0, 0.0, 0.0, 1.0], size: [0.05, 0.0, 0.0] } unit
|
||||
|
||||
it "box with material" $ ok $ X.mujoco {}
|
||||
[ X.asset {}
|
||||
[ X.material { name: "red", rgba: 1.0 /\ 0.0 /\ 0.0 /\ 1.0 } unit ]
|
||||
, X.worldbody {} $
|
||||
X.geom { type: X.GBox, size: 0.5 /\ 0.5 /\ 0.5, material: "red" } unit
|
||||
X.geom { type: X.GBox, size: [0.5, 0.5, 0.5], material: "red" } unit
|
||||
]
|
||||
|
||||
it "plane" $ ok $ w $
|
||||
X.geom { type: X.GPlane, size: 5.0 /\ 5.0 /\ 0.1 } unit
|
||||
X.geom { type: X.GPlane, size: [5.0, 5.0, 0.1] } unit
|
||||
|
||||
it "friction + density" $ ok $ w $
|
||||
X.geom { type: X.GSphere, size: 0.1 /\ 0.0 /\ 0.0, friction: 0.5 /\ 0.005 /\ 0.0001, density: 500.0 } unit
|
||||
X.geom { type: X.GSphere, size: [0.1, 0.0, 0.0], friction: 0.5 /\ 0.005 /\ 0.0001, density: 500.0 } unit
|
||||
|
||||
describe "site" do
|
||||
it "basic" $ ok $ w $
|
||||
X.body { pos: 0.0 /\ 0.0 /\ 0.0 }
|
||||
[ X.geom { type: X.GSphere, size: 0.1 /\ 0.0 /\ 0.0 } unit
|
||||
[ X.geom { type: X.GSphere, size: [0.1, 0.0, 0.0] } unit
|
||||
, X.site { name: "s1", pos: 0.0 /\ 0.0 /\ 0.1, size: 0.01 /\ 0.01 /\ 0.01 }
|
||||
]
|
||||
|
||||
@@ -186,7 +187,7 @@ spec =
|
||||
|
||||
it "tracking" $ ok $ w $
|
||||
X.body { name: "target_body", pos: 0.0 /\ 0.0 /\ 0.5 }
|
||||
[ X.geom { type: X.GSphere, size: 0.1 /\ 0.0 /\ 0.0 } unit
|
||||
[ X.geom { type: X.GSphere, size: [0.1, 0.0, 0.0] } unit
|
||||
, X.camera { name: "tracker", mode: X.CamTargetbody, target: "target_body", pos: 1.0 /\ 0.0 /\ 0.5 }
|
||||
]
|
||||
|
||||
@@ -201,7 +202,7 @@ spec =
|
||||
it "explicit mass + diaginertia" $ ok $ w $
|
||||
X.body { pos: 0.0 /\ 0.0 /\ 0.0 }
|
||||
[ X.inertial { pos: 0.0 /\ 0.0 /\ 0.0, mass: 1.0, diaginertia: 0.01 /\ 0.01 /\ 0.01 }
|
||||
, X.geom { type: X.GSphere, size: 0.1 /\ 0.0 /\ 0.0 } unit
|
||||
, X.geom { type: X.GSphere, size: [0.1, 0.0, 0.0] } unit
|
||||
]
|
||||
|
||||
describe "composite" do
|
||||
@@ -216,11 +217,35 @@ spec =
|
||||
, X.material { name: "floor_mat", texture: "grid", texrepeat: 5.0 /\ 5.0 } unit
|
||||
]
|
||||
, X.worldbody {}
|
||||
[ X.geom { type: X.GPlane, size: 5.0 /\ 5.0 /\ 0.1, material: "floor_mat" } unit
|
||||
[ X.geom { type: X.GPlane, size: [5.0, 5.0, 0.1], material: "floor_mat" } unit
|
||||
, X.light { name: "top", pos: 0.0 /\ 0.0 /\ 3.0, dir: 0.0 /\ 0.0 /\ (-1.0) }
|
||||
, X.body { name: "ball", pos: 0.0 /\ 0.0 /\ 1.0 }
|
||||
[ X.freejoint {}
|
||||
, X.geom { type: X.GSphere, size: 0.1 /\ 0.0 /\ 0.0, rgba: 1.0 /\ 0.0 /\ 0.0 /\ 1.0 } unit
|
||||
, X.geom { type: X.GSphere, size: [0.1, 0.0, 0.0], rgba: 1.0 /\ 0.0 /\ 0.0 /\ 1.0 } unit
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
it "bodies with joints" $ ok $ w
|
||||
[ X.light { name: "top", pos: 0.0 /\ 0.0 /\ 1.0 }
|
||||
, X.body {}
|
||||
[ X.joint { name: "v0_rx", damping: 1.0, stiffness: 10.0, axis: 1.0 /\ 0.0 /\ 0.0, pos: 0.0 /\ 0.0 /\ (-0.5) }
|
||||
, X.joint { name: "v0_ry", damping: 1.0, stiffness: 10.0, axis: 0.0 /\ 1.0 /\ 0.0, pos: 0.0 /\ 0.0 /\ (-0.5) }
|
||||
, X.geom { type: X.GCylinder, size: [1.0, 0.05] } unit
|
||||
, X.body { pos: zero /\ zero /\ 0.51 }
|
||||
[ X.joint { name: "b0a_rx", damping: 1.0, stiffness: 10.0, axis: 1.0 /\ 0.0 /\ 0.0, pos: 0.0 /\ 0.0 /\ (-0.5) }
|
||||
, X.joint { name: "b0a_ry", damping: 1.0, stiffness: 10.0, axis: 0.0 /\ 1.0 /\ 0.0, pos: 0.0 /\ 0.0 /\ (-0.5) }
|
||||
, X.geom { type: X.GCylinder, size: [0.05, 0.5] } unit
|
||||
, X.body { pos: zero /\ zero /\ one }
|
||||
[ X.joint { name: "b0b_rx", damping: 1.0, stiffness: 10.0, axis: 1.0 /\ 0.0 /\ 0.0, pos: 0.0 /\ 0.0 /\ (-0.5) }
|
||||
, X.joint { name: "b0b_ry", damping: 1.0, stiffness: 10.0, axis: 0.0 /\ 1.0 /\ 0.0, pos: 0.0 /\ 0.0 /\ (-0.5) }
|
||||
, X.geom { type: X.GCylinder, size: [0.05, 0.5] } unit
|
||||
, X.body { pos: zero /\ zero /\ 0.5 }
|
||||
[ X.joint { name: "v1_rx", damping: 1.0, stiffness: 10.0, axis: 1.0 /\ 0.0 /\ 0.0, pos: 0.0 /\ 0.0 /\ (-0.5) }
|
||||
, X.joint { name: "v1_ry", damping: 1.0, stiffness: 10.0, axis: 0.0 /\ 1.0 /\ 0.0, pos: 0.0 /\ 0.0 /\ (-0.5) }
|
||||
, X.geom { type: X.GCylinder, size: [1.0, 0.05] } unit
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user