acowley / roshask

Haskell client library for the ROS robotics framework.
BSD 3-Clause "New" or "Revised" License
107 stars 18 forks source link

Added support for default messages. Default messages can be created by i... #20

Closed rgleichman closed 10 years ago

rgleichman commented 10 years ago

...mporting Data.Default.Generics and doing (def :: ).

rgleichman commented 10 years ago

For large messages it would have been very tedious to initialize all of the fields. Now, instead of writing

Pr2GripperCommandActionGoal{
          header= H.Header {H.seq= 0,
                            H.stamp = (0,0),
                            H.frame_id= ""},
          goal_id= GID.GoalID {
            GID.stamp = (0,0),
            GID.id = ""
          }
          , goal=Pr2GripperCommandGoal{
             command = Pr2GripperCommand{
                position = closed, max_effort = (-1)
                }
             }
          }

You can do this:

import Data.Default.Generics (def)

(def :: Pr2GripperCommandActionGoal){
          goal=Pr2GripperCommandGoal{
             command = Pr2GripperCommand{
                position = closed, max_effort = (-1)
                }
             }
          }

This is similar to how rospy initializes messages. The Haskell package used for this is data-default-generics

acowley commented 10 years ago

Thanks, this looks good. I tend to be skeptical about default value type classes, but typical usage of ROS message types does seem to lean that way.