<s> """<STR_LIT>""" <EOL> from dronekit import connect , VehicleMode <EOL> import time <EOL> import argparse <EOL> parser = argparse . ArgumentParser ( description = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , <EOL> help = "<STR_LIT>" ) <EOL> args = parser . parse_args ( ) <EOL> connection_string = args . connect <EOL> sitl = None <EOL> if not args . connect : <EOL> print "<STR_LIT>" <EOL> from dronekit_sitl import SITL <EOL> sitl = SITL ( ) <EOL> sitl . download ( '<STR_LIT>' , '<STR_LIT>' , verbose = True ) <EOL> sitl_args = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> sitl . launch ( sitl_args , await_ready = True , restart = True ) <EOL> connection_string = '<STR_LIT>' <EOL> print "<STR_LIT>" % connection_string <EOL> vehicle = connect ( connection_string , wait_ready = True ) <EOL> vehicle . wait_ready ( '<STR_LIT>' ) <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" % vehicle . version <EOL> print "<STR_LIT>" % vehicle . version . major <EOL> print "<STR_LIT>" % vehicle . version . minor <EOL> print "<STR_LIT>" % vehicle . version . patch <EOL> print "<STR_LIT>" % vehicle . version . release_type ( ) <EOL> print "<STR_LIT>" % vehicle . version . release_version ( ) <EOL> print "<STR_LIT>" % vehicle . version . is_stable ( ) <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" % vehicle . capabilities . mission_float <EOL> print "<STR_LIT>" % vehicle . capabilities . param_float <EOL> print "<STR_LIT>" % vehicle . capabilities . mission_int <EOL> print "<STR_LIT>" % vehicle . capabilities . command_int <EOL> print "<STR_LIT>" % vehicle . capabilities . param_union <EOL> print "<STR_LIT>" % vehicle . capabilities . ftp <EOL> print "<STR_LIT>" % vehicle . capabilities . set_attitude_target <EOL> print "<STR_LIT>" % vehicle . capabilities . set_attitude_target_local_ned <EOL> print "<STR_LIT>" % vehicle . capabilities . set_altitude_target_global_int <EOL> print "<STR_LIT>" % vehicle . capabilities . terrain <EOL> print "<STR_LIT>" % vehicle . capabilities . set_actuator_target <EOL> print "<STR_LIT>" % vehicle . capabilities . flight_termination <EOL> print "<STR_LIT>" % vehicle . capabilities . mission_float <EOL> print "<STR_LIT>" % vehicle . capabilities . compass_calibration <EOL> print "<STR_LIT>" % vehicle . location . global_frame <EOL> print "<STR_LIT>" % vehicle . location . global_relative_frame <EOL> print "<STR_LIT>" % vehicle . location . local_frame <EOL> print "<STR_LIT>" % vehicle . attitude <EOL> print "<STR_LIT>" % vehicle . velocity <EOL> print "<STR_LIT>" % vehicle . gps_0 <EOL> print "<STR_LIT>" % vehicle . gimbal <EOL> print "<STR_LIT>" % vehicle . battery <EOL> print "<STR_LIT>" % vehicle . ekf_ok <EOL> print "<STR_LIT>" % vehicle . last_heartbeat <EOL> print "<STR_LIT>" % vehicle . rangefinder <EOL> print "<STR_LIT>" % vehicle . rangefinder . distance <EOL> print "<STR_LIT>" % vehicle . rangefinder . voltage <EOL> print "<STR_LIT>" % vehicle . heading <EOL> print "<STR_LIT>" % vehicle . is_armable <EOL> print "<STR_LIT>" % vehicle . system_status . state <EOL> print "<STR_LIT>" % vehicle . groundspeed <EOL> print "<STR_LIT>" % vehicle . airspeed <EOL> print "<STR_LIT>" % vehicle . mode . name <EOL> print "<STR_LIT>" % vehicle . armed <EOL> while not vehicle . home_location : <EOL> cmds = vehicle . commands <EOL> cmds . download ( ) <EOL> cmds . wait_ready ( ) <EOL> if not vehicle . home_location : <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" % vehicle . home_location <EOL> print "<STR_LIT>" <EOL> my_location_alt = vehicle . location . global_frame <EOL> my_location_alt . alt = <NUM_LIT> <EOL> vehicle . home_location = my_location_alt <EOL> print "<STR_LIT>" % vehicle . home_location <EOL> cmds = vehicle . commands <EOL> cmds . download ( ) <EOL> cmds . wait_ready ( ) <EOL> print "<STR_LIT>" % vehicle . home_location <EOL> print "<STR_LIT>" % vehicle . mode . name <EOL> vehicle . mode = VehicleMode ( "<STR_LIT>" ) <EOL> while not vehicle . mode . name == '<STR_LIT>' : <EOL> print "<STR_LIT>" <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> while not vehicle . is_armable : <EOL> print "<STR_LIT>" <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> print "<STR_LIT>" % vehicle . armed <EOL> vehicle . armed = True <EOL> while not vehicle . armed : <EOL> print "<STR_LIT>" <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> print "<STR_LIT>" % vehicle . armed <EOL> last_attitude_cache = None <EOL> def attitude_callback ( self , attr_name , value ) : <EOL> global last_attitude_cache <EOL> if value != last_attitude_cache : <EOL> print "<STR_LIT>" , value <EOL> last_attitude_cache = value <EOL> print "<STR_LIT>" <EOL> vehicle . add_attribute_listener ( '<STR_LIT>' , attitude_callback ) <EOL> print "<STR_LIT>" <EOL> time . sleep ( <NUM_LIT:2> ) <EOL> print "<STR_LIT>" <EOL> vehicle . remove_attribute_listener ( '<STR_LIT>' , attitude_callback ) <EOL> print "<STR_LIT>" <EOL> @ vehicle . on_attribute ( '<STR_LIT>' ) <EOL> def decorated_mode_callback ( self , attr_name , value ) : <EOL> print "<STR_LIT>" , value <EOL> print "<STR_LIT>" % vehicle . mode . name <EOL> vehicle . mode = VehicleMode ( "<STR_LIT>" ) <EOL> print "<STR_LIT>" <EOL> time . sleep ( <NUM_LIT:2> ) <EOL> print "<STR_LIT>" <EOL> try : <EOL> vehicle . remove_attribute_listener ( '<STR_LIT>' , decorated_mode_callback ) <EOL> except : <EOL> print "<STR_LIT>" <EOL> def wildcard_callback ( self , attr_name , value ) : <EOL> print "<STR_LIT>" % ( attr_name , value ) <EOL> print "<STR_LIT>" <EOL> vehicle . add_attribute_listener ( '<STR_LIT:*>' , wildcard_callback ) <EOL> print "<STR_LIT>" <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> print "<STR_LIT>" <EOL> vehicle . remove_attribute_listener ( '<STR_LIT:*>' , wildcard_callback ) <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" % vehicle . parameters [ '<STR_LIT>' ] <EOL> print "<STR_LIT>" <EOL> vehicle . parameters [ '<STR_LIT>' ] = <NUM_LIT:10> <EOL> print "<STR_LIT>" % vehicle . parameters [ '<STR_LIT>' ] <EOL> print "<STR_LIT>" <EOL> for key , value in vehicle . parameters . iteritems ( ) : <EOL> print "<STR_LIT>" % ( key , value ) <EOL> print "<STR_LIT>" <EOL> @ vehicle . parameters . on_attribute ( '<STR_LIT>' ) <EOL> def decorated_thr_min_callback ( self , attr_name , value ) : <EOL> print "<STR_LIT>" % ( attr_name , value ) <EOL> print "<STR_LIT>" <EOL> vehicle . parameters [ '<STR_LIT>' ] = <NUM_LIT:20> <EOL> for x in range ( <NUM_LIT:1> , <NUM_LIT:5> ) : <EOL> if vehicle . parameters [ '<STR_LIT>' ] == <NUM_LIT:20> : <EOL> break <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> print "<STR_LIT>" <EOL> def any_parameter_callback ( self , attr_name , value ) : <EOL> print "<STR_LIT>" % ( attr_name , value ) <EOL> vehicle . parameters . add_attribute_listener ( '<STR_LIT:*>' , any_parameter_callback ) <EOL> print "<STR_LIT>" <EOL> vehicle . parameters [ '<STR_LIT>' ] = <NUM_LIT> <EOL> vehicle . parameters [ '<STR_LIT>' ] = <NUM_LIT:30> <EOL> print "<STR_LIT>" <EOL> vehicle . mode = VehicleMode ( "<STR_LIT>" ) <EOL> vehicle . armed = False <EOL> vehicle . parameters [ '<STR_LIT>' ] = <NUM_LIT> <EOL> vehicle . parameters [ '<STR_LIT>' ] = <NUM_LIT> <EOL> print "<STR_LIT>" <EOL> vehicle . close ( ) <EOL> if sitl is not None : <EOL> sitl . stop ( ) <EOL> print ( "<STR_LIT>" ) </s>
