def main(self): veh_control.connect(local_connect()) self.set_target_location(veh_control.get_location()) while(veh_control.is_connected()): location = veh_control.get_location() attitude = veh_control.get_attitude() self.refresh_simulator(location,attitude) frame = self.get_frame() cv2.imshow('frame',frame) key = cv2.waitKey(1) print key if key ==1113938: veh_control.set_velocity(2,0,0) #forward elif key == 1113940: veh_control.set_velocity(-2,0,0) #backward elif key == 1113937: veh_control.set_velocity(0,-2,0) #left elif key ==1113939: veh_control.set_velocity(0,2,0) #right elif(key == 1048690): yaw = math.degrees(attitude.yaw) #yaw left veh_control.set_yaw(yaw - 5) elif(key == 1048692): yaw = math.degrees(attitude.yaw) #yaw right veh_control.set_yaw(yaw + 5) elif(key == 1048677): veh_control.set_velocity(0,0,-2) #down elif(key == 1048689): veh_control.set_velocity(0,0,2) #up else: veh_control.set_velocity(0,0,0) #still
def main(self): veh_control.connect(local_connect()) self.set_target_location(veh_control.get_location()) while (veh_control.is_connected()): location = veh_control.get_location() attitude = veh_control.get_attitude() self.refresh_simulator(location, attitude) frame = self.get_frame() cv2.imshow('frame', frame) key = cv2.waitKey(1) print key if key == 1113938: veh_control.set_velocity(2, 0, 0) #forward elif key == 1113940: veh_control.set_velocity(-2, 0, 0) #backward elif key == 1113937: veh_control.set_velocity(0, -2, 0) #left elif key == 1113939: veh_control.set_velocity(0, 2, 0) #right elif (key == 1048690): yaw = math.degrees(attitude.yaw) #yaw left veh_control.set_yaw(yaw - 5) elif (key == 1048692): yaw = math.degrees(attitude.yaw) #yaw right veh_control.set_yaw(yaw + 5) elif (key == 1048677): veh_control.set_velocity(0, 0, -2) #down elif (key == 1048689): veh_control.set_velocity(0, 0, 2) #up else: veh_control.set_velocity(0, 0, 0) #still
def connect(self): while(veh_control.is_connected() == False): # connect to droneapi veh_control.connect(local_connect()) self.vehicle = veh_control.get_vehicle()
def connect(self): while (veh_control.is_connected() == False): # connect to droneapi veh_control.connect(local_connect()) self.vehicle = veh_control.get_vehicle()