Package Summary

SQL bindings for ros

Status

Not being actively developed. See instead the warehousewg stack, which wraps a NoSQL database.

Example

  35 import roslib; roslib.load_manifest('rossql_examples')
  36 import rospy
  37 from rossql import rosdb
  38 from rossql.rosdb import nested_field, nested_column
  39 import geometry_msgs.msg as gm
  40 
  41 
  42 def main():
  43     
  44     # Create db and table of poses indexed by x,y
  45     db = rosdb.create_in_memory_db()
  46     indices = [nested_field('position', c) for c in ['x', 'y']]
  47     table = rosdb.create_message_table(db, 'geometry_msgs/Pose', 'poses', \
  48                                        indexed_fields=indices)
  49 
  50     print "Inserting"
  51     # Insert some ros messages
  52     poses = [gm.Pose(position=gm.Point(x, y, x+y)) \
  53              for x in range(20) for y in range(30)]
  54     for pose in poses:
  55         rosdb.insert_message(table, pose)
  56     print "done inserting"
  57 
  58     # Query
  59     q = table.select((nested_column(table, 'position', 'x') == 15) & \
  60                      (nested_column(table, 'position', 'z') > 20) & \
  61                      (nested_column(table, 'position', 'z') < 30))
  62     result = q.execute()
  63     matching_poses = [rosdb.msg_from_row(table, row) for row in result]
  64 
  65     # Print
  66     for p in matching_poses:
  67         print p        
  68 
  69 
  70 if __name__ == "__main__":
  71     main()

Wiki: rossql (last edited 2011-04-15 18:16:21 by BhaskaraMarthi)