Пример #1
0
def test():
    topic = rospy.Publisher('shifter/cmd', Shifter)
    rospy.Subscriber('shifter/state', Shifter, log_shifter_state)
    rospy.init_node('test_shifter')

    rospy.loginfo('starting shifter test')

    # initially reset shifter
    cmd = Shifter()                     # shifter message
    cmd.gear = Shifter.Park
    reset_cmd = Shifter()               # reset shifter message
    reset_cmd.gear = Shifter.Reset

    while not rospy.is_shutdown():
        if cmd.gear > Shifter.Drive:
            cmd.gear = Shifter.Park

        # shift to next gear
        topic.publish(cmd)
        log_shifter_cmd(cmd)
        cmd.gear += 1
        rospy.sleep(1.0)                # only change once a second

        # reset shifter
        topic.publish(reset_cmd)
        log_shifter_cmd(reset_cmd)
        rospy.sleep(1.0)                # only change once a second
Пример #2
0
def shift(gear):
    "shift transmission to desired gear"
    topic = rospy.Publisher('shifter/cmd', Shifter)
    rospy.Subscriber('shifter/state', Shifter, shifter_state_update)
    rospy.init_node('shift')

    rospy.loginfo('Shifting transmission into ' + gear_name)

    # initially reset shifter
    cmd = Shifter()                     # shifter message
    cmd.gear = gear
    log_shifter_cmd(cmd)
    topic.publish(cmd)

    # The Arens Controls hardware mechanism requires holding the shift
    # relay on for one second before resetting it.
    rospy.sleep(1.0)                    # wait a second

    # TODO: Make sure the shift actually occurred before continuing.
    # The command could possibly have been lost.  This version depends
    # on the user to notice if anything went wrong.
    #
    # Moreover, this script might as well not bother to send a command
    # if the transmission was already in the desired gear.

    reset_cmd = Shifter()               # reset shifter relay message
    reset_cmd.gear = Shifter.Reset
    log_shifter_cmd(reset_cmd)
    topic.publish(reset_cmd)

    rospy.sleep(1.0)                    # wait another second

    rospy.loginfo('Finished shifting transmission')
Пример #3
0
def test():
    topic = rospy.Publisher('shifter/cmd', Shifter)
    rospy.Subscriber('shifter/state', Shifter, log_shifter_state)
    rospy.init_node('test_shifter')

    rospy.loginfo('starting shifter test')

    # initially reset shifter
    cmd = Shifter()  # shifter message
    cmd.gear = Shifter.Park
    reset_cmd = Shifter()  # reset shifter message
    reset_cmd.gear = Shifter.Reset

    while not rospy.is_shutdown():
        if cmd.gear > Shifter.Drive:
            cmd.gear = Shifter.Park

        # shift to next gear
        topic.publish(cmd)
        log_shifter_cmd(cmd)
        cmd.gear += 1
        rospy.sleep(1.0)  # only change once a second

        # reset shifter
        topic.publish(reset_cmd)
        log_shifter_cmd(reset_cmd)
        rospy.sleep(1.0)  # only change once a second
Пример #4
0
def shift(gear):
    "shift transmission to desired gear"
    topic = rospy.Publisher('shifter/cmd', Shifter)
    rospy.Subscriber('shifter/state', Shifter, shifter_state_update)
    rospy.init_node('shift')

    rospy.loginfo('Shifting transmission into ' + gear_name)

    # initially reset shifter
    cmd = Shifter()  # shifter message
    cmd.gear = gear
    log_shifter_cmd(cmd)
    topic.publish(cmd)

    # The Arens Controls hardware mechanism requires holding the shift
    # relay on for one second before resetting it.
    rospy.sleep(1.0)  # wait a second

    # TODO: Make sure the shift actually occurred before continuing.
    # The command could possibly have been lost.  This version depends
    # on the user to notice if anything went wrong.
    #
    # Moreover, this script might as well not bother to send a command
    # if the transmission was already in the desired gear.

    reset_cmd = Shifter()  # reset shifter relay message
    reset_cmd.gear = Shifter.Reset
    log_shifter_cmd(reset_cmd)
    topic.publish(reset_cmd)

    rospy.sleep(1.0)  # wait another second

    rospy.loginfo('Finished shifting transmission')