本文整理汇总了Python中mongodb_store.message_store.MessageStoreProxy.update_id方法的典型用法代码示例。如果您正苦于以下问题:Python MessageStoreProxy.update_id方法的具体用法?Python MessageStoreProxy.update_id怎么用?Python MessageStoreProxy.update_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mongodb_store.message_store.MessageStoreProxy
的用法示例。
在下文中一共展示了MessageStoreProxy.update_id方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_tag_cb
# 需要导入模块: from mongodb_store.message_store import MessageStoreProxy [as 别名]
# 或者: from mongodb_store.message_store.MessageStoreProxy import update_id [as 别名]
def add_tag_cb(self, msg):
#rospy.loginfo('Adding Tag '+msg.tag+' to '+str(msg.node))
succeded = True
for j in msg.node:
msg_store = MessageStoreProxy(collection='topological_maps')
query = {"name" : j, "pointset": self.nodes.name}
query_meta = {}
query_meta["pointset"] = self.nodes.name
query_meta["map"] = self.nodes.map
#print query, query_meta
available = msg_store.query(strands_navigation_msgs.msg.TopologicalNode._type, query, query_meta)
#print len(available)
for i in available:
msgid= i[1]['_id']
if 'tag' in i[1]:
if not msg.tag in i[1]['tag']:
i[1]['tag'].append(msg.tag)
else:
a=[]
a.append(msg.tag)
i[1]['tag']=a
meta_out = str(i[1])
msg_store.update_id(msgid, i[0], i[1], upsert = False)
#print trstr
if len(available) == 0:
succeded = False
return succeded, meta_out
示例2: rm_tag_cb
# 需要导入模块: from mongodb_store.message_store import MessageStoreProxy [as 别名]
# 或者: from mongodb_store.message_store.MessageStoreProxy import update_id [as 别名]
def rm_tag_cb(self, msg):
#rospy.loginfo('Adding Tag '+msg.tag+' to '+str(msg.node))
succeded = True
for j in msg.node:
msg_store = MessageStoreProxy(collection='topological_maps')
query = {"name" : j, "pointset": self.nodes.name}
query_meta = {}
query_meta["pointset"] = self.nodes.name
query_meta["map"] = self.nodes.map
#print query, query_meta
available = msg_store.query(strands_navigation_msgs.msg.TopologicalNode._type, query, query_meta)
#print len(available)
succeded = False
for i in available:
msgid= i[1]['_id']
if 'tag' in i[1]:
if msg.tag in i[1]['tag']:
print 'removing tag'
i[1]['tag'].remove(msg.tag)
print 'new list of tags'
print i[1]['tag']
msg_store.update_id(msgid, i[0], i[1], upsert = False)
succeded = True
meta_out = str(i[1])
return succeded, meta_out
示例3: add_localise_by_topic
# 需要导入模块: from mongodb_store.message_store import MessageStoreProxy [as 别名]
# 或者: from mongodb_store.message_store.MessageStoreProxy import update_id [as 别名]
def add_localise_by_topic(tmap, node, json_str):
#print req
#data = json.loads(req.content)
#print data
msg_store = MessageStoreProxy(collection='topological_maps')
query = {"name" : node, "pointset": tmap}
query_meta = {}
#query_meta["pointset"] = tmap
#query_meta["map"] = self.nodes.map
#print query, query_meta
available = msg_store.query(strands_navigation_msgs.msg.TopologicalNode._type, query, query_meta)
#print len(available)
if len(available) != 1:
#succeded = False
print 'there are no nodes or more than 1 with that name'
else:
#succeded = True
for i in available:
if not i[0].localise_by_topic:
msgid= i[1]['_id']
i[0].localise_by_topic=json_str
#print i[0]
print "Updating %s--%s" %(i[0].pointset, i[0].name)
msg_store.update_id(msgid, i[0], i[1], upsert = False)
示例4: add_content_cb
# 需要导入模块: from mongodb_store.message_store import MessageStoreProxy [as 别名]
# 或者: from mongodb_store.message_store.MessageStoreProxy import update_id [as 别名]
def add_content_cb(self, req):
#print req
data = json.loads(req.content)
#print data
msg_store = MessageStoreProxy(collection='topological_maps')
query = {"name" : req.node, "pointset": self.nodes.name}
query_meta = {}
query_meta["pointset"] = self.nodes.name
query_meta["map"] = self.nodes.map
#print query, query_meta
available = msg_store.query(strands_navigation_msgs.msg.TopologicalNode._type, query, query_meta)
#print len(available)
if len(available) != 1:
succeded = False
print 'there are no nodes or more than 1 with that name'
else:
succeded = True
for i in available:
msgid= i[1]['_id']
if 'contains' in i[1]:
if type(data) is list :
for j in data:
if 'category' in j and 'name' in j :
i[1]['contains'].append(j)
elif type(data) is dict :
if 'category' in data and 'name' in data :
i[1]['contains'].append(data)
else:
a=[]
if type(data) is list :
for j in data:
if 'category' in j and 'name' in j :
a.append(j)
elif type(data) is dict :
if 'category' in data and 'name' in data :
a.append(data)
i[1]['contains']=a
meta_out = str(i[1])
print "Updating %s--%s" %(i[0].pointset, i[0].name)
msg_store.update_id(msgid, i[0], i[1], upsert = False)
return succeded, meta_out
示例5: check_sanity
# 需要导入模块: from mongodb_store.message_store import MessageStoreProxy [as 别名]
# 或者: from mongodb_store.message_store.MessageStoreProxy import update_id [as 别名]
def check_sanity(client):
msg_store = MessageStoreProxy(collection='topological_maps')
db=client.message_store
collection=db["topological_maps"]
available = collection.find().distinct("_meta.pointset")
print available
for point_set in available:
#get one message
#search = {"_meta.pointset": pointset}
query_meta = {}
query_meta["pointset"] = point_set
message_list = msg_store.query(TopologicalNode._type, {}, query_meta)
#points = strands_navigation_msgs.msg.TopologicalMap()
#points.name = point_set
#points.map = point_set
#points.pointset = point_set
#string last_updated
eids = []
for i in message_list:
update = False
print i[0].pointset, i[0].name, i[1]['_id']
if i[0].edges:
for j in i[0].edges :
if j.edge_id == '':
update = True
print 'needs edge id'
j.edge_id = get_edge_id(i[0].name, j.node, eids)
print 'new edge_id %s' %j.edge_id
eids.append(j.edge_id)
if j.top_vel <= 0.1 :
update = True
print 'needs top vel'
j.top_vel = 0.55
if j.map_2d == '':
update = True
print 'needs map_2d'
j.map_2d = i[0].map
if update:
msg_store.update_id(i[1]['_id'], i[0], i[1], upsert = False)
示例6: SOMAROIManager
# 需要导入模块: from mongodb_store.message_store import MessageStoreProxy [as 别名]
# 或者: from mongodb_store.message_store.MessageStoreProxy import update_id [as 别名]
#.........这里部分代码省略.........
# geospatial store
# delete old message
old_msg = self._soma_obj_msg[soma_id]
res = self._gs_store.find_one({'soma_roi_id': roi,
'soma_map': self.soma_map,
'soma_config': self.soma_conf})
if res:
_gs_id = res['_id']
self._gs_store.remove(_gs_id)
#rospy.loginfo("GS Store: deleted roi")
# add new object to geospatial store
geo_json = self.geo_json_from_soma_obj(old_msg)
if geo_json:
try:
self._gs_store.insert(geo_json)
rospy.loginfo("GS Store: updated roi (%s %s)" % (old_msg.type, old_msg.roi_id) )
except:
rospy.logerr("The polygon of %s %s is malformed (self-intersecting) => Please update geometry." % (old_msg.type, old_msg.roi_id))
def update_object(self, feedback):
rospy.loginfo("Updated marker: %s", feedback.marker_name)
_id = self._soma_obj_ids[feedback.marker_name]
msg = self._soma_obj_msg[feedback.marker_name]
new_msg = copy.deepcopy(msg)
new_msg.pose = feedback.pose
self._soma_obj_pose[feedback.marker_name] = feedback.pose
self._msg_store.update_id(_id, new_msg)
# geospatial store
# delete old message
res = self._gs_store.find_one({'soma_roi_id': new_msg.roi_id,
'soma_map': self.soma_map,
'soma_config': self.soma_conf})
if res:
_gs_id = res['_id']
self._gs_store.remove(_gs_id)
#rospy.loginfo("GS Store: deleted roi")
# add new object to geospatial store
geo_json = self.geo_json_from_soma_obj(new_msg)
if geo_json:
try:
self._gs_store.insert(geo_json)
rospy.loginfo("GS Store: updated roi (%s %s)" % (new_msg.type, new_msg.roi_id) )
except:
rospy.logerr("The polygon of %s %s is malformed (self-intersecting) => Please update geometry." % (new_msg.type, new_msg.roi_id))
def create_object_marker(self, soma_obj, roi, soma_type, pose):
# create an interactive marker for our server
int_marker = InteractiveMarker()
int_marker.header.frame_id = "map"
int_marker.name = soma_obj
int_marker.description = soma_type + ' (' + roi + ')'
int_marker.pose = pose
int_marker.pose.position.z = 0.01
marker = Marker()
marker.type = Marker.SPHERE
marker.scale.x = 0.25
示例7: SOMAManager
# 需要导入模块: from mongodb_store.message_store import MessageStoreProxy [as 别名]
# 或者: from mongodb_store.message_store.MessageStoreProxy import update_id [as 别名]
#.........这里部分代码省略.........
geo_json['loc'] = {'type': 'Point',
'coordinates': self._gs_store.coords_to_lnglat(soma_obj.pose.position.x,
soma_obj.pose.position.y)}
return geo_json
def delete_object(self, soma_id):
# geospatial store
res = self._gs_store.find_one({'soma_id': soma_id,
'soma_map': self.soma_map,
'soma_config': self.soma_conf})
if res:
_gs_id = res['_id']
self._gs_store.remove(_gs_id)
print "GS Store: deleted obj"
# message store
_id = self._soma_obj_ids[str(soma_id)]
self._msg_store.delete(str(_id))
self._server.erase(soma_id)
self._server.applyChanges()
def update_object(self, feedback):
print "Updated marker " + feedback.marker_name
_id = self._soma_obj_ids[feedback.marker_name]
msg = self._soma_obj_msg[feedback.marker_name]
new_msg = copy.deepcopy(msg)
new_msg.pose = feedback.pose
self._msg_store.update_id(_id, new_msg)
# geospatial store
# delete old message
res = self._gs_store.find_one({'soma_id': new_msg.id,
'soma_map': self.soma_map,
'soma_config': self.soma_conf})
if res:
_gs_id = res['_id']
self._gs_store.remove(_gs_id)
print "GS Store: deleted obj"
# add new object to geospatial store
self._gs_store.insert(self.geo_json_from_soma_obj(new_msg))
print "GS Store: added obj"
def create_object_marker(self, soma_obj, soma_type, pose):
# create an interactive marker for our server
int_marker = InteractiveMarker()
int_marker.header.frame_id = "map"
int_marker.name = soma_obj
int_marker.description = "id" + soma_obj
int_marker.pose = pose
int_marker.pose.position.z = 0.01
mesh_marker = Marker()
mesh_marker.type = Marker.MESH_RESOURCE
mesh_marker.scale.x = 1
mesh_marker.scale.y = 1
mesh_marker.scale.z = 1
random.seed(soma_type)
val = random.random()
示例8: SOMAROIDrawer
# 需要导入模块: from mongodb_store.message_store import MessageStoreProxy [as 别名]
# 或者: from mongodb_store.message_store.MessageStoreProxy import update_id [as 别名]
#.........这里部分代码省略.........
self._soma_obj_roi_ids[str(soma_roi_id)] = list()
self._soma_obj_markers[soma_obj.id] = dict()
#_id = self._msg_store.update_id
_id = self._msg_store.insert(soma_obj)
self._soma_obj_ids[soma_obj.id] = _id
self._soma_obj_roi_ids[soma_obj.roi_id].append(soma_obj.id)
self._soma_obj_type[soma_obj.id] = soma_type
self._soma_obj_roi[soma_obj.id] = roi_id
self._soma_obj_msg[soma_obj.id] = soma_obj
self._soma_obj_pose[soma_obj.id] = soma_obj.posearray.poses
else:
# Get the roi id
soma_roi_id = roi_id
#print roi_id," ",self.soma_map," ",self.soma_conf," ",self._soma_obj_ids['1']
#call the object with that id
res = self._msg_store.query(SOMA2ROIObject._type,message_query={'id':str(roi_id)})
#iterate through the objects. Normally there should be only 1 object returned
for o,om in res:
# print o," hi ",om
soma_obj = o
# print "Soma Object: ", soma_obj
if soma_obj:
soma_obj.posearray.poses.append(pose)
self._soma_obj_pose[soma_obj.id] = soma_obj.posearray.poses
self.insert_geo_json(soma_obj.roi_id,soma_obj)
#print soma_obj
_id = self._soma_obj_ids[soma_obj.id]
_newid = self._msg_store.update_id(_id,soma_obj)
soma_id = soma_obj.id
self._soma_obj_msg[soma_obj.id] = soma_obj
#_id = self._msg_store.update_id
#self._soma_obj_ids[soma_obj.id] = _id
#self._soma_obj_msg[soma_obj.id] = soma_obj
#self._soma_obj_roi_ids[soma_obj.roi_id].append(soma_obj.id)
#self._soma_obj_roi[soma_obj.id].append(soma_obj.roi_id)
#for pose in soma_obj.posearray.poses:
self.load_object(str(soma_id), soma_obj.roi_id, soma_type, pose)
def create_object_marker(self, soma_obj, roi, soma_type, pose,markerno):
# create an interactive marker for our server
marker = Marker()
marker.header.frame_id = "map"
#int_marker.name = soma_obj+'_'+str(markerno)
#int_marker.description = soma_type + ' (' + roi +'_'+str(markerno)+ ')'
marker.pose = pose
marker.id = markerno;
# print marker.pose
marker.pose.position.z = 0.01
#marker = Marker()
示例9:
# 需要导入模块: from mongodb_store.message_store import MessageStoreProxy [as 别名]
# 或者: from mongodb_store.message_store.MessageStoreProxy import update_id [as 别名]
p_id = msg_store.insert(p)
p_id = msg_store.insert(['test1', 'test2'])
# get it back with a name
print msg_store.query_named("my favourite pose", Pose._type)
p.position.x = 666
# update it with a name
msg_store.update_named("my favourite pose", p)
p.position.y = 2020
# update the other inserted one using the id
msg_store.update_id(p_id, p)
stored_p, meta = msg_store.query_id(p_id, Pose._type)
assert stored_p.position.x == 666
assert stored_p.position.y == 2020
print "stored object ok"
print "stored object inserted at %s (UTC rostime) by %s" % (meta['inserted_at'], meta['inserted_by'])
print "stored object last updated at %s (UTC rostime) by %s" % (meta['last_updated_at'], meta['last_updated_by'])
# some other things you can do...
# get it back with a name
print msg_store.query_named("my favourite pose", Pose._type)