Пример #1
0
import br_cam
from br_control import RovCon
from time import sleep

def input_speed(new_speed):
    while True:
        new_speed = raw_input('speed: ')
        new_speed = float(new_speed)
    

if __name__ == '__main__':
    try:
        # open file to save ROS server address
        # initiate rover connection and video streaming
        rover = RovCon() 
#        rover_video = br_cam.RovCam(rover.return_data())

        rospy.init_node('br_single_control')
#        distance = 0.5    # feet

        speed = 0.015
        i = 0
        while not rospy.is_shutdown(): 
            while i < 1/speed:
                rover.move_forward()
                rover.stop_tracks()
                sleep(speed) # manually given image frame rate
                i = i + 1
            i = 0
            speed = raw_input('speed: ')
import argparse
parser = argparse.ArgumentParser('br_single_control')
parser.add_argument('file', type=str, default=None,
                    help='temporary file to store server uri')
parser.add_argument('robot_address', type=str, default=None,
                    help='address of NICs connect to robots')
arg = parser.parse_args()

if __name__ == '__main__':
    try:
        #TODO: change the local host part to a normal address
        # for now the wanted address is exported manually in the
        # .bashrc file

        # initiate rover connection and video streaming
        rover = RovCon(arg.robot_address) 
        rover_video = br_cam.RovCam(rover.return_data())

        # publish robot camera data
        pub = rospy.Publisher('/output/image_raw/compressed'+ 
            arg.robot_address.split('.')[3], CompressedImage, 
            queue_size=100)
        rospy.init_node('robot'+arg.robot_address.split('.')[3])
#        distance = 0.5    # feet
#        speed = 1         # foot/sec
        # obtain published move command
        #TODO: also obtain speed and distance
        rospy.Subscriber("move", String, rover.set_move)

        # thread to run the subscriber
        from threading import Thread