当前位置: 首页>>代码示例>>Python>>正文


Python MessageStoreProxy.insert_named方法代码示例

本文整理汇总了Python中mongodb_store.message_store.MessageStoreProxy.insert_named方法的典型用法代码示例。如果您正苦于以下问题:Python MessageStoreProxy.insert_named方法的具体用法?Python MessageStoreProxy.insert_named怎么用?Python MessageStoreProxy.insert_named使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mongodb_store.message_store.MessageStoreProxy的用法示例。


在下文中一共展示了MessageStoreProxy.insert_named方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_add_message

# 需要导入模块: from mongodb_store.message_store import MessageStoreProxy [as 别名]
# 或者: from mongodb_store.message_store.MessageStoreProxy import insert_named [as 别名]
    def test_add_message(self):
        msg_store = MessageStoreProxy()
        POSE_NAME = "__test__pose__"
        p = Pose(Point(0, 1, 2), Quaternion(0, 0, 0, 1))
      
        # insert a pose object with a name
        msg_store.insert_named(POSE_NAME, p)
 
        # get it back with a name
        stored, meta = msg_store.query_named(POSE_NAME, Pose._type)

        self.assertIsInstance(stored, Pose)
        self.assertEqual(stored.position.x, p.position.x)
        self.assertEqual(stored.position.y, p.position.y)
        self.assertEqual(stored.position.z, p.position.z)

        self.assertEqual(stored.orientation.x, p.orientation.x)
        self.assertEqual(stored.orientation.y, p.orientation.y)
        self.assertEqual(stored.orientation.z, p.orientation.z)
        self.assertEqual(stored.orientation.w, p.orientation.w)

        p.position.x = 666

        msg_store.update_named(POSE_NAME, p)

        # get it back with a name
        updated = msg_store.query_named(POSE_NAME, Pose._type)[0]

        self.assertEqual(updated.position.x, p.position.x)

        # # try to get it back with an incorrect name
        wrong_name = "thid name does not exist in the datacentre"
        none_item = msg_store.query_named(wrong_name, Pose._type)[0]
        self.assertIsNone(none_item)

        # # get all non-existant typed objects, so get an empty list back
        none_query = msg_store.query( "not my type")
        self.assertEqual(len(none_query), 0)

        # add 100 query and sort by date inserted.
        for i in range(100):
            p = Pose(Point(0, 0, 0), Quaternion(i, 0, 100, 1))
            msg_store.insert(p)
            
        result = msg_store.query(Pose._type, message_query={ 'orientation.z': {'$gt': 10} }, sort_query=[("$natural", -1)])
        self.assertEqual(len(result), 100)
        self.assertEqual(result[0][0].orientation.x, 99)
        
        # must remove the item or unittest only really valid once
        print meta["_id"]
        print str(meta["_id"])
        deleted = msg_store.delete(str(meta["_id"]))
        self.assertTrue(deleted)
开发者ID:AIRLab-POLIMI,项目名称:iDrive,代码行数:55,代码来源:test_messagestore.py

示例2: MessageStoreProxy

# 需要导入模块: from mongodb_store.message_store import MessageStoreProxy [as 别名]
# 或者: from mongodb_store.message_store.MessageStoreProxy import insert_named [as 别名]
import StringIO


if __name__ == '__main__':
    rospy.init_node("example_message_store_client")


    msg_store = MessageStoreProxy()

    p = Pose(Point(0, 1, 2), Quaternion(3, 4,  5, 6))
  
    try:


        # insert a pose object with a name, store the id from db
        p_id = msg_store.insert_named("my favourite pose", p)
 
        # you don't need a name (note that this p_id is different than one above)
        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
开发者ID:Vesperal-Hunter,项目名称:navigation_data_collecting,代码行数:33,代码来源:client.py

示例3: MessageStoreProxy

# 需要导入模块: from mongodb_store.message_store import MessageStoreProxy [as 别名]
# 或者: from mongodb_store.message_store.MessageStoreProxy import insert_named [as 别名]
import sys, os
from std_msgs.msg import String, Header, Int32
from mongodb_store.message_store import MessageStoreProxy
# from soma2_msgs.msg import SOMA2Object



if __name__ == "__main__":
    rospy.init_node('query_soma')

    # connecting
    soma_store = MessageStoreProxy(database="message_store", collection="soma_activity_ids_list")

    if len(sys.argv) > 1:
        for cnt, arg in enumerate(sys.argv):
            if cnt ==0: continue
            # print arg

            print 'Add an object ID to a msg store list: %s ' %arg
            new_obj_id = Int32(int(arg))

            # putting something in
            soma_store.insert_named("object id %s" %arg, new_obj_id)

            # # getting it back out
            # id,meta = soma_store.query_named("object id %s" %arg, Int32._type)
            # print scene, meta

    else:
        print "Requires a list of SOMA2 object IDs to add to a database"
开发者ID:ferdianjovan,项目名称:activity_analysis,代码行数:32,代码来源:add_soma_ids.py


注:本文中的mongodb_store.message_store.MessageStoreProxy.insert_named方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。