def test_set_altitude(self):
     loc = Location()
     #set the default location
     self.assertEqual(loc.get_altitude(),0)
     loc.set_altitude(0)
     self.assertEqual(loc.get_altitude(),0)
     #check character -> set zero
     loc.set_altitude(CHARACTER)
     self.assertEqual(loc.get_altitude(),0)
     #check character number -> convert to the number
     loc.set_altitude(CHAR_NUMBER)
     self.assertEqual(loc.get_altitude(),float(CHAR_NUMBER))
Exemple #2
0
 def up(self,init_alt_in_meter):
     if(self.is_first_function):
         head = self.vehicle.heading/ANGLE_FIX
         self.is_first_function = False
     else:
         head= self.vehicle.heading
     loc = Location()
     loc1 = Location()
     loc.setFromVehicleLocation(self.vehicle.location.global_frame)
     loc1.setFromVehicleLocation(self.vehicle.location.global_frame)
     loc.set_altitude(loc.get_altitude()+init_alt_in_meter)
     location_global = LocationGlobal(loc.latitude,loc.longitude,loc.altitude)
     self.vehicle.simple_goto(location_global)
     while not loc1.is_right_alt(loc.altitude):
         loc1.setFromVehicleLocation(self.vehicle.location.global_frame)
         self.condition_yaw(head)
         time.sleep(DELAY)
     if init_alt_in_meter > 0:
         print "complete function up"
     else:
         print "complete function down"
    def forward(self,move_forward_in_meter):
        dest_location = Location()
        loc1 = Location()
        head = self.vehicle.heading
        loc1.setFromVehicleLocation(self.vehicle.location.global_relative_frame)
        dest_location.setFromVehicleLocation(self.vehicle.location.global_relative_frame)
        add_lat = math.sin(self.vehicle.heading)*(move_forward_in_meter/100000.0)
        add_lon = math.cos(self.vehicle.heading)*(move_forward_in_meter/100000.0)
        dest_location.set_latitude(round(dest_location.get_latitude()+ add_lat,7))
        dest_location.set_longitude(round(dest_location.get_longitude()+add_lon,7))
        location_global = LocationGlobalRelative(dest_location.get_latitude(),dest_location.get_longitude(),dest_location.get_altitude())
        self.vehicle.simple_goto(location_global,groundspeed=100)
        while True:
            time.sleep(DELAY)
            if abs(self.vehicle.location.global_relative_frame.lat-location_global.lat) < 0.0000001 and abs(self.vehicle.location.global_relative_frame.lon-location_global.lon) < 0.000001  :
                break;
            self.condition_yaw(head)

        if move_forward_in_meter > 0:
            print "complete function forward\n"
        else :
            print "complete function backwards\n"