예제 #1
0
def test_byte_msg():
    msg = Byte()
    msg.data = b'\x10'

    parsed_msg = json_to_msg(msg_to_json(msg), Byte())

    assert parsed_msg.data == msg.data
예제 #2
0
def callback_enc_dx(channel):
    global dir_dx
    global tick_dx_pub
    global v_input_dx
    global v_input_sx

    if ((v_input_dx != 0) or (v_input_sx != 0)):
        enc_msg = Byte()
        enc_msg.data = dir_dx
        tick_dx_pub.publish(enc_msg)
예제 #3
0
    try:
        print(msg)
        while (1):
            key = getKey()
            if key in pinBindings.keys():
                value = pinBindings[key]

            else:
                value = 0

                if (key == '\x03'):
                    break

            packet = Byte()
            packet.data = value
            pub.publish(packet)
            packet.data = 0
            pub.publish(packet)

            print(Pots.pot1)

    except Exception as e:
        print(e)

    finally:
        packet = Byte()
        value = 0
        packet.data = value
        pub.publish(packet)
예제 #4
0
 def send_byte(self, data):
     msg = Byte()
     msg.data = data
     self.publisher_.publish(msg)
     self.get_logger().info('Publishing: "%s"' % msg.data)
예제 #5
0
        motor_rate_sub = rospy.Subscriber('/mip_rover/motors/rates', MotorRate,
                                          motor_rate_handler)
        motor_cmd_pub = rospy.Publisher('/mip_rover/motors/cmd',
                                        MotorCmd,
                                        queue_size=10)
        green_led_pub = rospy.Publisher('/mip_rover/leds/green',
                                        Byte,
                                        queue_size=10)

        rate = rospy.Rate(4)
        motor_cmd = MotorCmd()
        motor_cmd.left_motor = 0
        motor_cmd.right_motor = 0
        green_led_cmd = Byte()
        green_led_cmd.data = 0
        while not rospy.is_shutdown():
            print('{:d} {:d} {:f} {:f}'.format(motor_cmd.left_motor,
                                               motor_cmd.right_motor,
                                               current_left_motor_rate,
                                               current_right_motor_rate))
            green_led_pub.publish(green_led_cmd)
            motor_cmd.header.stamp = rospy.Time.now()
            motor_cmd_pub.publish(motor_cmd)
            motor_cmd.left_motor += 10
            motor_cmd.right_motor += 10
            green_led_cmd.data = green_led_cmd.data == 0
            if motor_cmd.left_motor > motor_cmd_scale or motor_cmd.right_motor > motor_cmd_scale:
                break
            rate.sleep()