Commit d4a10fc8 authored by Jan Koniarik's avatar Jan Koniarik
Browse files

started to use library launch/package tools for XML files

parent 11d61ecf
cmake_minimum_required(VERSION 2.8.3)
project(schpin_koke)
catkin_package()
<?xml version="1.0"?>
<package format="2">
<name>schpin_koke</name>
<version>0.0.0</version>
<description>The schpin_koke package</description>
<maintainer email="squirrel@todo.todo">squirrel</maintainer>
<license>LGPLv3</license>
<buildtool_depend>catkin</buildtool_depend>
<export>
</export>
</package>
<launch>
<param name="robot_description" textfile="$(find schpin_koke)/src/koke.urdf"/>
<param name="robot_semantics" textfile="$(find schpin_koke)/src/koke.srdf"/>
</launch>
......@@ -57,7 +57,7 @@ executable schpin-koke
-- other-extensions:
-- Other library packages from which modules are imported.
build-depends: base >=4.11, linear, schpin-robot-lib, dimensional, directory, mtl, language-openscad, containers, bytestring, filepath, unordered-containers, cassava, hashable, Unique
build-depends: base >=4.11, linear, schpin-robot-lib, dimensional, directory, language-openscad, containers, bytestring, filepath, unordered-containers, cassava, hashable, Unique, mtl
-- Directories containing source files.
hs-source-dirs: src
......
module Package where
import Control.Monad.Reader ( runReader )
import Parser
import Schpin.Package
import Schpin.Package.Xml
import Schpin.SCAD
import System.Directory ( copyFile
, createDirectory
, createDirectoryIfMissing
, getCurrentDirectory
)
import Schpin.Walker
import Schpin.Walker.Pkg
import Schpin.Walker.SCAD
import Schpin.Walker.SRDF
import Schpin.Walker.URDF
import System.Directory ( copyFile
, createDirectory
, createDirectoryIfMissing
, getCurrentDirectory
)
data ConfType = Default | Folded | Expanded deriving (Show, Eq);
kokePackageConfig :: String -> PackageConfig
kokePackageConfig cwd = PackageConfig { pkg_name = "schpin_koke"
, scad_dir = cwd ++ "/out/tmp/scad"
, pkg_dir = cwd ++ "/out/pkg/schpin_koke"
, src_dir = cwd ++ "/src/scad"
, urdf_subdir = "/src/"
, srdf_subdir = "/src/"
}
kokePackageConfig cwd = PackageConfig
{ pkg_info = PackageInfo
{ pkg_name = "schpin_koke"
, version = "0.1"
, description = "Data files for KOKE"
, maintainers = [Person "Jan Koniarik" "433337@mail.muni.cz"]
, license = "LGPL"
, authors = [Person "Jan Koniarik" "433337@mail.muni.cz"]
, depends = []
}
, scad_dir = cwd ++ "/out/tmp/scad"
, pkg_dir = cwd ++ "/out/pkg/schpin_koke"
, src_dir = cwd ++ "/src/scad"
, urdf_subdir = "/src/"
, srdf_subdir = "/src/"
}
exportExtras :: (ConfType -> SimpleWalker) -> IO()
exportExtras :: (ConfType -> SimpleWalker) -> IO ()
exportExtras w = do
cwd <- getCurrentDirectory
let conf = kokePackageConfig cwd
let ew = ewalker conf Default
mapM_ (uncurry renderSCAD)
$ [ (cwd ++ "/out/gen/skeleton/default.scad", getSCADVisualSkeleton ew)
, ( cwd ++ "/out/gen/skeleton/default_col.scad"
, getSCADCollisionSkeleton ew
)
, ( cwd ++ "/out/gen/skeleton/folded.scad"
, getSCADVisualSkeleton (ewalker conf Folded)
)
, ( cwd ++ "/out/gen/skeleton/expanded.scad"
, getSCADVisualSkeleton (ewalker conf Expanded)
)
]
cwd <- getCurrentDirectory
let conf = kokePackageConfig cwd
let ew = extendWalker (w Default) conf
mapM_ (uncurry renderSCAD)
$ [ (cwd ++ "/out/gen/skeleton/default.scad", getSCADVisualSkeleton ew)
, ( cwd ++ "/out/gen/skeleton/default_col.scad"
, getSCADCollisionSkeleton ew
)
, ( cwd ++ "/out/gen/skeleton/folded.scad"
, getSCADVisualSkeleton (extendWalker (w Folded) conf)
)
, ( cwd ++ "/out/gen/skeleton/expanded.scad"
, getSCADVisualSkeleton (extendWalker (w Expanded) conf)
)
]
generateBOM (ew) (conf)
generatePrint (ew) (conf)
generateBOM (ew) (conf)
generatePrint (ew) (conf)
where
ewalker conf conf_type = runReader (extendWalker $ w conf_type) $ conf
exportPackage :: (ConfType -> SimpleWalker) -> IO ()
exportPackage w = do
cwd <- getCurrentDirectory
let conf = kokePackageConfig cwd
let ew = ewalker conf Default
generateWalkerPackage (w Default) conf
createDirectoryIfMissing False (pkg_dir conf ++ "/launch")
copyFile "launch/robot_description.launch"
(pkg_dir conf ++ "/launch/robot_description.launch")
copyFile "launch/koke_gazebo.launch"
(pkg_dir conf ++ "/launch/koke_gazebo.launch")
cwd <- getCurrentDirectory
let conf = kokePackageConfig cwd
let ew = extendWalker (w Default) conf
createDirectoryIfMissing False (pkg_dir conf ++ "/worlds")
copyFile "worlds/koke.world" (pkg_dir conf ++ "/worlds/koke.world")
generateWalkerPackage (w Default) conf
writeCMakeLists conf
writePackageXML conf
writeRobotDescriptionLaunch (w Default) conf
copyFile "general/CMakeLists.txt" (pkg_dir conf ++ "/CMakeLists.txt")
copyFile "general/package.xml" (pkg_dir conf ++ "/package.xml")
copyFile "launch/koke_gazebo.launch"
(pkg_dir conf ++ "/launch/koke_gazebo.launch")
where
ewalker conf conf_type = runReader (extendWalker $ w conf_type) $ conf
createDirectoryIfMissing False (pkg_dir conf ++ "/worlds")
copyFile "worlds/koke.world" (pkg_dir conf ++ "/worlds/koke.world")
......@@ -22,6 +22,7 @@ import Debug.Trace ( traceShow
)
import qualified Language.OpenSCAD as LS
import qualified Schpin.SCAD as SC
import Schpin.Package
import Schpin.Shared
import System.Directory
import System.FilePath
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment