idx int64 0 252k | question stringlengths 48 5.28k | target stringlengths 5 1.23k |
|---|---|---|
229,900 | def add_hook ( self , name , callback , prio = 0 ) : hook_list = self . _hooks . get ( name , [ ] ) add = ( lambda * args , ** kwargs : self . _exception_free_callback ( callback , * args , ** kwargs ) ) , - prio pos = bisect . bisect_right ( list ( x [ 1 ] for x in hook_list ) , - prio ) hook_list [ pos : pos ] = [ ad... | Add a new hook that can be called with the call_hook function . prio is the priority . Higher priority hooks are called before lower priority ones . This function does not enforce a particular order between hooks with the same priorities . |
229,901 | def input_is_consistent ( self , task_input , default_allowed_extension , default_max_size ) : for problem in self . _problems : if not problem . input_is_consistent ( task_input , default_allowed_extension , default_max_size ) : return False return True | Check if an input for a task is consistent . Return true if this is case false else |
229,902 | def get_limits ( self ) : vals = self . _hook_manager . call_hook ( 'task_limits' , course = self . get_course ( ) , task = self , default = self . _limits ) return vals [ 0 ] if len ( vals ) else self . _limits | Return the limits of this task |
229,903 | def allow_network_access_grading ( self ) : vals = self . _hook_manager . call_hook ( 'task_network_grading' , course = self . get_course ( ) , task = self , default = self . _network_grading ) return vals [ 0 ] if len ( vals ) else self . _network_grading | Return True if the grading container should have access to the network |
229,904 | def _create_task_problem ( self , problemid , problem_content , task_problem_types ) : if not id_checker ( problemid ) : raise Exception ( "Invalid problem _id: " + problemid ) if problem_content . get ( 'type' , "" ) not in task_problem_types : raise Exception ( "Invalid type for problem " + problemid ) return task_pr... | Creates a new instance of the right class for a given problem . |
229,905 | def course_menu ( course , template_helper ) : scoreboards = course . get_descriptor ( ) . get ( 'scoreboard' , [ ] ) if scoreboards != [ ] : return str ( template_helper . get_custom_renderer ( 'frontend/plugins/scoreboard' , layout = False ) . course_menu ( course ) ) else : return None | Displays the link to the scoreboards on the course page if the plugin is activated for this course |
229,906 | def task_menu ( course , task , template_helper ) : scoreboards = course . get_descriptor ( ) . get ( 'scoreboard' , [ ] ) try : tolink = [ ] for sid , scoreboard in enumerate ( scoreboards ) : if task . get_id ( ) in scoreboard [ "content" ] : tolink . append ( ( sid , scoreboard [ "name" ] ) ) if tolink : return str ... | Displays the link to the scoreboards on the task page if the plugin is activated for this course and the task is used in scoreboards |
229,907 | def get_user_lists ( self , course , classroomid ) : tutor_list = course . get_staff ( ) student_list = list ( self . database . classrooms . aggregate ( [ { "$match" : { "_id" : ObjectId ( classroomid ) } } , { "$unwind" : "$students" } , { "$project" : { "students" : 1 , "grouped" : { "$anyElementTrue" : { "$map" : {... | Get the available student and tutor lists for classroom edition |
229,908 | def update_classroom ( self , course , classroomid , new_data ) : student_list , tutor_list , other_students , _ = self . get_user_lists ( course , classroomid ) new_data [ "tutors" ] = [ tutor for tutor in map ( str . strip , new_data [ "tutors" ] ) if tutor in tutor_list ] students , groups , errored_students = [ ] ,... | Update classroom and returns a list of errored students |
229,909 | def parse ( self , debug = False ) : if self . _parsed is None : try : if self . _mode == "html" : self . _parsed = self . html ( self . _content , self . _show_everything , self . _translation ) else : self . _parsed = self . rst ( self . _content , self . _show_everything , self . _translation , debug = debug ) excep... | Returns parsed text |
229,910 | def POST_AUTH ( self , courseid , taskid ) : if not id_checker ( taskid ) : raise Exception ( "Invalid task id" ) self . get_course_and_check_rights ( courseid , allow_all_staff = False ) request = web . input ( file = { } ) if request . get ( "action" ) == "upload" and request . get ( 'path' ) is not None and request ... | Upload or modify a file |
229,911 | def show_tab_file ( self , courseid , taskid , error = None ) : return self . template_helper . get_renderer ( False ) . course_admin . edit_tabs . files ( self . course_factory . get_course ( courseid ) , taskid , self . get_task_filelist ( self . task_factory , courseid , taskid ) , error ) | Return the file tab |
229,912 | def action_edit ( self , courseid , taskid , path ) : wanted_path = self . verify_path ( courseid , taskid , path ) if wanted_path is None : return "Internal error" try : content = self . task_factory . get_task_fs ( courseid , taskid ) . get ( wanted_path ) . decode ( "utf-8" ) return json . dumps ( { "content" : cont... | Edit a file |
229,913 | def action_edit_save ( self , courseid , taskid , path , content ) : wanted_path = self . verify_path ( courseid , taskid , path ) if wanted_path is None : return json . dumps ( { "error" : True } ) try : self . task_factory . get_task_fs ( courseid , taskid ) . put ( wanted_path , content . encode ( "utf-8" ) ) return... | Save an edited file |
229,914 | def action_download ( self , courseid , taskid , path ) : wanted_path = self . verify_path ( courseid , taskid , path ) if wanted_path is None : raise web . notfound ( ) task_fs = self . task_factory . get_task_fs ( courseid , taskid ) ( method , mimetype_or_none , file_or_url ) = task_fs . distribute ( wanted_path ) i... | Download a file or a directory |
229,915 | def write_json_or_yaml ( file_path , content ) : with codecs . open ( file_path , "w" , "utf-8" ) as f : f . write ( get_json_or_yaml ( file_path , content ) ) | Write JSON or YAML depending on the file extension . |
229,916 | def get_json_or_yaml ( file_path , content ) : if os . path . splitext ( file_path ) [ 1 ] == ".json" : return json . dumps ( content , sort_keys = False , indent = 4 , separators = ( ',' , ': ' ) ) else : return inginious . common . custom_yaml . dump ( content ) | Generate JSON or YAML depending on the file extension . |
229,917 | def _set_session ( self , username , realname , email , language ) : self . _session . loggedin = True self . _session . email = email self . _session . username = username self . _session . realname = realname self . _session . language = language self . _session . token = None if "lti" not in self . _session : self .... | Init the session . Preserves potential LTI information . |
229,918 | def _destroy_session ( self ) : self . _session . loggedin = False self . _session . email = None self . _session . username = None self . _session . realname = None self . _session . token = None self . _session . lti = None | Destroy the session |
229,919 | def create_lti_session ( self , user_id , roles , realname , email , course_id , task_id , consumer_key , outcome_service_url , outcome_result_id , tool_name , tool_desc , tool_url , context_title , context_label ) : self . _destroy_session ( ) self . _session . load ( '' ) session_id = self . _session . session_id sel... | Creates an LTI cookieless session . Returns the new session id |
229,920 | def user_saw_task ( self , username , courseid , taskid ) : self . _database . user_tasks . update ( { "username" : username , "courseid" : courseid , "taskid" : taskid } , { "$setOnInsert" : { "username" : username , "courseid" : courseid , "taskid" : taskid , "tried" : 0 , "succeeded" : False , "grade" : 0.0 , "submi... | Set in the database that the user has viewed this task |
229,921 | def update_user_stats ( self , username , task , submission , result_str , grade , state , newsub ) : self . user_saw_task ( username , submission [ "courseid" ] , submission [ "taskid" ] ) if newsub : old_submission = self . _database . user_tasks . find_one_and_update ( { "username" : username , "courseid" : submissi... | Update stats with a new submission |
229,922 | def get_course_aggregations ( self , course ) : return natsorted ( list ( self . _database . aggregations . find ( { "courseid" : course . get_id ( ) } ) ) , key = lambda x : x [ "description" ] ) | Returns a list of the course aggregations |
229,923 | def get_accessible_time ( self , plugin_override = True ) : vals = self . _hook_manager . call_hook ( 'task_accessibility' , course = self . get_course ( ) , task = self , default = self . _accessible ) return vals [ 0 ] if len ( vals ) and plugin_override else self . _accessible | Get the accessible time of this task |
229,924 | def get_deadline ( self ) : if self . get_accessible_time ( ) . is_always_accessible ( ) : return _ ( "No deadline" ) elif self . get_accessible_time ( ) . is_never_accessible ( ) : return _ ( "It's too late" ) else : return self . get_accessible_time ( ) . get_soft_end_date ( ) . strftime ( "%d/%m/%Y %H:%M:%S" ) | Returns a string containing the deadline for this task |
229,925 | def get_authors ( self , language ) : return self . gettext ( language , self . _author ) if self . _author else "" | Return the list of this task s authors |
229,926 | def adapt_input_for_backend ( self , input_data ) : for problem in self . _problems : input_data = problem . adapt_input_for_backend ( input_data ) return input_data | Adapt the input from web . py for the inginious . backend |
229,927 | def get_users ( self , course ) : users = OrderedDict ( sorted ( list ( self . user_manager . get_users_info ( self . user_manager . get_course_registered_users ( course ) ) . items ( ) ) , key = lambda k : k [ 1 ] [ 0 ] if k [ 1 ] is not None else "" ) ) return users | Returns a sorted list of users |
229,928 | def get_course ( self , courseid ) : try : course = self . course_factory . get_course ( courseid ) except : raise web . notfound ( ) return course | Return the course |
229,929 | def show_page ( self , course ) : username = self . user_manager . session_username ( ) if not self . user_manager . course_is_open_to_user ( course , lti = False ) : return self . template_helper . get_renderer ( ) . course_unavailable ( ) else : tasks = course . get_tasks ( ) last_submissions = self . submission_mana... | Prepares and shows the course page |
229,930 | def mavparms ( logfile ) : mlog = mavutil . mavlink_connection ( filename ) while True : try : m = mlog . recv_match ( type = [ 'PARAM_VALUE' , 'PARM' ] ) if m is None : return except Exception : return if m . get_type ( ) == 'PARAM_VALUE' : pname = str ( m . param_id ) . strip ( ) value = m . param_value else : pname ... | extract mavlink parameters |
229,931 | def send ( self , mavmsg , force_mavlink1 = False ) : buf = mavmsg . pack ( self , force_mavlink1 = force_mavlink1 ) self . file . write ( buf ) self . seq = ( self . seq + 1 ) % 256 self . total_packets_sent += 1 self . total_bytes_sent += len ( buf ) if self . send_callback : self . send_callback ( mavmsg , * self . ... | send a MAVLink message |
229,932 | def bytes_needed ( self ) : if self . native : ret = self . native . expected_length - self . buf_len ( ) else : ret = self . expected_length - self . buf_len ( ) if ret <= 0 : return 1 return ret | return number of bytes needed for next parsing stage |
229,933 | def __callbacks ( self , msg ) : if self . callback : self . callback ( msg , * self . callback_args , ** self . callback_kwargs ) | this method exists only to make profiling results easier to read |
229,934 | def parse_char ( self , c ) : self . buf . extend ( c ) self . total_bytes_received += len ( c ) if self . native : if native_testing : self . test_buf . extend ( c ) m = self . __parse_char_native ( self . test_buf ) m2 = self . __parse_char_legacy ( ) if m2 != m : print ( "Native: %s\nLegacy: %s\n" % ( m , m2 ) ) rai... | input some data bytes possibly returning a new message |
229,935 | def parse_buffer ( self , s ) : m = self . parse_char ( s ) if m is None : return None ret = [ m ] while True : m = self . parse_char ( "" ) if m is None : return ret ret . append ( m ) return ret | input some data bytes possibly returning a list of new messages |
229,936 | def check_signature ( self , msgbuf , srcSystem , srcComponent ) : if isinstance ( msgbuf , array . array ) : msgbuf = msgbuf . tostring ( ) timestamp_buf = msgbuf [ - 12 : - 6 ] link_id = msgbuf [ - 13 ] ( tlow , thigh ) = struct . unpack ( '<IH' , timestamp_buf ) timestamp = tlow + ( thigh << 32 ) stream_key = ( link... | check signature on incoming message |
229,937 | def flexifunction_set_send ( self , target_system , target_component , force_mavlink1 = False ) : return self . send ( self . flexifunction_set_encode ( target_system , target_component ) , force_mavlink1 = force_mavlink1 ) | Depreciated but used as a compiler flag . Do not remove |
229,938 | def system_time_send ( self , time_unix_usec , time_boot_ms , force_mavlink1 = False ) : return self . send ( self . system_time_encode ( time_unix_usec , time_boot_ms ) , force_mavlink1 = force_mavlink1 ) | The system time is the time of the master clock typically the computer clock of the main onboard computer . |
229,939 | def set_mode_send ( self , target_system , base_mode , custom_mode , force_mavlink1 = False ) : return self . send ( self . set_mode_encode ( target_system , base_mode , custom_mode ) , force_mavlink1 = force_mavlink1 ) | THIS INTERFACE IS DEPRECATED . USE COMMAND_LONG with MAV_CMD_DO_SET_MODE INSTEAD . Set the system mode as defined by enum MAV_MODE . There is no target component id as the mode is by definition for the overall aircraft not only for one component . |
229,940 | def param_request_list_send ( self , target_system , target_component , force_mavlink1 = False ) : return self . send ( self . param_request_list_encode ( target_system , target_component ) , force_mavlink1 = force_mavlink1 ) | Request all parameters of this component . After this request all parameters are emitted . |
229,941 | def mission_current_send ( self , seq , force_mavlink1 = False ) : return self . send ( self . mission_current_encode ( seq ) , force_mavlink1 = force_mavlink1 ) | Message that announces the sequence number of the current active mission item . The MAV will fly towards this mission item . |
229,942 | def mission_count_send ( self , target_system , target_component , count , force_mavlink1 = False ) : return self . send ( self . mission_count_encode ( target_system , target_component , count ) , force_mavlink1 = force_mavlink1 ) | This message is emitted as response to MISSION_REQUEST_LIST by the MAV and to initiate a write transaction . The GCS can then request the individual mission item based on the knowledge of the total number of MISSIONs . |
229,943 | def mission_clear_all_send ( self , target_system , target_component , force_mavlink1 = False ) : return self . send ( self . mission_clear_all_encode ( target_system , target_component ) , force_mavlink1 = force_mavlink1 ) | Delete all mission items at once . |
229,944 | def data_stream_send ( self , stream_id , message_rate , on_off , force_mavlink1 = False ) : return self . send ( self . data_stream_encode ( stream_id , message_rate , on_off ) , force_mavlink1 = force_mavlink1 ) | THIS INTERFACE IS DEPRECATED . USE MESSAGE_INTERVAL INSTEAD . |
229,945 | def command_ack_send ( self , command , result , force_mavlink1 = False ) : return self . send ( self . command_ack_encode ( command , result ) , force_mavlink1 = force_mavlink1 ) | Report status of a command . Includes feedback wether the command was executed . |
229,946 | def timesync_send ( self , tc1 , ts1 , force_mavlink1 = False ) : return self . send ( self . timesync_encode ( tc1 , ts1 ) , force_mavlink1 = force_mavlink1 ) | Time synchronization message . |
229,947 | def camera_trigger_send ( self , time_usec , seq , force_mavlink1 = False ) : return self . send ( self . camera_trigger_encode ( time_usec , seq ) , force_mavlink1 = force_mavlink1 ) | Camera - IMU triggering and synchronisation message . |
229,948 | def log_erase_send ( self , target_system , target_component , force_mavlink1 = False ) : return self . send ( self . log_erase_encode ( target_system , target_component ) , force_mavlink1 = force_mavlink1 ) | Erase all logs |
229,949 | def log_request_end_send ( self , target_system , target_component , force_mavlink1 = False ) : return self . send ( self . log_request_end_encode ( target_system , target_component ) , force_mavlink1 = force_mavlink1 ) | Stop log transfer and resume normal logging |
229,950 | def power_status_send ( self , Vcc , Vservo , flags , force_mavlink1 = False ) : return self . send ( self . power_status_encode ( Vcc , Vservo , flags ) , force_mavlink1 = force_mavlink1 ) | Power supply status |
229,951 | def terrain_check_send ( self , lat , lon , force_mavlink1 = False ) : return self . send ( self . terrain_check_encode ( lat , lon ) , force_mavlink1 = force_mavlink1 ) | Request that the vehicle report terrain height at the given location . Used by GCS to check if vehicle has all terrain data needed for a mission . |
229,952 | def gps_input_encode ( self , time_usec , gps_id , ignore_flags , time_week_ms , time_week , fix_type , lat , lon , alt , hdop , vdop , vn , ve , vd , speed_accuracy , horiz_accuracy , vert_accuracy , satellites_visible ) : return MAVLink_gps_input_message ( time_usec , gps_id , ignore_flags , time_week_ms , time_week ... | GPS sensor input message . This is a raw sensor value sent by the GPS . This is NOT the global position estimate of the sytem . |
229,953 | def message_interval_send ( self , message_id , interval_us , force_mavlink1 = False ) : return self . send ( self . message_interval_encode ( message_id , interval_us ) , force_mavlink1 = force_mavlink1 ) | This interface replaces DATA_STREAM |
229,954 | def extended_sys_state_send ( self , vtol_state , landed_state , force_mavlink1 = False ) : return self . send ( self . extended_sys_state_encode ( vtol_state , landed_state ) , force_mavlink1 = force_mavlink1 ) | Provides state for additional features |
229,955 | def named_value_float_send ( self , time_boot_ms , name , value , force_mavlink1 = False ) : return self . send ( self . named_value_float_encode ( time_boot_ms , name , value ) , force_mavlink1 = force_mavlink1 ) | Send a key - value pair as float . The use of this message is discouraged for normal packets but a quite efficient way for testing new messages and getting experimental debug output . |
229,956 | def named_value_int_send ( self , time_boot_ms , name , value , force_mavlink1 = False ) : return self . send ( self . named_value_int_encode ( time_boot_ms , name , value ) , force_mavlink1 = force_mavlink1 ) | Send a key - value pair as integer . The use of this message is discouraged for normal packets but a quite efficient way for testing new messages and getting experimental debug output . |
229,957 | def debug_send ( self , time_boot_ms , ind , value , force_mavlink1 = False ) : return self . send ( self . debug_encode ( time_boot_ms , ind , value ) , force_mavlink1 = force_mavlink1 ) | Send a debug value . The index is used to discriminate between values . These values show up in the plot of QGroundControl as DEBUG N . |
229,958 | def sendVX ( self , vx ) : self . lock . acquire ( ) self . data . vx = vx self . lock . release ( ) | Sends VX velocity . |
229,959 | def sendVY ( self , vy ) : self . lock . acquire ( ) self . data . vy = vy self . lock . release ( ) | Sends VY velocity . |
229,960 | def sendAZ ( self , az ) : self . lock . acquire ( ) self . data . az = az self . lock . release ( ) | Sends AZ velocity . |
229,961 | def bumperEvent2BumperData ( event ) : bump = BumperData ( ) bump . state = event . state bump . bumper = event . bumper return bump | Translates from ROS BumperScan to JderobotTypes BumperData . |
229,962 | def __callback ( self , event ) : bump = bumperEvent2BumperData ( event ) if bump . state == 1 : self . lock . acquire ( ) self . time = current_milli_time ( ) self . data = bump self . lock . release ( ) | Callback function to receive and save Bumper Scans . |
229,963 | def getBumperData ( self ) : self . lock . acquire ( ) t = current_milli_time ( ) if ( t - self . time ) > 500 : self . data . state = 0 bump = self . data self . lock . release ( ) return bump | Returns last BumperData . |
229,964 | def cmd_bat ( self , args ) : print ( "Flight battery: %u%%" % self . battery_level ) if self . settings . numcells != 0 : print ( "%.2f V/cell for %u cells - approx %u%%" % ( self . per_cell , self . settings . numcells , self . vcell_to_battery_percent ( self . per_cell ) ) ) | show battery levels |
229,965 | def battery_update ( self , SYS_STATUS ) : self . battery_level = SYS_STATUS . battery_remaining self . voltage_level = SYS_STATUS . voltage_battery self . current_battery = SYS_STATUS . current_battery if self . settings . numcells != 0 : self . per_cell = ( self . voltage_level * 0.001 ) / self . settings . numcells | update battery level |
229,966 | def cmd_accelcal ( self , args ) : mav = self . master mav . mav . command_long_send ( mav . target_system , mav . target_component , mavutil . mavlink . MAV_CMD_PREFLIGHT_CALIBRATION , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 ) self . accelcal_count = 0 self . accelcal_wait_enter = False | do a full 3D accel calibration |
229,967 | def cmd_gyrocal ( self , args ) : mav = self . master mav . mav . command_long_send ( mav . target_system , mav . target_component , mavutil . mavlink . MAV_CMD_PREFLIGHT_CALIBRATION , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 ) | do a full gyro calibration |
229,968 | def cmd_magcal ( self , args ) : if len ( args ) < 1 : print ( "Usage: magcal <start|accept|cancel>" ) return if args [ 0 ] == 'start' : self . master . mav . command_long_send ( self . settings . target_system , 0 , mavutil . mavlink . MAV_CMD_DO_START_MAG_CAL , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 ) elif args [ 0 ] == 'acce... | control magnetometer calibration |
229,969 | def set_fence_enabled ( self , do_enable ) : self . master . mav . command_long_send ( self . target_system , self . target_component , mavutil . mavlink . MAV_CMD_DO_FENCE_ENABLE , 0 , do_enable , 0 , 0 , 0 , 0 , 0 , 0 ) | Enable or disable fence |
229,970 | def cmd_fence_move ( self , args ) : if len ( args ) < 1 : print ( "Usage: fence move FENCEPOINTNUM" ) return if not self . have_list : print ( "Please list fence points first" ) return idx = int ( args [ 0 ] ) if idx <= 0 or idx > self . fenceloader . count ( ) : print ( "Invalid fence point number %u" % idx ) return ... | handle fencepoint move |
229,971 | def cmd_fence_remove ( self , args ) : if len ( args ) < 1 : print ( "Usage: fence remove FENCEPOINTNUM" ) return if not self . have_list : print ( "Please list fence points first" ) return idx = int ( args [ 0 ] ) if idx <= 0 or idx > self . fenceloader . count ( ) : print ( "Invalid fence point number %u" % idx ) ret... | handle fencepoint remove |
229,972 | def send_fence ( self ) : self . fenceloader . target_system = self . target_system self . fenceloader . target_component = self . target_component self . fenceloader . reindex ( ) action = self . get_mav_param ( 'FENCE_ACTION' , mavutil . mavlink . FENCE_ACTION_NONE ) self . param_set ( 'FENCE_ACTION' , mavutil . mavl... | send fence points from fenceloader |
229,973 | def fetch_fence_point ( self , i ) : self . master . mav . fence_fetch_point_send ( self . target_system , self . target_component , i ) tstart = time . time ( ) p = None while time . time ( ) - tstart < 3 : p = self . master . recv_match ( type = 'FENCE_POINT' , blocking = False ) if p is not None : break time . sleep... | fetch one fence point |
229,974 | def fence_draw_callback ( self , points ) : self . fenceloader . clear ( ) if len ( points ) < 3 : return self . fenceloader . target_system = self . target_system self . fenceloader . target_component = self . target_component bounds = mp_util . polygon_bounds ( points ) ( lat , lon , width , height ) = bounds center ... | callback from drawing a fence |
229,975 | def add_menu ( self , menu ) : self . menu . add ( menu ) self . mpstate . console . set_menu ( self . menu , self . menu_callback ) | add a new menu |
229,976 | def estimated_time_remaining ( self , lat , lon , wpnum , speed ) : idx = wpnum if wpnum >= self . module ( 'wp' ) . wploader . count ( ) : return 0 distance = 0 done = set ( ) while idx < self . module ( 'wp' ) . wploader . count ( ) : if idx in done : break done . add ( idx ) w = self . module ( 'wp' ) . wploader . w... | estimate time remaining in mission in seconds |
229,977 | def angle ( self , v ) : return acos ( ( self * v ) / ( self . length ( ) * v . length ( ) ) ) | return the angle between this vector and another vector |
229,978 | def from_euler ( self , roll , pitch , yaw ) : cp = cos ( pitch ) sp = sin ( pitch ) sr = sin ( roll ) cr = cos ( roll ) sy = sin ( yaw ) cy = cos ( yaw ) self . a . x = cp * cy self . a . y = ( sr * sp * cy ) - ( cr * sy ) self . a . z = ( cr * sp * cy ) + ( sr * sy ) self . b . x = cp * sy self . b . y = ( sr * sp * ... | fill the matrix from Euler angles in radians |
229,979 | def from_euler312 ( self , roll , pitch , yaw ) : c3 = cos ( pitch ) s3 = sin ( pitch ) s2 = sin ( roll ) c2 = cos ( roll ) s1 = sin ( yaw ) c1 = cos ( yaw ) self . a . x = c1 * c3 - s1 * s2 * s3 self . b . y = c1 * c2 self . c . z = c3 * c2 self . a . y = - c2 * s1 self . a . z = s3 * c1 + c3 * s2 * s1 self . b . x = ... | fill the matrix from Euler angles in radians in 312 convention |
229,980 | def rotate ( self , g ) : temp_matrix = Matrix3 ( ) a = self . a b = self . b c = self . c temp_matrix . a . x = a . y * g . z - a . z * g . y temp_matrix . a . y = a . z * g . x - a . x * g . z temp_matrix . a . z = a . x * g . y - a . y * g . x temp_matrix . b . x = b . y * g . z - b . z * g . y temp_matrix . b . y =... | rotate the matrix by a given amount on 3 axes |
229,981 | def normalize ( self ) : error = self . a * self . b t0 = self . a - ( self . b * ( 0.5 * error ) ) t1 = self . b - ( self . a * ( 0.5 * error ) ) t2 = t0 % t1 self . a = t0 * ( 1.0 / t0 . length ( ) ) self . b = t1 * ( 1.0 / t1 . length ( ) ) self . c = t2 * ( 1.0 / t2 . length ( ) ) | re - normalise a rotation matrix |
229,982 | def trace ( self ) : return self . a . x + self . b . y + self . c . z | the trace of the matrix |
229,983 | def from_axis_angle ( self , axis , angle ) : ux = axis . x uy = axis . y uz = axis . z ct = cos ( angle ) st = sin ( angle ) self . a . x = ct + ( 1 - ct ) * ux ** 2 self . a . y = ux * uy * ( 1 - ct ) - uz * st self . a . z = ux * uz * ( 1 - ct ) + uy * st self . b . x = uy * ux * ( 1 - ct ) + uz * st self . b . y = ... | create a rotation matrix from axis and angle |
229,984 | def from_two_vectors ( self , vec1 , vec2 ) : angle = vec1 . angle ( vec2 ) cross = vec1 % vec2 if cross . length ( ) == 0 : return self . from_euler ( 0 , 0 , angle ) cross . normalize ( ) return self . from_axis_angle ( cross , angle ) | get a rotation matrix from two vectors . This returns a rotation matrix which when applied to vec1 will produce a vector pointing in the same direction as vec2 |
229,985 | def plane_intersection ( self , plane , forward_only = False ) : l_dot_n = self . vector * plane . normal if l_dot_n == 0.0 : return None d = ( ( plane . point - self . point ) * plane . normal ) / l_dot_n if forward_only and d < 0 : return None return ( self . vector * d ) + self . point | return point where line intersects with a plane |
229,986 | def getRgbd ( self ) : img = Rgb ( ) if self . hasproxy ( ) : self . lock . acquire ( ) img = self . image self . lock . release ( ) return img | Returns last Rgbd . |
229,987 | def add_mavlink_packet ( self , msg ) : mtype = msg . get_type ( ) if mtype not in self . msg_types : return for i in range ( len ( self . fields ) ) : if mtype not in self . field_types [ i ] : continue f = self . fields [ i ] self . values [ i ] = mavutil . evaluate_expression ( f , self . state . master . messages )... | add data to the graph |
229,988 | def generate ( basename , xml ) : if basename . endswith ( '.js' ) : filename = basename else : filename = basename + '.js' msgs = [ ] enums = [ ] filelist = [ ] for x in xml : msgs . extend ( x . message ) enums . extend ( x . enum ) filelist . append ( os . path . basename ( x . filename ) ) for m in msgs : if xml [ ... | generate complete javascript implementation |
229,989 | def flight_modes ( logfile ) : print ( "Processing log %s" % filename ) mlog = mavutil . mavlink_connection ( filename ) mode = "" previous_mode = "" mode_start_timestamp = - 1 time_in_mode = { } previous_percent = - 1 seconds_per_percent = - 1 filesize = os . path . getsize ( filename ) while True : m = mlog . recv_ma... | show flight modes for a log file |
229,990 | def have_graph ( name ) : for g in mestate . graphs : if g . name == name : return True return False | return true if we have a graph of the given name |
229,991 | def expression_ok ( expression ) : expression_ok = True fields = expression . split ( ) for f in fields : try : if f . endswith ( ':2' ) : f = f [ : - 2 ] if mavutil . evaluate_expression ( f , mestate . status . msgs ) is None : expression_ok = False except Exception : expression_ok = False break return expression_ok | return True if an expression is OK with current messages |
229,992 | def load_graph_xml ( xml , filename , load_all = False ) : ret = [ ] try : root = objectify . fromstring ( xml ) except Exception : return [ ] if root . tag != 'graphs' : return [ ] if not hasattr ( root , 'graph' ) : return [ ] for g in root . graph : name = g . attrib [ 'name' ] expressions = [ e . text for e in g . ... | load a graph from one xml string |
229,993 | def cmd_condition ( args ) : if len ( args ) == 0 : print ( "condition is: %s" % mestate . settings . condition ) return mestate . settings . condition = ' ' . join ( args ) if len ( mestate . settings . condition ) == 0 or mestate . settings . condition == 'clear' : mestate . settings . condition = None | control MAVExporer conditions |
229,994 | def ualberta_sys_status_send ( self , mode , nav_mode , pilot , force_mavlink1 = False ) : return self . send ( self . ualberta_sys_status_encode ( mode , nav_mode , pilot ) , force_mavlink1 = force_mavlink1 ) | System status specific to ualberta uav |
229,995 | def button_change_send ( self , time_boot_ms , last_change_ms , state , force_mavlink1 = False ) : return self . send ( self . button_change_encode ( time_boot_ms , last_change_ms , state ) , force_mavlink1 = force_mavlink1 ) | Report button state change |
229,996 | def convert_from_latlon_to_utm ( points = None , latitudes = None , longitudes = None , false_easting = None , false_northing = None ) : old_geo = Geo_reference ( ) utm_points = [ ] if points == None : assert len ( latitudes ) == len ( longitudes ) points = map ( None , latitudes , longitudes ) for point in points : zo... | Convert latitude and longitude data to UTM as a list of coordinates . |
229,997 | def dcm ( self ) : if self . _dcm is None : if self . _q is not None : self . _dcm = self . _q_to_dcm ( self . q ) elif self . _euler is not None : self . _dcm = self . _euler_to_dcm ( self . _euler ) return self . _dcm | Get the DCM |
229,998 | def lock_time ( logfile ) : print ( "Processing log %s" % filename ) mlog = mavutil . mavlink_connection ( filename ) locked = False start_time = 0.0 total_time = 0.0 t = None m = mlog . recv_match ( type = [ 'GPS_RAW_INT' , 'GPS_RAW' ] , condition = args . condition ) if m is None : return 0 unlock_time = time . mktim... | work out gps lock times for a log file |
229,999 | def on_menu ( self , event ) : state = self . state if state . popup_object is not None : obj = state . popup_object ret = obj . popup_menu . find_selected ( event ) if ret is not None : ret . call_handler ( ) state . event_queue . put ( SlipMenuEvent ( state . popup_latlon , event , [ SlipObjectSelection ( obj . key ,... | handle menu selection |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.