def test_setparam_service(self):
        from rosbridge_library.rosbridge_protocol import RosbridgeProtocol
        param = Param("/test_param")
        test_protocol=RosbridgeProtocol(88)

        def outgoing(message):
            print("ROSBRidge Outgoing: {}".format(message))
        
        test_protocol.outgoing=outgoing

        test_protocol.incoming(param.set_command(885))
Esempio n. 2
0
    def test_advertise_service(self):

        from rosbridge_library.rosbridge_protocol import RosbridgeProtocol
        test_protocol=RosbridgeProtocol(88)

        def outgoing(message):
            print("ROSBRidge Outgoing: {}".format(message))

            test_protocol.incoming('{"op": "service_response", "service": "/test_service", "values": {"value": "88"}, "result": true, "id": "service_request:/test_service:1"}')
        test_protocol.outgoing=outgoing        

        service = Service("/test_service",type="rosapi/GetParam")
        test_protocol.incoming(service.advertise_command())
    def test_rosbridge_false_subscription(self):
        from std_msgs.msg import String
        pub = rospy.Publisher("/test", String, queue_size=10,latch=True)
        pub.publish("dada")

        from rosbridge_library.rosbridge_protocol import RosbridgeProtocol
        test_protocol=RosbridgeProtocol(88)

        def outgoing(message):
            print("ROSBRidge Outgoing: {}".format(message))
        
        test_protocol.outgoing=outgoing

        topic=Topic("/test","sensor_msgs/Image")
        test_protocol.incoming(topic.advertise_command())
    def test_rosbridgeprotocol(self):
        from rosbridge_library.rosbridge_protocol import RosbridgeProtocol
        test_protocol=RosbridgeProtocol(88)
        
        def outgoing(message):
            print("ROSBRidge Outgoing: {}".format(message))
        
        test_protocol.outgoing=outgoing

        with open('sample_config.json', 'r') as outfile:
            sample_config = outfile.read()

        parser = ConfigParser(sample_config)
        commands = parser.parse()

        test_protocol.incoming(commands[1])
Esempio n. 5
0
    def test_scan_topic(self):
        with open('sample_scan.txt', 'r') as outfile:
            sample_scan = outfile.read()

        from rosbridge_library.rosbridge_protocol import RosbridgeProtocol
        test_protocol = RosbridgeProtocol(88)

        def outgoing(message):
            print("ROSBRidge Outgoing: {}".format(message))

        test_protocol.outgoing = outgoing

        topic = Topic("/scan", "sensor_msgs/LaserScan", latch=False)
        test_protocol.incoming(topic.advertise_command())

        test_protocol.incoming(sample_scan)
    def test_service_handler(self):
        from rosbridge_library.rosbridge_protocol import RosbridgeProtocol
        test_protocol=RosbridgeProtocol(88)

        service_handler=ServiceHandler(test_protocol)

        def outgoing(message):
            service_handler.callback(message)
            print("ROSBRidge Outgoing: {}".format(message))
        
        test_protocol.outgoing=outgoing
        

        if not rospy.has_param("/test_param"):
            rospy.set_param('/test_param', 88)
        param = Param("/test_param") 
        result = yield service_handler.execute(param.get_command())  
        print("result is {}".format(result))     
Esempio n. 7
0
def main(args=None):
    server_url = os.environ.get('ROWMA_SERVER_URL',
                                'https://rowma.moriokalab.com')
    sio.connect(server_url)

    signal.signal(signal.SIGINT, signal_handler)
    signal.pause()

    client_id_seed = 0
    protocol = RosbridgeProtocol(client_id_seed, rowma)

    protocol.outgoing = outgoing_func

    rclpy.spin(rowma)

    # Destroy the node explicitly
    # (optional - otherwise it will be done automatically
    # when the garbage collector destroys the node object)
    rowma.destroy_node()
    rclpy.shutdown()