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 ...@@ -57,7 +57,7 @@ executable schpin-koke
-- other-extensions: -- other-extensions:
-- Other library packages from which modules are imported. -- 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. -- Directories containing source files.
hs-source-dirs: src hs-source-dirs: src
......
module Package where module Package where
import Control.Monad.Reader ( runReader )
import Parser import Parser
import Schpin.Package
import Schpin.Package.Xml
import Schpin.SCAD import Schpin.SCAD
import System.Directory ( copyFile
, createDirectory
, createDirectoryIfMissing
, getCurrentDirectory
)
import Schpin.Walker import Schpin.Walker
import Schpin.Walker.Pkg import Schpin.Walker.Pkg
import Schpin.Walker.SCAD import Schpin.Walker.SCAD
import Schpin.Walker.SRDF import Schpin.Walker.SRDF
import Schpin.Walker.URDF import Schpin.Walker.URDF
import System.Directory ( copyFile
, createDirectory
, createDirectoryIfMissing
, getCurrentDirectory
)
data ConfType = Default | Folded | Expanded deriving (Show, Eq); data ConfType = Default | Folded | Expanded deriving (Show, Eq);
kokePackageConfig :: String -> PackageConfig kokePackageConfig :: String -> PackageConfig
kokePackageConfig cwd = PackageConfig { pkg_name = "schpin_koke" kokePackageConfig cwd = PackageConfig
, scad_dir = cwd ++ "/out/tmp/scad" { pkg_info = PackageInfo
, pkg_dir = cwd ++ "/out/pkg/schpin_koke" { pkg_name = "schpin_koke"
, src_dir = cwd ++ "/src/scad" , version = "0.1"
, urdf_subdir = "/src/" , description = "Data files for KOKE"
, srdf_subdir = "/src/" , 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 exportExtras w = do
cwd <- getCurrentDirectory cwd <- getCurrentDirectory
let conf = kokePackageConfig cwd let conf = kokePackageConfig cwd
let ew = ewalker conf Default let ew = extendWalker (w Default) conf
mapM_ (uncurry renderSCAD) mapM_ (uncurry renderSCAD)
$ [ (cwd ++ "/out/gen/skeleton/default.scad", getSCADVisualSkeleton ew) $ [ (cwd ++ "/out/gen/skeleton/default.scad", getSCADVisualSkeleton ew)
, ( cwd ++ "/out/gen/skeleton/default_col.scad" , ( cwd ++ "/out/gen/skeleton/default_col.scad"
, getSCADCollisionSkeleton ew , getSCADCollisionSkeleton ew
) )
, ( cwd ++ "/out/gen/skeleton/folded.scad" , ( cwd ++ "/out/gen/skeleton/folded.scad"
, getSCADVisualSkeleton (ewalker conf Folded) , getSCADVisualSkeleton (extendWalker (w Folded) conf)
) )
, ( cwd ++ "/out/gen/skeleton/expanded.scad" , ( cwd ++ "/out/gen/skeleton/expanded.scad"
, getSCADVisualSkeleton (ewalker conf Expanded) , getSCADVisualSkeleton (extendWalker (w Expanded) conf)
) )
] ]
generateBOM (ew) (conf) generateBOM (ew) (conf)
generatePrint (ew) (conf) generatePrint (ew) (conf)
where
ewalker conf conf_type = runReader (extendWalker $ w conf_type) $ conf
exportPackage :: (ConfType -> SimpleWalker) -> IO () exportPackage :: (ConfType -> SimpleWalker) -> IO ()
exportPackage w = do exportPackage w = do
cwd <- getCurrentDirectory cwd <- getCurrentDirectory
let conf = kokePackageConfig cwd let conf = kokePackageConfig cwd
let ew = ewalker conf Default let ew = extendWalker (w Default) conf
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")
createDirectoryIfMissing False (pkg_dir conf ++ "/worlds") generateWalkerPackage (w Default) conf
copyFile "worlds/koke.world" (pkg_dir conf ++ "/worlds/koke.world") writeCMakeLists conf
writePackageXML conf
writeRobotDescriptionLaunch (w Default) conf
copyFile "general/CMakeLists.txt" (pkg_dir conf ++ "/CMakeLists.txt") copyFile "launch/koke_gazebo.launch"
copyFile "general/package.xml" (pkg_dir conf ++ "/package.xml") (pkg_dir conf ++ "/launch/koke_gazebo.launch")
where createDirectoryIfMissing False (pkg_dir conf ++ "/worlds")
ewalker conf conf_type = runReader (extendWalker $ w conf_type) $ conf copyFile "worlds/koke.world" (pkg_dir conf ++ "/worlds/koke.world")
...@@ -22,6 +22,7 @@ import Debug.Trace ( traceShow ...@@ -22,6 +22,7 @@ import Debug.Trace ( traceShow
) )
import qualified Language.OpenSCAD as LS import qualified Language.OpenSCAD as LS
import qualified Schpin.SCAD as SC import qualified Schpin.SCAD as SC
import Schpin.Package
import Schpin.Shared import Schpin.Shared
import System.Directory import System.Directory
import System.FilePath import System.FilePath
......
Supports Markdown
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