예제 #1
0
  def toROS( self ):
    ros = ROSObjectDescription()
    ros.id = self.id
    ros.type = str( self.type )

    if self.geometries:
      for model in self.geometries:
        if model.geometry_type == 'POINT2D':
          ros.geometries.point2d_models.append( model.toROSPoint2DModel() )
        elif model.geometry_type == 'POSE2D':
          ros.geometries.pose2d_models.append( model.toROSPose2DModel() )
        elif model.geometry_type == 'POLYGON2D':
          ros.geometries.polygon2d_models.append( model.toROSPolygon2DModel() )
        elif model.geometry_type == 'POINT3D':
          ros.geometries.point3d_models.append( model.toROSPoint3DModel() )
        elif model.geometry_type == 'POSE3D':
          ros.geometries.pose3d_models.append( model.toROSPose3DModel() )
        elif model.geometry_type == 'POLYGON3D':
          ros.geometries.polygon3d_models.append( model.toROSPolygon3DModel() )
        elif model.geometry_type == 'TRIANGLEMESH3D':
          ros.geometries.trianglemesh3d_models.append( model.toROSTriangleMesh3DModel() )
        elif model.geometry_type == 'POLYGONMESH3D':
          ros.geometries.polygonmesh3d_models.append( model.toROSPolygonMesh3DModel() )
        else:
          print 'ERROR: found unknown geometry type:', model.geometry_type

    if self.abstractions:
      for model in self.abstractions:
        if model.geometry_type == 'POINT2D':
          ros.abstractions.point2d_models.append( model.toROSPoint2DModel() )
        elif model.geometry_type == 'POSE2D':
          ros.abstractions.pose2d_models.append( model.toROSPose2DModel() )
        elif model.geometry_type == 'POLYGON2D':
          ros.abstractions.polygon2d_models.append( model.toROSPolygon2DModel() )
        elif model.geometry_type == 'POINT3D':
          ros.abstractions.point3d_models.append( model.toROSPoint3DModel() )
        elif model.geometry_type == 'POSE3D':
          ros.abstractions.pose3d_models.append( model.toROSPose3DModel() )
        elif model.geometry_type == 'POLYGON3D':
          ros.abstractions.polygon3d_models.append( model.toROSPolygon3DModel() )
        elif model.geometry_type == 'TRIANGLEMESH3D':
          ros.abstractions.trianglemesh3d_models.append( model.toROSTriangleMesh3DModel() )
        elif model.geometry_type == 'POLYGONMESH3D':
          ros.abstractions.polygonmesh3d_models.append( model.toROSPolygonMesh3DModel() )
        else:
          print 'ERROR: found unknown geometry type:', model.geometry_type

    return ros
예제 #2
0
def get_object_descriptions_list( req ):
  rospy.loginfo( "SEMAP DB SRVs: get_object_descriptions_list" )
  res = GetObjectDescriptionsListResponse()
  descriptions =[]
  try:
    ids = desc_ids_by_type(ObjectDescription, req.types).all()
    descriptions = db().query(ObjectDescription.id, ObjectDescription.type).distinct().filter(ObjectDescription.id.in_( ids ), ~ObjectDescription.type.match('absolute_description_')).all()
    for id, type in descriptions:
      desc = ROSObjectDescription()
      desc.id = id
      desc.type = type
      res.descriptions.append(desc)
    rospy.loginfo( "return proper res" )
    return res
  except exc.SQLAlchemyError, e:
      if len(descriptions) == 0:
        rospy.loginfo( "no desc found" )
      rospy.loginfo( "sql error %s" % e)
      rospy.loginfo( "got %d descriptions" % len( descriptions ) )
예제 #3
0
def get_object_descriptions_list(req):
    rospy.loginfo("SEMAP DB SRVs: get_object_descriptions_list")
    res = GetObjectDescriptionsListResponse()
    descriptions = []
    try:
        ids = desc_ids_by_type(ObjectDescription, req.types).all()
        descriptions = db().query(
            ObjectDescription.id, ObjectDescription.type).distinct().filter(
                ObjectDescription.id.in_(ids),
                ~ObjectDescription.type.match('absolute_description_')).all()
        for id, type in descriptions:
            desc = ROSObjectDescription()
            desc.id = id
            desc.type = type
            res.descriptions.append(desc)
        rospy.loginfo("return proper res")
        return res
    except exc.SQLAlchemyError, e:
        if len(descriptions) == 0:
            rospy.loginfo("no desc found")
        rospy.loginfo("sql error %s" % e)
        rospy.loginfo("got %d descriptions" % len(descriptions))
예제 #4
0
def get_object_descriptions_list(req):
    rospy.loginfo("SpatialDB SRVs: get_object_descriptions_list")
    res = GetObjectDescriptionsListResponse()
    rospy.loginfo("before SpatialDB SRVs: get_object_descriptions_list")
    descriptions =[]
    #import logging
    try:
      descriptions = db().query(ObjectDescription.id, ObjectDescription.type).all()

      for id, type in descriptions:
        desc = ROSObjectDescription()
        desc.id = id
        desc.type = type
        res.descriptions.append(desc)

      rospy.loginfo("return proper res")
      return res

    except exc.SQLAlchemyError, e:
        if len(descriptions) == 0:
          rospy.loginfo("no desc found")
        rospy.loginfo("sql error %s" % e)
        rospy.loginfo('got %d descriptions' % len(descriptions))
예제 #5
0
    def toROS(self):
        ros = ROSObjectDescription()
        ros.id = self.id
        ros.type = str(self.type)

        if self.geometries:
            for model in self.geometries:
                if model.geometry_type == 'POINT2D':
                    ros.geometries.point2d_models.append(
                        model.toROSPoint2DModel())
                elif model.geometry_type == 'POSE2D':
                    ros.geometries.pose2d_models.append(
                        model.toROSPose2DModel())
                elif model.geometry_type == 'POLYGON2D':
                    ros.geometries.polygon2d_models.append(
                        model.toROSPolygon2DModel())
                elif model.geometry_type == 'POINT3D':
                    ros.geometries.point3d_models.append(
                        model.toROSPoint3DModel())
                elif model.geometry_type == 'POSE3D':
                    ros.geometries.pose3d_models.append(
                        model.toROSPose3DModel())
                elif model.geometry_type == 'POLYGON3D':
                    ros.geometries.polygon3d_models.append(
                        model.toROSPolygon3DModel())
                elif model.geometry_type == 'TRIANGLEMESH3D':
                    ros.geometries.trianglemesh3d_models.append(
                        model.toROSTriangleMesh3DModel())
                elif model.geometry_type == 'POLYGONMESH3D':
                    ros.geometries.polygonmesh3d_models.append(
                        model.toROSPolygonMesh3DModel())
                else:
                    print 'ERROR: found unknown geometry type:', model.geometry_type

        if self.abstractions:
            for model in self.abstractions:
                if model.geometry_type == 'POINT2D':
                    ros.abstractions.point2d_models.append(
                        model.toROSPoint2DModel())
                elif model.geometry_type == 'POSE2D':
                    ros.abstractions.pose2d_models.append(
                        model.toROSPose2DModel())
                elif model.geometry_type == 'POLYGON2D':
                    ros.abstractions.polygon2d_models.append(
                        model.toROSPolygon2DModel())
                elif model.geometry_type == 'POINT3D':
                    ros.abstractions.point3d_models.append(
                        model.toROSPoint3DModel())
                elif model.geometry_type == 'POSE3D':
                    ros.abstractions.pose3d_models.append(
                        model.toROSPose3DModel())
                elif model.geometry_type == 'POLYGON3D':
                    ros.abstractions.polygon3d_models.append(
                        model.toROSPolygon3DModel())
                elif model.geometry_type == 'TRIANGLEMESH3D':
                    ros.abstractions.trianglemesh3d_models.append(
                        model.toROSTriangleMesh3DModel())
                elif model.geometry_type == 'POLYGONMESH3D':
                    ros.abstractions.polygonmesh3d_models.append(
                        model.toROSPolygonMesh3DModel())
                else:
                    print 'ERROR: found unknown geometry type:', model.geometry_type

        return ros