Getting Started - acowley/roshask GitHub Wiki

Creating a Package

At a command line, go to a directory on your ROS_PACKAGE_PATH where you want to create a new package (which we'll call "MyPackage" for the sake of this example) and run the command,

roshask create MyPackage std_msgs

to create a new package, named MyPackage, that depends on the std_msgs ROS package. The create subcommand of the roshask executable will prepare a Haskell project using the cabal package management system, along with basic source files in the src subdirectory. Please consult the Examples directory in the roshask repository for examples of packages and their build systems. If you installed roshask from hackage, you can expand a copy of its source, including the Examples directory, by issuing the command cabal unpack roshask wherever you want the roshask source.

Building a Package

The first time you want to build a package that depends on roshask, run the command roshask dep in the package directory. This will chase down all the dependencies of your package and generate Haskell code for all the message types defined in those packages. This will also automatically generate and install a Haskell library for any messages defined in your package, so you will want to run roshask dep after defining your own message types. Note that running rosmake (or even rosmake -s) will also run roshask dep before compiling your package.

The roshask dep command will install Haskell libraries for the messages defined in your package along with messages defined in the packages you depend on. These libraries will have the name ROS-pkgName-msgs, where any underscores in the package name will have been replaced with hyphens. If pkgName already ends in the string "msgs", then that suffix is not added to the name. This is the idiom in ROS for defining packages that just define message types, but not any Nodes. The ROS- prefix on these generated haskell libraries also provides a way to uninstall libraries generated by roshask should you chose to do so: simply use ghc-pkg unregister to unregister all the ROS- libraries.

These ROS-pkgName-msgs libraries are distinct from any libraries your roshask package might define for things like Nodes. The roshask create command will give your cabal library a name like ROS-pkgName, and this .cabal file is yours to do with as you please. It is only the *-msgs libraries that roshask will regenerate when called with roshask dep.

The upshot of all this is that you will typically want to run roshask dep to make sure that messages defined in a package you depend on are built and registered with GHC, but it is not necessary to run this command for every build of your package. Instead, you can use cabal install to compile your package. This will register any library defined by your package with GHC, and place any executables defined by your package in your package's bin directory.