test_client.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:ros-interop 作者: mcgill-robotics 项目源码 文件源码
def test_object_image(self):
        """Tests posting telemetry data through client."""
        # Set up test data.
        url = "http://interop"
        client_args = (url, "testuser", "testpass", 1.0)
        object_id = 1

        width = 40
        height = 30
        nparr = np.random.randint(0, 256, (width, height, 3)).astype(np.uint8)

        bridge = CvBridge()
        ros_img = bridge.cv2_to_imgmsg(nparr)

        img = ObjectImageSerializer.from_msg(ros_img)

        with InteroperabilityMockServer(url) as server:
            # Setup mock server.
            server.set_root_response()
            server.set_login_response()
            server.set_post_object_image_response(object_id)
            server.set_get_object_image_response(object_id, img, "image/png")
            server.set_delete_object_image_response(object_id)

            # Connect client.
            client = InteroperabilityClient(*client_args)
            client.wait_for_server()
            client.login()
            client.post_object_image(object_id, ros_img)
            client.get_object_image(object_id)
            client.delete_object_image(object_id)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号