repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
UCL-INGI/INGInious
inginious/common/hook_manager.py
HookManager.add_hook
def add_hook(self, name, callback, prio=0): """ 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. """ 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] = [add] self._hooks[name] = hook_list
python
def add_hook(self, name, callback, prio=0): """ 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. """ 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] = [add] self._hooks[name] = hook_list
[ "def", "add_hook", "(", "self", ",", "name", ",", "callback", ",", "prio", "=", "0", ")", ":", "hook_list", "=", "self", ".", "_hooks", ".", "get", "(", "name", ",", "[", "]", ")", "add", "=", "(", "lambda", "*", "args", ",", "*", "*", "kwargs"...
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.
[ "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", "do...
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/common/hook_manager.py#L26-L37
train
229,900
UCL-INGI/INGInious
inginious/common/tasks.py
Task.input_is_consistent
def input_is_consistent(self, task_input, default_allowed_extension, default_max_size): """ Check if an input for a task is consistent. Return true if this is case, false else """ for problem in self._problems: if not problem.input_is_consistent(task_input, default_allowed_extension, default_max_size): return False return True
python
def input_is_consistent(self, task_input, default_allowed_extension, default_max_size): """ Check if an input for a task is consistent. Return true if this is case, false else """ for problem in self._problems: if not problem.input_is_consistent(task_input, default_allowed_extension, default_max_size): return False return True
[ "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", ",", ...
Check if an input for a task is consistent. Return true if this is case, false else
[ "Check", "if", "an", "input", "for", "a", "task", "is", "consistent", ".", "Return", "true", "if", "this", "is", "case", "false", "else" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/common/tasks.py#L75-L80
train
229,901
UCL-INGI/INGInious
inginious/common/tasks.py
Task.get_limits
def get_limits(self): """ Return the limits of this task """ 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
python
def get_limits(self): """ Return the limits of this task """ 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
[ "def", "get_limits", "(", "self", ")", ":", "vals", "=", "self", ".", "_hook_manager", ".", "call_hook", "(", "'task_limits'", ",", "course", "=", "self", ".", "get_course", "(", ")", ",", "task", "=", "self", ",", "default", "=", "self", ".", "_limits...
Return the limits of this task
[ "Return", "the", "limits", "of", "this", "task" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/common/tasks.py#L106-L109
train
229,902
UCL-INGI/INGInious
inginious/common/tasks.py
Task.allow_network_access_grading
def allow_network_access_grading(self): """ Return True if the grading container should have access to the network """ 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
python
def allow_network_access_grading(self): """ Return True if the grading container should have access to the network """ 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
[ "def", "allow_network_access_grading", "(", "self", ")", ":", "vals", "=", "self", ".", "_hook_manager", ".", "call_hook", "(", "'task_network_grading'", ",", "course", "=", "self", ".", "get_course", "(", ")", ",", "task", "=", "self", ",", "default", "=", ...
Return True if the grading container should have access to the network
[ "Return", "True", "if", "the", "grading", "container", "should", "have", "access", "to", "the", "network" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/common/tasks.py#L111-L114
train
229,903
UCL-INGI/INGInious
inginious/common/tasks.py
Task._create_task_problem
def _create_task_problem(self, problemid, problem_content, task_problem_types): """Creates a new instance of the right class for a given problem.""" # Basic checks 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_problem_types.get(problem_content.get('type', ""))(self, problemid, problem_content, self._translations)
python
def _create_task_problem(self, problemid, problem_content, task_problem_types): """Creates a new instance of the right class for a given problem.""" # Basic checks 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_problem_types.get(problem_content.get('type', ""))(self, problemid, problem_content, self._translations)
[ "def", "_create_task_problem", "(", "self", ",", "problemid", ",", "problem_content", ",", "task_problem_types", ")", ":", "# Basic checks", "if", "not", "id_checker", "(", "problemid", ")", ":", "raise", "Exception", "(", "\"Invalid problem _id: \"", "+", "problemi...
Creates a new instance of the right class for a given problem.
[ "Creates", "a", "new", "instance", "of", "the", "right", "class", "for", "a", "given", "problem", "." ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/common/tasks.py#L162-L170
train
229,904
UCL-INGI/INGInious
inginious/frontend/plugins/scoreboard/__init__.py
course_menu
def course_menu(course, template_helper): """ Displays the link to the scoreboards on the course page, if the plugin is activated for this course """ 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
python
def course_menu(course, template_helper): """ Displays the link to the scoreboards on the course page, if the plugin is activated for this course """ 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
[ "def", "course_menu", "(", "course", ",", "template_helper", ")", ":", "scoreboards", "=", "course", ".", "get_descriptor", "(", ")", ".", "get", "(", "'scoreboard'", ",", "[", "]", ")", "if", "scoreboards", "!=", "[", "]", ":", "return", "str", "(", "...
Displays the link to the scoreboards on the course page, if the plugin is activated for this course
[ "Displays", "the", "link", "to", "the", "scoreboards", "on", "the", "course", "page", "if", "the", "plugin", "is", "activated", "for", "this", "course" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/plugins/scoreboard/__init__.py#L172-L179
train
229,905
UCL-INGI/INGInious
inginious/frontend/plugins/scoreboard/__init__.py
task_menu
def task_menu(course, task, template_helper): """ 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 """ 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(template_helper.get_custom_renderer('frontend/plugins/scoreboard', layout=False).task_menu(course, tolink)) return None except: return None
python
def task_menu(course, task, template_helper): """ 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 """ 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(template_helper.get_custom_renderer('frontend/plugins/scoreboard', layout=False).task_menu(course, tolink)) return None except: return None
[ "def", "task_menu", "(", "course", ",", "task", ",", "template_helper", ")", ":", "scoreboards", "=", "course", ".", "get_descriptor", "(", ")", ".", "get", "(", "'scoreboard'", ",", "[", "]", ")", "try", ":", "tolink", "=", "[", "]", "for", "sid", "...
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
[ "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" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/plugins/scoreboard/__init__.py#L182-L195
train
229,906
UCL-INGI/INGInious
inginious/frontend/pages/course_admin/classroom_edit.py
CourseEditClassroom.get_user_lists
def get_user_lists(self, course, classroomid): """ Get the available student and tutor lists for classroom edition""" tutor_list = course.get_staff() # Determine if user is grouped or not in the classroom student_list = list(self.database.classrooms.aggregate([ {"$match": {"_id": ObjectId(classroomid)}}, {"$unwind": "$students"}, {"$project": { "students": 1, "grouped": { "$anyElementTrue": { "$map": { "input": "$groups.students", "as": "group", "in": { "$anyElementTrue": { "$map": { "input": "$$group", "as": "groupmember", "in": {"$eq": ["$$groupmember", "$students"]} } } } } } } }} ])) student_list = dict([(student["students"], student) for student in student_list]) other_students = [entry['students'] for entry in list(self.database.classrooms.aggregate([ {"$match": {"courseid": course.get_id(), "_id": {"$ne": ObjectId(classroomid)}}}, {"$unwind": "$students"}, {"$project": {"_id": 0, "students": 1}} ]))] users_info = self.user_manager.get_users_info(other_students + list(student_list.keys()) + tutor_list) # Order the non-registered students other_students = sorted(other_students, key=lambda val: (("0"+users_info[val][0]) if users_info[val] else ("1"+val))) return student_list, tutor_list, other_students, users_info
python
def get_user_lists(self, course, classroomid): """ Get the available student and tutor lists for classroom edition""" tutor_list = course.get_staff() # Determine if user is grouped or not in the classroom student_list = list(self.database.classrooms.aggregate([ {"$match": {"_id": ObjectId(classroomid)}}, {"$unwind": "$students"}, {"$project": { "students": 1, "grouped": { "$anyElementTrue": { "$map": { "input": "$groups.students", "as": "group", "in": { "$anyElementTrue": { "$map": { "input": "$$group", "as": "groupmember", "in": {"$eq": ["$$groupmember", "$students"]} } } } } } } }} ])) student_list = dict([(student["students"], student) for student in student_list]) other_students = [entry['students'] for entry in list(self.database.classrooms.aggregate([ {"$match": {"courseid": course.get_id(), "_id": {"$ne": ObjectId(classroomid)}}}, {"$unwind": "$students"}, {"$project": {"_id": 0, "students": 1}} ]))] users_info = self.user_manager.get_users_info(other_students + list(student_list.keys()) + tutor_list) # Order the non-registered students other_students = sorted(other_students, key=lambda val: (("0"+users_info[val][0]) if users_info[val] else ("1"+val))) return student_list, tutor_list, other_students, users_info
[ "def", "get_user_lists", "(", "self", ",", "course", ",", "classroomid", ")", ":", "tutor_list", "=", "course", ".", "get_staff", "(", ")", "# Determine if user is grouped or not in the classroom", "student_list", "=", "list", "(", "self", ".", "database", ".", "c...
Get the available student and tutor lists for classroom edition
[ "Get", "the", "available", "student", "and", "tutor", "lists", "for", "classroom", "edition" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/course_admin/classroom_edit.py#L21-L64
train
229,907
UCL-INGI/INGInious
inginious/frontend/pages/course_admin/classroom_edit.py
CourseEditClassroom.update_classroom
def update_classroom(self, course, classroomid, new_data): """ Update classroom and returns a list of errored students""" student_list, tutor_list, other_students, _ = self.get_user_lists(course, classroomid) # Check tutors new_data["tutors"] = [tutor for tutor in map(str.strip, new_data["tutors"]) if tutor in tutor_list] students, groups, errored_students = [], [], [] new_data["students"] = map(str.strip, new_data["students"]) # Check the students for student in new_data["students"]: if student in student_list: students.append(student) else: if student in other_students: # Remove user from the other classroom self.database.classrooms.find_one_and_update({"courseid": course.get_id(), "groups.students": student}, {"$pull": {"groups.$.students": student, "students": student}}) self.database.classrooms.find_one_and_update({"courseid": course.get_id(), "students": student}, {"$pull": {"students": student}}) students.append(student) else: # Check if user can be registered user_info = self.user_manager.get_user_info(student) if user_info is None or student in tutor_list: errored_students.append(student) else: students.append(student) removed_students = [student for student in student_list if student not in new_data["students"]] self.database.classrooms.find_one_and_update({"courseid": course.get_id(), "default": True}, {"$push": {"students": {"$each": removed_students}}}) new_data["students"] = students # Check the groups for group in new_data["groups"]: group["students"] = [student for student in map(str.strip, group["students"]) if student in new_data["students"]] if len(group["students"]) <= group["size"]: groups.append(group) new_data["groups"] = groups classroom = self.database.classrooms.find_one_and_update( {"_id": ObjectId(classroomid)}, {"$set": {"description": new_data["description"], "students": students, "tutors": new_data["tutors"], "groups": groups}}, return_document=ReturnDocument.AFTER) return classroom, errored_students
python
def update_classroom(self, course, classroomid, new_data): """ Update classroom and returns a list of errored students""" student_list, tutor_list, other_students, _ = self.get_user_lists(course, classroomid) # Check tutors new_data["tutors"] = [tutor for tutor in map(str.strip, new_data["tutors"]) if tutor in tutor_list] students, groups, errored_students = [], [], [] new_data["students"] = map(str.strip, new_data["students"]) # Check the students for student in new_data["students"]: if student in student_list: students.append(student) else: if student in other_students: # Remove user from the other classroom self.database.classrooms.find_one_and_update({"courseid": course.get_id(), "groups.students": student}, {"$pull": {"groups.$.students": student, "students": student}}) self.database.classrooms.find_one_and_update({"courseid": course.get_id(), "students": student}, {"$pull": {"students": student}}) students.append(student) else: # Check if user can be registered user_info = self.user_manager.get_user_info(student) if user_info is None or student in tutor_list: errored_students.append(student) else: students.append(student) removed_students = [student for student in student_list if student not in new_data["students"]] self.database.classrooms.find_one_and_update({"courseid": course.get_id(), "default": True}, {"$push": {"students": {"$each": removed_students}}}) new_data["students"] = students # Check the groups for group in new_data["groups"]: group["students"] = [student for student in map(str.strip, group["students"]) if student in new_data["students"]] if len(group["students"]) <= group["size"]: groups.append(group) new_data["groups"] = groups classroom = self.database.classrooms.find_one_and_update( {"_id": ObjectId(classroomid)}, {"$set": {"description": new_data["description"], "students": students, "tutors": new_data["tutors"], "groups": groups}}, return_document=ReturnDocument.AFTER) return classroom, errored_students
[ "def", "update_classroom", "(", "self", ",", "course", ",", "classroomid", ",", "new_data", ")", ":", "student_list", ",", "tutor_list", ",", "other_students", ",", "_", "=", "self", ".", "get_user_lists", "(", "course", ",", "classroomid", ")", "# Check tutor...
Update classroom and returns a list of errored students
[ "Update", "classroom", "and", "returns", "a", "list", "of", "errored", "students" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/course_admin/classroom_edit.py#L66-L116
train
229,908
UCL-INGI/INGInious
inginious/frontend/parsable_text.py
ParsableText.parse
def parse(self, debug=False): """Returns parsed text""" 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) except Exception as e: if debug: raise BaseException("Parsing failed") from e else: self._parsed = self._translation.gettext("<b>Parsing failed</b>: <pre>{}</pre>").format(html.escape(self._content)) return self._parsed
python
def parse(self, debug=False): """Returns parsed text""" 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) except Exception as e: if debug: raise BaseException("Parsing failed") from e else: self._parsed = self._translation.gettext("<b>Parsing failed</b>: <pre>{}</pre>").format(html.escape(self._content)) return self._parsed
[ "def", "parse", "(", "self", ",", "debug", "=", "False", ")", ":", "if", "self", ".", "_parsed", "is", "None", ":", "try", ":", "if", "self", ".", "_mode", "==", "\"html\"", ":", "self", ".", "_parsed", "=", "self", ".", "html", "(", "self", ".",...
Returns parsed text
[ "Returns", "parsed", "text" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/parsable_text.py#L144-L157
train
229,909
UCL-INGI/INGInious
inginious/frontend/pages/course_admin/task_edit_file.py
CourseTaskFiles.POST_AUTH
def POST_AUTH(self, courseid, taskid): # pylint: disable=arguments-differ """ Upload or modify a file """ 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.get('file') is not None: return self.action_upload(courseid, taskid, request.get('path'), request.get('file')) elif request.get("action") == "edit_save" and request.get('path') is not None and request.get('content') is not None: return self.action_edit_save(courseid, taskid, request.get('path'), request.get('content')) else: return self.show_tab_file(courseid, taskid)
python
def POST_AUTH(self, courseid, taskid): # pylint: disable=arguments-differ """ Upload or modify a file """ 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.get('file') is not None: return self.action_upload(courseid, taskid, request.get('path'), request.get('file')) elif request.get("action") == "edit_save" and request.get('path') is not None and request.get('content') is not None: return self.action_edit_save(courseid, taskid, request.get('path'), request.get('content')) else: return self.show_tab_file(courseid, taskid)
[ "def", "POST_AUTH", "(", "self", ",", "courseid", ",", "taskid", ")", ":", "# pylint: disable=arguments-differ", "if", "not", "id_checker", "(", "taskid", ")", ":", "raise", "Exception", "(", "\"Invalid task id\"", ")", "self", ".", "get_course_and_check_rights", ...
Upload or modify a file
[ "Upload", "or", "modify", "a", "file" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/course_admin/task_edit_file.py#L40-L53
train
229,910
UCL-INGI/INGInious
inginious/frontend/pages/course_admin/task_edit_file.py
CourseTaskFiles.show_tab_file
def show_tab_file(self, courseid, taskid, error=None): """ Return the file tab """ 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)
python
def show_tab_file(self, courseid, taskid, error=None): """ Return the file tab """ 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)
[ "def", "show_tab_file", "(", "self", ",", "courseid", ",", "taskid", ",", "error", "=", "None", ")", ":", "return", "self", ".", "template_helper", ".", "get_renderer", "(", "False", ")", ".", "course_admin", ".", "edit_tabs", ".", "files", "(", "self", ...
Return the file tab
[ "Return", "the", "file", "tab" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/course_admin/task_edit_file.py#L55-L58
train
229,911
UCL-INGI/INGInious
inginious/frontend/pages/course_admin/task_edit_file.py
CourseTaskFiles.action_edit
def action_edit(self, courseid, taskid, path): """ Edit a file """ 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": content}) except: return json.dumps({"error": "not-readable"})
python
def action_edit(self, courseid, taskid, path): """ Edit a file """ 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": content}) except: return json.dumps({"error": "not-readable"})
[ "def", "action_edit", "(", "self", ",", "courseid", ",", "taskid", ",", "path", ")", ":", "wanted_path", "=", "self", ".", "verify_path", "(", "courseid", ",", "taskid", ",", "path", ")", "if", "wanted_path", "is", "None", ":", "return", "\"Internal error\...
Edit a file
[ "Edit", "a", "file" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/course_admin/task_edit_file.py#L131-L140
train
229,912
UCL-INGI/INGInious
inginious/frontend/pages/course_admin/task_edit_file.py
CourseTaskFiles.action_edit_save
def action_edit_save(self, courseid, taskid, path, content): """ Save an edited file """ 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 json.dumps({"ok": True}) except: return json.dumps({"error": True})
python
def action_edit_save(self, courseid, taskid, path, content): """ Save an edited file """ 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 json.dumps({"ok": True}) except: return json.dumps({"error": True})
[ "def", "action_edit_save", "(", "self", ",", "courseid", ",", "taskid", ",", "path", ",", "content", ")", ":", "wanted_path", "=", "self", ".", "verify_path", "(", "courseid", ",", "taskid", ",", "path", ")", "if", "wanted_path", "is", "None", ":", "retu...
Save an edited file
[ "Save", "an", "edited", "file" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/course_admin/task_edit_file.py#L142-L151
train
229,913
UCL-INGI/INGInious
inginious/frontend/pages/course_admin/task_edit_file.py
CourseTaskFiles.action_download
def action_download(self, courseid, taskid, path): """ Download a file or a directory """ 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) if method == "local": web.header('Content-Type', mimetype_or_none) return file_or_url elif method == "url": raise web.redirect(file_or_url) else: raise web.notfound()
python
def action_download(self, courseid, taskid, path): """ Download a file or a directory """ 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) if method == "local": web.header('Content-Type', mimetype_or_none) return file_or_url elif method == "url": raise web.redirect(file_or_url) else: raise web.notfound()
[ "def", "action_download", "(", "self", ",", "courseid", ",", "taskid", ",", "path", ")", ":", "wanted_path", "=", "self", ".", "verify_path", "(", "courseid", ",", "taskid", ",", "path", ")", "if", "wanted_path", "is", "None", ":", "raise", "web", ".", ...
Download a file or a directory
[ "Download", "a", "file", "or", "a", "directory" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/course_admin/task_edit_file.py#L235-L251
train
229,914
UCL-INGI/INGInious
inginious/common/base.py
write_json_or_yaml
def write_json_or_yaml(file_path, content): """ Write JSON or YAML depending on the file extension. """ with codecs.open(file_path, "w", "utf-8") as f: f.write(get_json_or_yaml(file_path, content))
python
def write_json_or_yaml(file_path, content): """ Write JSON or YAML depending on the file extension. """ with codecs.open(file_path, "w", "utf-8") as f: f.write(get_json_or_yaml(file_path, content))
[ "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.
[ "Write", "JSON", "or", "YAML", "depending", "on", "the", "file", "extension", "." ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/common/base.py#L43-L46
train
229,915
UCL-INGI/INGInious
inginious/common/base.py
get_json_or_yaml
def get_json_or_yaml(file_path, content): """ Generate JSON or YAML depending on the file extension. """ 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)
python
def get_json_or_yaml(file_path, content): """ Generate JSON or YAML depending on the file extension. """ 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)
[ "def", "get_json_or_yaml", "(", "file_path", ",", "content", ")", ":", "if", "os", ".", "path", ".", "splitext", "(", "file_path", ")", "[", "1", "]", "==", "\".json\"", ":", "return", "json", ".", "dumps", "(", "content", ",", "sort_keys", "=", "False...
Generate JSON or YAML depending on the file extension.
[ "Generate", "JSON", "or", "YAML", "depending", "on", "the", "file", "extension", "." ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/common/base.py#L49-L54
train
229,916
UCL-INGI/INGInious
inginious/frontend/user_manager.py
UserManager._set_session
def _set_session(self, username, realname, email, language): """ Init the session. Preserves potential LTI information. """ 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._session.lti = None
python
def _set_session(self, username, realname, email, language): """ Init the session. Preserves potential LTI information. """ 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._session.lti = None
[ "def", "_set_session", "(", "self", ",", "username", ",", "realname", ",", "email", ",", "language", ")", ":", "self", ".", "_session", ".", "loggedin", "=", "True", "self", ".", "_session", ".", "email", "=", "email", "self", ".", "_session", ".", "us...
Init the session. Preserves potential LTI information.
[ "Init", "the", "session", ".", "Preserves", "potential", "LTI", "information", "." ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/user_manager.py#L184-L193
train
229,917
UCL-INGI/INGInious
inginious/frontend/user_manager.py
UserManager._destroy_session
def _destroy_session(self): """ Destroy the session """ self._session.loggedin = False self._session.email = None self._session.username = None self._session.realname = None self._session.token = None self._session.lti = None
python
def _destroy_session(self): """ Destroy the session """ self._session.loggedin = False self._session.email = None self._session.username = None self._session.realname = None self._session.token = None self._session.lti = None
[ "def", "_destroy_session", "(", "self", ")", ":", "self", ".", "_session", ".", "loggedin", "=", "False", "self", ".", "_session", ".", "email", "=", "None", "self", ".", "_session", ".", "username", "=", "None", "self", ".", "_session", ".", "realname",...
Destroy the session
[ "Destroy", "the", "session" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/user_manager.py#L195-L202
train
229,918
UCL-INGI/INGInious
inginious/frontend/user_manager.py
UserManager.create_lti_session
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): """ Creates an LTI cookieless session. Returns the new session id""" self._destroy_session() # don't forget to destroy the current session (cleans the threaded dict from web.py) self._session.load('') # creates a new cookieless session session_id = self._session.session_id self._session.lti = { "email": email, "username": user_id, "realname": realname, "roles": roles, "task": (course_id, task_id), "outcome_service_url": outcome_service_url, "outcome_result_id": outcome_result_id, "consumer_key": consumer_key, "context_title": context_title, "context_label": context_label, "tool_description": tool_desc, "tool_name": tool_name, "tool_url": tool_url } return session_id
python
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): """ Creates an LTI cookieless session. Returns the new session id""" self._destroy_session() # don't forget to destroy the current session (cleans the threaded dict from web.py) self._session.load('') # creates a new cookieless session session_id = self._session.session_id self._session.lti = { "email": email, "username": user_id, "realname": realname, "roles": roles, "task": (course_id, task_id), "outcome_service_url": outcome_service_url, "outcome_result_id": outcome_result_id, "consumer_key": consumer_key, "context_title": context_title, "context_label": context_label, "tool_description": tool_desc, "tool_name": tool_name, "tool_url": tool_url } return session_id
[ "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...
Creates an LTI cookieless session. Returns the new session id
[ "Creates", "an", "LTI", "cookieless", "session", ".", "Returns", "the", "new", "session", "id" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/user_manager.py#L204-L228
train
229,919
UCL-INGI/INGInious
inginious/frontend/user_manager.py
UserManager.user_saw_task
def user_saw_task(self, username, courseid, taskid): """ Set in the database that the user has viewed this task """ 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, "submissionid": None, "state": ""}}, upsert=True)
python
def user_saw_task(self, username, courseid, taskid): """ Set in the database that the user has viewed this task """ 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, "submissionid": None, "state": ""}}, upsert=True)
[ "def", "user_saw_task", "(", "self", ",", "username", ",", "courseid", ",", "taskid", ")", ":", "self", ".", "_database", ".", "user_tasks", ".", "update", "(", "{", "\"username\"", ":", "username", ",", "\"courseid\"", ":", "courseid", ",", "\"taskid\"", ...
Set in the database that the user has viewed this task
[ "Set", "in", "the", "database", "that", "the", "user", "has", "viewed", "this", "task" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/user_manager.py#L518-L523
train
229,920
UCL-INGI/INGInious
inginious/frontend/user_manager.py
UserManager.update_user_stats
def update_user_stats(self, username, task, submission, result_str, grade, state, newsub): """ Update stats with a new submission """ self.user_saw_task(username, submission["courseid"], submission["taskid"]) if newsub: old_submission = self._database.user_tasks.find_one_and_update( {"username": username, "courseid": submission["courseid"], "taskid": submission["taskid"]}, {"$inc": {"tried": 1, "tokens.amount": 1}}) # Check if the submission is the default download set_default = task.get_evaluate() == 'last' or \ (task.get_evaluate() == 'student' and old_submission is None) or \ (task.get_evaluate() == 'best' and old_submission.get('grade', 0.0) <= grade) if set_default: self._database.user_tasks.find_one_and_update( {"username": username, "courseid": submission["courseid"], "taskid": submission["taskid"]}, {"$set": {"succeeded": result_str == "success", "grade": grade, "state": state, "submissionid": submission['_id']}}) else: old_submission = self._database.user_tasks.find_one( {"username": username, "courseid": submission["courseid"], "taskid": submission["taskid"]}) if task.get_evaluate() == 'best': # if best, update cache consequently (with best submission) def_sub = list(self._database.submissions.find({ "username": username, "courseid": task.get_course_id(), "taskid": task.get_id(), "status": "done"} ).sort([("grade", pymongo.DESCENDING), ("submitted_on", pymongo.DESCENDING)]).limit(1)) if len(def_sub) > 0: self._database.user_tasks.find_one_and_update( {"username": username, "courseid": submission["courseid"], "taskid": submission["taskid"]}, {"$set": { "succeeded": def_sub[0]["result"] == "success", "grade": def_sub[0]["grade"], "state": def_sub[0]["state"], "submissionid": def_sub[0]['_id'] }}) elif old_submission["submissionid"] == submission["_id"]: # otherwise, update cache if needed self._database.user_tasks.find_one_and_update( {"username": username, "courseid": submission["courseid"], "taskid": submission["taskid"]}, {"$set": { "succeeded": submission["result"] == "success", "grade": submission["grade"], "state": submission["state"] }})
python
def update_user_stats(self, username, task, submission, result_str, grade, state, newsub): """ Update stats with a new submission """ self.user_saw_task(username, submission["courseid"], submission["taskid"]) if newsub: old_submission = self._database.user_tasks.find_one_and_update( {"username": username, "courseid": submission["courseid"], "taskid": submission["taskid"]}, {"$inc": {"tried": 1, "tokens.amount": 1}}) # Check if the submission is the default download set_default = task.get_evaluate() == 'last' or \ (task.get_evaluate() == 'student' and old_submission is None) or \ (task.get_evaluate() == 'best' and old_submission.get('grade', 0.0) <= grade) if set_default: self._database.user_tasks.find_one_and_update( {"username": username, "courseid": submission["courseid"], "taskid": submission["taskid"]}, {"$set": {"succeeded": result_str == "success", "grade": grade, "state": state, "submissionid": submission['_id']}}) else: old_submission = self._database.user_tasks.find_one( {"username": username, "courseid": submission["courseid"], "taskid": submission["taskid"]}) if task.get_evaluate() == 'best': # if best, update cache consequently (with best submission) def_sub = list(self._database.submissions.find({ "username": username, "courseid": task.get_course_id(), "taskid": task.get_id(), "status": "done"} ).sort([("grade", pymongo.DESCENDING), ("submitted_on", pymongo.DESCENDING)]).limit(1)) if len(def_sub) > 0: self._database.user_tasks.find_one_and_update( {"username": username, "courseid": submission["courseid"], "taskid": submission["taskid"]}, {"$set": { "succeeded": def_sub[0]["result"] == "success", "grade": def_sub[0]["grade"], "state": def_sub[0]["state"], "submissionid": def_sub[0]['_id'] }}) elif old_submission["submissionid"] == submission["_id"]: # otherwise, update cache if needed self._database.user_tasks.find_one_and_update( {"username": username, "courseid": submission["courseid"], "taskid": submission["taskid"]}, {"$set": { "succeeded": submission["result"] == "success", "grade": submission["grade"], "state": submission["state"] }})
[ "def", "update_user_stats", "(", "self", ",", "username", ",", "task", ",", "submission", ",", "result_str", ",", "grade", ",", "state", ",", "newsub", ")", ":", "self", ".", "user_saw_task", "(", "username", ",", "submission", "[", "\"courseid\"", "]", ",...
Update stats with a new submission
[ "Update", "stats", "with", "a", "new", "submission" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/user_manager.py#L525-L568
train
229,921
UCL-INGI/INGInious
inginious/frontend/user_manager.py
UserManager.get_course_aggregations
def get_course_aggregations(self, course): """ Returns a list of the course aggregations""" return natsorted(list(self._database.aggregations.find({"courseid": course.get_id()})), key=lambda x: x["description"])
python
def get_course_aggregations(self, course): """ Returns a list of the course aggregations""" return natsorted(list(self._database.aggregations.find({"courseid": course.get_id()})), key=lambda x: x["description"])
[ "def", "get_course_aggregations", "(", "self", ",", "course", ")", ":", "return", "natsorted", "(", "list", "(", "self", ".", "_database", ".", "aggregations", ".", "find", "(", "{", "\"courseid\"", ":", "course", ".", "get_id", "(", ")", "}", ")", ")", ...
Returns a list of the course aggregations
[ "Returns", "a", "list", "of", "the", "course", "aggregations" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/user_manager.py#L650-L652
train
229,922
UCL-INGI/INGInious
inginious/frontend/tasks.py
WebAppTask.get_accessible_time
def get_accessible_time(self, plugin_override=True): """ Get the accessible time of this task """ 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
python
def get_accessible_time(self, plugin_override=True): """ Get the accessible time of this task """ 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
[ "def", "get_accessible_time", "(", "self", ",", "plugin_override", "=", "True", ")", ":", "vals", "=", "self", ".", "_hook_manager", ".", "call_hook", "(", "'task_accessibility'", ",", "course", "=", "self", ".", "get_course", "(", ")", ",", "task", "=", "...
Get the accessible time of this task
[ "Get", "the", "accessible", "time", "of", "this", "task" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/tasks.py#L68-L71
train
229,923
UCL-INGI/INGInious
inginious/frontend/tasks.py
WebAppTask.get_deadline
def get_deadline(self): """ Returns a string containing the deadline for this task """ 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: # Prefer to show the soft deadline rather than the hard one return self.get_accessible_time().get_soft_end_date().strftime("%d/%m/%Y %H:%M:%S")
python
def get_deadline(self): """ Returns a string containing the deadline for this task """ 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: # Prefer to show the soft deadline rather than the hard one return self.get_accessible_time().get_soft_end_date().strftime("%d/%m/%Y %H:%M:%S")
[ "def", "get_deadline", "(", "self", ")", ":", "if", "self", ".", "get_accessible_time", "(", ")", ".", "is_always_accessible", "(", ")", ":", "return", "_", "(", "\"No deadline\"", ")", "elif", "self", ".", "get_accessible_time", "(", ")", ".", "is_never_acc...
Returns a string containing the deadline for this task
[ "Returns", "a", "string", "containing", "the", "deadline", "for", "this", "task" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/tasks.py#L77-L85
train
229,924
UCL-INGI/INGInious
inginious/frontend/tasks.py
WebAppTask.get_authors
def get_authors(self, language): """ Return the list of this task's authors """ return self.gettext(language, self._author) if self._author else ""
python
def get_authors(self, language): """ Return the list of this task's authors """ return self.gettext(language, self._author) if self._author else ""
[ "def", "get_authors", "(", "self", ",", "language", ")", ":", "return", "self", ".", "gettext", "(", "language", ",", "self", ".", "_author", ")", "if", "self", ".", "_author", "else", "\"\"" ]
Return the list of this task's authors
[ "Return", "the", "list", "of", "this", "task", "s", "authors" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/tasks.py#L106-L108
train
229,925
UCL-INGI/INGInious
inginious/frontend/tasks.py
WebAppTask.adapt_input_for_backend
def adapt_input_for_backend(self, input_data): """ Adapt the input from web.py for the inginious.backend """ for problem in self._problems: input_data = problem.adapt_input_for_backend(input_data) return input_data
python
def adapt_input_for_backend(self, input_data): """ Adapt the input from web.py for the inginious.backend """ for problem in self._problems: input_data = problem.adapt_input_for_backend(input_data) return input_data
[ "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
[ "Adapt", "the", "input", "from", "web", ".", "py", "for", "the", "inginious", ".", "backend" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/tasks.py#L110-L114
train
229,926
UCL-INGI/INGInious
inginious/frontend/pages/course_admin/submissions.py
CourseSubmissionsPage.get_users
def get_users(self, course): """ Returns a sorted list of users """ 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
python
def get_users(self, course): """ Returns a sorted list of users """ 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
[ "def", "get_users", "(", "self", ",", "course", ")", ":", "users", "=", "OrderedDict", "(", "sorted", "(", "list", "(", "self", ".", "user_manager", ".", "get_users_info", "(", "self", ".", "user_manager", ".", "get_course_registered_users", "(", "course", "...
Returns a sorted list of users
[ "Returns", "a", "sorted", "list", "of", "users" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/course_admin/submissions.py#L107-L111
train
229,927
UCL-INGI/INGInious
inginious/frontend/pages/course.py
CoursePage.get_course
def get_course(self, courseid): """ Return the course """ try: course = self.course_factory.get_course(courseid) except: raise web.notfound() return course
python
def get_course(self, courseid): """ Return the course """ try: course = self.course_factory.get_course(courseid) except: raise web.notfound() return course
[ "def", "get_course", "(", "self", ",", "courseid", ")", ":", "try", ":", "course", "=", "self", ".", "course_factory", ".", "get_course", "(", "courseid", ")", "except", ":", "raise", "web", ".", "notfound", "(", ")", "return", "course" ]
Return the course
[ "Return", "the", "course" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/course.py#L15-L22
train
229,928
UCL-INGI/INGInious
inginious/frontend/pages/course.py
CoursePage.show_page
def show_page(self, course): """ Prepares and shows the course page """ 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_manager.get_user_last_submissions(5, {"courseid": course.get_id(), "taskid": {"$in": list(tasks.keys())}}) for submission in last_submissions: submission["taskname"] = tasks[submission['taskid']].get_name(self.user_manager.session_language()) tasks_data = {} user_tasks = self.database.user_tasks.find({"username": username, "courseid": course.get_id(), "taskid": {"$in": list(tasks.keys())}}) is_admin = self.user_manager.has_staff_rights_on_course(course, username) tasks_score = [0.0, 0.0] for taskid, task in tasks.items(): tasks_data[taskid] = {"visible": task.get_accessible_time().after_start() or is_admin, "succeeded": False, "grade": 0.0} tasks_score[1] += task.get_grading_weight() if tasks_data[taskid]["visible"] else 0 for user_task in user_tasks: tasks_data[user_task["taskid"]]["succeeded"] = user_task["succeeded"] tasks_data[user_task["taskid"]]["grade"] = user_task["grade"] weighted_score = user_task["grade"]*tasks[user_task["taskid"]].get_grading_weight() tasks_score[0] += weighted_score if tasks_data[user_task["taskid"]]["visible"] else 0 course_grade = round(tasks_score[0]/tasks_score[1]) if tasks_score[1] > 0 else 0 tag_list = course.get_all_tags_names_as_list(is_admin, self.user_manager.session_language()) user_info = self.database.users.find_one({"username": username}) return self.template_helper.get_renderer().course(user_info, course, last_submissions, tasks, tasks_data, course_grade, tag_list)
python
def show_page(self, course): """ Prepares and shows the course page """ 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_manager.get_user_last_submissions(5, {"courseid": course.get_id(), "taskid": {"$in": list(tasks.keys())}}) for submission in last_submissions: submission["taskname"] = tasks[submission['taskid']].get_name(self.user_manager.session_language()) tasks_data = {} user_tasks = self.database.user_tasks.find({"username": username, "courseid": course.get_id(), "taskid": {"$in": list(tasks.keys())}}) is_admin = self.user_manager.has_staff_rights_on_course(course, username) tasks_score = [0.0, 0.0] for taskid, task in tasks.items(): tasks_data[taskid] = {"visible": task.get_accessible_time().after_start() or is_admin, "succeeded": False, "grade": 0.0} tasks_score[1] += task.get_grading_weight() if tasks_data[taskid]["visible"] else 0 for user_task in user_tasks: tasks_data[user_task["taskid"]]["succeeded"] = user_task["succeeded"] tasks_data[user_task["taskid"]]["grade"] = user_task["grade"] weighted_score = user_task["grade"]*tasks[user_task["taskid"]].get_grading_weight() tasks_score[0] += weighted_score if tasks_data[user_task["taskid"]]["visible"] else 0 course_grade = round(tasks_score[0]/tasks_score[1]) if tasks_score[1] > 0 else 0 tag_list = course.get_all_tags_names_as_list(is_admin, self.user_manager.session_language()) user_info = self.database.users.find_one({"username": username}) return self.template_helper.get_renderer().course(user_info, course, last_submissions, tasks, tasks_data, course_grade, tag_list)
[ "def", "show_page", "(", "self", ",", "course", ")", ":", "username", "=", "self", ".", "user_manager", ".", "session_username", "(", ")", "if", "not", "self", ".", "user_manager", ".", "course_is_open_to_user", "(", "course", ",", "lti", "=", "False", ")"...
Prepares and shows the course page
[ "Prepares", "and", "shows", "the", "course", "page" ]
cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/course.py#L40-L74
train
229,929
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavparms.py
mavparms
def mavparms(logfile): '''extract mavlink parameters''' 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 = m.Name value = m.Value if len(pname) > 0: if args.changesOnly is True and pname in parms and parms[pname] != value: print("%s %-15s %.6f -> %.6f" % (time.asctime(time.localtime(m._timestamp)), pname, parms[pname], value)) parms[pname] = value
python
def mavparms(logfile): '''extract mavlink parameters''' 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 = m.Name value = m.Value if len(pname) > 0: if args.changesOnly is True and pname in parms and parms[pname] != value: print("%s %-15s %.6f -> %.6f" % (time.asctime(time.localtime(m._timestamp)), pname, parms[pname], value)) parms[pname] = value
[ "def", "mavparms", "(", "logfile", ")", ":", "mlog", "=", "mavutil", ".", "mavlink_connection", "(", "filename", ")", "while", "True", ":", "try", ":", "m", "=", "mlog", ".", "recv_match", "(", "type", "=", "[", "'PARAM_VALUE'", ",", "'PARM'", "]", ")"...
extract mavlink parameters
[ "extract", "mavlink", "parameters" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavparms.py#L20-L41
train
229,930
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.send
def send(self, mavmsg, force_mavlink1=False): '''send a MAVLink message''' 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_callback_args, **self.send_callback_kwargs)
python
def send(self, mavmsg, force_mavlink1=False): '''send a MAVLink message''' 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_callback_args, **self.send_callback_kwargs)
[ "def", "send", "(", "self", ",", "mavmsg", ",", "force_mavlink1", "=", "False", ")", ":", "buf", "=", "mavmsg", ".", "pack", "(", "self", ",", "force_mavlink1", "=", "force_mavlink1", ")", "self", ".", "file", ".", "write", "(", "buf", ")", "self", "...
send a MAVLink message
[ "send", "a", "MAVLink", "message" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L7550-L7558
train
229,931
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.bytes_needed
def bytes_needed(self): '''return number of bytes needed for next parsing stage''' 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
python
def bytes_needed(self): '''return number of bytes needed for next parsing stage''' 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
[ "def", "bytes_needed", "(", "self", ")", ":", "if", "self", ".", "native", ":", "ret", "=", "self", ".", "native", ".", "expected_length", "-", "self", ".", "buf_len", "(", ")", "else", ":", "ret", "=", "self", ".", "expected_length", "-", "self", "....
return number of bytes needed for next parsing stage
[ "return", "number", "of", "bytes", "needed", "for", "next", "parsing", "stage" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L7563-L7572
train
229,932
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.__callbacks
def __callbacks(self, msg): '''this method exists only to make profiling results easier to read''' if self.callback: self.callback(msg, *self.callback_args, **self.callback_kwargs)
python
def __callbacks(self, msg): '''this method exists only to make profiling results easier to read''' if self.callback: self.callback(msg, *self.callback_args, **self.callback_kwargs)
[ "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
[ "this", "method", "exists", "only", "to", "make", "profiling", "results", "easier", "to", "read" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L7579-L7582
train
229,933
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.parse_char
def parse_char(self, c): '''input some data bytes, possibly returning a new message''' 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)) raise Exception('Native vs. Legacy mismatch') else: m = self.__parse_char_native(self.buf) else: m = self.__parse_char_legacy() if m != None: self.total_packets_received += 1 self.__callbacks(m) else: # XXX The idea here is if we've read something and there's nothing left in # the buffer, reset it to 0 which frees the memory if self.buf_len() == 0 and self.buf_index != 0: self.buf = bytearray() self.buf_index = 0 return m
python
def parse_char(self, c): '''input some data bytes, possibly returning a new message''' 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)) raise Exception('Native vs. Legacy mismatch') else: m = self.__parse_char_native(self.buf) else: m = self.__parse_char_legacy() if m != None: self.total_packets_received += 1 self.__callbacks(m) else: # XXX The idea here is if we've read something and there's nothing left in # the buffer, reset it to 0 which frees the memory if self.buf_len() == 0 and self.buf_index != 0: self.buf = bytearray() self.buf_index = 0 return m
[ "def", "parse_char", "(", "self", ",", "c", ")", ":", "self", ".", "buf", ".", "extend", "(", "c", ")", "self", ".", "total_bytes_received", "+=", "len", "(", "c", ")", "if", "self", ".", "native", ":", "if", "native_testing", ":", "self", ".", "te...
input some data bytes, possibly returning a new message
[ "input", "some", "data", "bytes", "possibly", "returning", "a", "new", "message" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L7584-L7613
train
229,934
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.parse_buffer
def parse_buffer(self, s): '''input some data bytes, possibly returning a list of new messages''' 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
python
def parse_buffer(self, s): '''input some data bytes, possibly returning a list of new messages''' 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
[ "def", "parse_buffer", "(", "self", ",", "s", ")", ":", "m", "=", "self", ".", "parse_char", "(", "s", ")", "if", "m", "is", "None", ":", "return", "None", "ret", "=", "[", "m", "]", "while", "True", ":", "m", "=", "self", ".", "parse_char", "(...
input some data bytes, possibly returning a list of new messages
[ "input", "some", "data", "bytes", "possibly", "returning", "a", "list", "of", "new", "messages" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L7662-L7673
train
229,935
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.check_signature
def check_signature(self, msgbuf, srcSystem, srcComponent): '''check signature on incoming message''' 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) # see if the timestamp is acceptable stream_key = (link_id,srcSystem,srcComponent) if stream_key in self.signing.stream_timestamps: if timestamp <= self.signing.stream_timestamps[stream_key]: # reject old timestamp # print('old timestamp') return False else: # a new stream has appeared. Accept the timestamp if it is at most # one minute behind our current timestamp if timestamp + 6000*1000 < self.signing.timestamp: # print('bad new stream ', timestamp/(100.0*1000*60*60*24*365), self.signing.timestamp/(100.0*1000*60*60*24*365)) return False self.signing.stream_timestamps[stream_key] = timestamp # print('new stream') h = hashlib.new('sha256') h.update(self.signing.secret_key) h.update(msgbuf[:-6]) sig1 = str(h.digest())[:6] sig2 = str(msgbuf)[-6:] if sig1 != sig2: # print('sig mismatch') return False # the timestamp we next send with is the max of the received timestamp and # our current timestamp self.signing.timestamp = max(self.signing.timestamp, timestamp) return True
python
def check_signature(self, msgbuf, srcSystem, srcComponent): '''check signature on incoming message''' 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) # see if the timestamp is acceptable stream_key = (link_id,srcSystem,srcComponent) if stream_key in self.signing.stream_timestamps: if timestamp <= self.signing.stream_timestamps[stream_key]: # reject old timestamp # print('old timestamp') return False else: # a new stream has appeared. Accept the timestamp if it is at most # one minute behind our current timestamp if timestamp + 6000*1000 < self.signing.timestamp: # print('bad new stream ', timestamp/(100.0*1000*60*60*24*365), self.signing.timestamp/(100.0*1000*60*60*24*365)) return False self.signing.stream_timestamps[stream_key] = timestamp # print('new stream') h = hashlib.new('sha256') h.update(self.signing.secret_key) h.update(msgbuf[:-6]) sig1 = str(h.digest())[:6] sig2 = str(msgbuf)[-6:] if sig1 != sig2: # print('sig mismatch') return False # the timestamp we next send with is the max of the received timestamp and # our current timestamp self.signing.timestamp = max(self.signing.timestamp, timestamp) return True
[ "def", "check_signature", "(", "self", ",", "msgbuf", ",", "srcSystem", ",", "srcComponent", ")", ":", "if", "isinstance", "(", "msgbuf", ",", "array", ".", "array", ")", ":", "msgbuf", "=", "msgbuf", ".", "tostring", "(", ")", "timestamp_buf", "=", "msg...
check signature on incoming message
[ "check", "signature", "on", "incoming", "message" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L7675-L7712
train
229,936
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.flexifunction_set_send
def flexifunction_set_send(self, target_system, target_component, force_mavlink1=False): ''' Depreciated but used as a compiler flag. Do not remove target_system : System ID (uint8_t) target_component : Component ID (uint8_t) ''' return self.send(self.flexifunction_set_encode(target_system, target_component), force_mavlink1=force_mavlink1)
python
def flexifunction_set_send(self, target_system, target_component, force_mavlink1=False): ''' Depreciated but used as a compiler flag. Do not remove target_system : System ID (uint8_t) target_component : Component ID (uint8_t) ''' return self.send(self.flexifunction_set_encode(target_system, target_component), force_mavlink1=force_mavlink1)
[ "def", "flexifunction_set_send", "(", "self", ",", "target_system", ",", "target_component", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "flexifunction_set_encode", "(", "target_system", ",", "target_component", ...
Depreciated but used as a compiler flag. Do not remove target_system : System ID (uint8_t) target_component : Component ID (uint8_t)
[ "Depreciated", "but", "used", "as", "a", "compiler", "flag", ".", "Do", "not", "remove" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L7855-L7863
train
229,937
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.system_time_send
def system_time_send(self, time_unix_usec, time_boot_ms, force_mavlink1=False): ''' The system time is the time of the master clock, typically the computer clock of the main onboard computer. time_unix_usec : Timestamp of the master clock in microseconds since UNIX epoch. (uint64_t) time_boot_ms : Timestamp of the component clock since boot time in milliseconds. (uint32_t) ''' return self.send(self.system_time_encode(time_unix_usec, time_boot_ms), force_mavlink1=force_mavlink1)
python
def system_time_send(self, time_unix_usec, time_boot_ms, force_mavlink1=False): ''' The system time is the time of the master clock, typically the computer clock of the main onboard computer. time_unix_usec : Timestamp of the master clock in microseconds since UNIX epoch. (uint64_t) time_boot_ms : Timestamp of the component clock since boot time in milliseconds. (uint32_t) ''' return self.send(self.system_time_encode(time_unix_usec, time_boot_ms), force_mavlink1=force_mavlink1)
[ "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", ")", ",", "for...
The system time is the time of the master clock, typically the computer clock of the main onboard computer. time_unix_usec : Timestamp of the master clock in microseconds since UNIX epoch. (uint64_t) time_boot_ms : Timestamp of the component clock since boot time in milliseconds. (uint32_t)
[ "The", "system", "time", "is", "the", "time", "of", "the", "master", "clock", "typically", "the", "computer", "clock", "of", "the", "main", "onboard", "computer", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L8636-L8645
train
229,938
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.set_mode_send
def set_mode_send(self, target_system, base_mode, custom_mode, force_mavlink1=False): ''' 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. target_system : The system setting the mode (uint8_t) base_mode : The new base mode (uint8_t) custom_mode : The new autopilot-specific mode. This field can be ignored by an autopilot. (uint32_t) ''' return self.send(self.set_mode_encode(target_system, base_mode, custom_mode), force_mavlink1=force_mavlink1)
python
def set_mode_send(self, target_system, base_mode, custom_mode, force_mavlink1=False): ''' 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. target_system : The system setting the mode (uint8_t) base_mode : The new base mode (uint8_t) custom_mode : The new autopilot-specific mode. This field can be ignored by an autopilot. (uint32_t) ''' return self.send(self.set_mode_encode(target_system, base_mode, custom_mode), force_mavlink1=force_mavlink1)
[ "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", ",", "...
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. target_system : The system setting the mode (uint8_t) base_mode : The new base mode (uint8_t) custom_mode : The new autopilot-specific mode. This field can be ignored by an autopilot. (uint32_t)
[ "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", ...
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L8760-L8773
train
229,939
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.param_request_list_send
def param_request_list_send(self, target_system, target_component, force_mavlink1=False): ''' Request all parameters of this component. After this request, all parameters are emitted. target_system : System ID (uint8_t) target_component : Component ID (uint8_t) ''' return self.send(self.param_request_list_encode(target_system, target_component), force_mavlink1=force_mavlink1)
python
def param_request_list_send(self, target_system, target_component, force_mavlink1=False): ''' Request all parameters of this component. After this request, all parameters are emitted. target_system : System ID (uint8_t) target_component : Component ID (uint8_t) ''' return self.send(self.param_request_list_encode(target_system, target_component), force_mavlink1=force_mavlink1)
[ "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", ...
Request all parameters of this component. After this request, all parameters are emitted. target_system : System ID (uint8_t) target_component : Component ID (uint8_t)
[ "Request", "all", "parameters", "of", "this", "component", ".", "After", "this", "request", "all", "parameters", "are", "emitted", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L8826-L8835
train
229,940
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.mission_current_send
def mission_current_send(self, seq, force_mavlink1=False): ''' Message that announces the sequence number of the current active mission item. The MAV will fly towards this mission item. seq : Sequence (uint16_t) ''' return self.send(self.mission_current_encode(seq), force_mavlink1=force_mavlink1)
python
def mission_current_send(self, seq, force_mavlink1=False): ''' Message that announces the sequence number of the current active mission item. The MAV will fly towards this mission item. seq : Sequence (uint16_t) ''' return self.send(self.mission_current_encode(seq), force_mavlink1=force_mavlink1)
[ "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. seq : Sequence (uint16_t)
[ "Message", "that", "announces", "the", "sequence", "number", "of", "the", "current", "active", "mission", "item", ".", "The", "MAV", "will", "fly", "towards", "this", "mission", "item", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L9590-L9599
train
229,941
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.mission_count_send
def mission_count_send(self, target_system, target_component, count, force_mavlink1=False): ''' 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. target_system : System ID (uint8_t) target_component : Component ID (uint8_t) count : Number of mission items in the sequence (uint16_t) ''' return self.send(self.mission_count_encode(target_system, target_component, count), force_mavlink1=force_mavlink1)
python
def mission_count_send(self, target_system, target_component, count, force_mavlink1=False): ''' 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. target_system : System ID (uint8_t) target_component : Component ID (uint8_t) count : Number of mission items in the sequence (uint16_t) ''' return self.send(self.mission_count_encode(target_system, target_component, count), force_mavlink1=force_mavlink1)
[ "def", "mission_count_send", "(", "self", ",", "target_system", ",", "target_component", ",", "count", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "mission_count_encode", "(", "target_system", ",", "target_comp...
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. target_system : System ID (uint8_t) target_component : Component ID (uint8_t) count : Number of mission items in the sequence (uint16_t)
[ "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", ...
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L9635-L9647
train
229,942
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.mission_clear_all_send
def mission_clear_all_send(self, target_system, target_component, force_mavlink1=False): ''' Delete all mission items at once. target_system : System ID (uint8_t) target_component : Component ID (uint8_t) ''' return self.send(self.mission_clear_all_encode(target_system, target_component), force_mavlink1=force_mavlink1)
python
def mission_clear_all_send(self, target_system, target_component, force_mavlink1=False): ''' Delete all mission items at once. target_system : System ID (uint8_t) target_component : Component ID (uint8_t) ''' return self.send(self.mission_clear_all_encode(target_system, target_component), force_mavlink1=force_mavlink1)
[ "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", ...
Delete all mission items at once. target_system : System ID (uint8_t) target_component : Component ID (uint8_t)
[ "Delete", "all", "mission", "items", "at", "once", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L9659-L9667
train
229,943
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.data_stream_send
def data_stream_send(self, stream_id, message_rate, on_off, force_mavlink1=False): ''' THIS INTERFACE IS DEPRECATED. USE MESSAGE_INTERVAL INSTEAD. stream_id : The ID of the requested data stream (uint8_t) message_rate : The message rate (uint16_t) on_off : 1 stream is enabled, 0 stream is stopped. (uint8_t) ''' return self.send(self.data_stream_encode(stream_id, message_rate, on_off), force_mavlink1=force_mavlink1)
python
def data_stream_send(self, stream_id, message_rate, on_off, force_mavlink1=False): ''' THIS INTERFACE IS DEPRECATED. USE MESSAGE_INTERVAL INSTEAD. stream_id : The ID of the requested data stream (uint8_t) message_rate : The message rate (uint16_t) on_off : 1 stream is enabled, 0 stream is stopped. (uint8_t) ''' return self.send(self.data_stream_encode(stream_id, message_rate, on_off), force_mavlink1=force_mavlink1)
[ "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", ",", "o...
THIS INTERFACE IS DEPRECATED. USE MESSAGE_INTERVAL INSTEAD. stream_id : The ID of the requested data stream (uint8_t) message_rate : The message rate (uint16_t) on_off : 1 stream is enabled, 0 stream is stopped. (uint8_t)
[ "THIS", "INTERFACE", "IS", "DEPRECATED", ".", "USE", "MESSAGE_INTERVAL", "INSTEAD", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L10178-L10187
train
229,944
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.command_ack_send
def command_ack_send(self, command, result, force_mavlink1=False): ''' Report status of a command. Includes feedback wether the command was executed. command : Command ID, as defined by MAV_CMD enum. (uint16_t) result : See MAV_RESULT enum (uint8_t) ''' return self.send(self.command_ack_encode(command, result), force_mavlink1=force_mavlink1)
python
def command_ack_send(self, command, result, force_mavlink1=False): ''' Report status of a command. Includes feedback wether the command was executed. command : Command ID, as defined by MAV_CMD enum. (uint16_t) result : See MAV_RESULT enum (uint8_t) ''' return self.send(self.command_ack_encode(command, result), force_mavlink1=force_mavlink1)
[ "def", "command_ack_send", "(", "self", ",", "command", ",", "result", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "command_ack_encode", "(", "command", ",", "result", ")", ",", "force_mavlink1", "=", "fo...
Report status of a command. Includes feedback wether the command was executed. command : Command ID, as defined by MAV_CMD enum. (uint16_t) result : See MAV_RESULT enum (uint8_t)
[ "Report", "status", "of", "a", "command", ".", "Includes", "feedback", "wether", "the", "command", "was", "executed", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L10452-L10461
train
229,945
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.timesync_send
def timesync_send(self, tc1, ts1, force_mavlink1=False): ''' Time synchronization message. tc1 : Time sync timestamp 1 (int64_t) ts1 : Time sync timestamp 2 (int64_t) ''' return self.send(self.timesync_encode(tc1, ts1), force_mavlink1=force_mavlink1)
python
def timesync_send(self, tc1, ts1, force_mavlink1=False): ''' Time synchronization message. tc1 : Time sync timestamp 1 (int64_t) ts1 : Time sync timestamp 2 (int64_t) ''' return self.send(self.timesync_encode(tc1, ts1), force_mavlink1=force_mavlink1)
[ "def", "timesync_send", "(", "self", ",", "tc1", ",", "ts1", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "timesync_encode", "(", "tc1", ",", "ts1", ")", ",", "force_mavlink1", "=", "force_mavlink1", ")"...
Time synchronization message. tc1 : Time sync timestamp 1 (int64_t) ts1 : Time sync timestamp 2 (int64_t)
[ "Time", "synchronization", "message", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L11391-L11399
train
229,946
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.camera_trigger_send
def camera_trigger_send(self, time_usec, seq, force_mavlink1=False): ''' Camera-IMU triggering and synchronisation message. time_usec : Timestamp for the image frame in microseconds (uint64_t) seq : Image frame sequence (uint32_t) ''' return self.send(self.camera_trigger_encode(time_usec, seq), force_mavlink1=force_mavlink1)
python
def camera_trigger_send(self, time_usec, seq, force_mavlink1=False): ''' Camera-IMU triggering and synchronisation message. time_usec : Timestamp for the image frame in microseconds (uint64_t) seq : Image frame sequence (uint32_t) ''' return self.send(self.camera_trigger_encode(time_usec, seq), force_mavlink1=force_mavlink1)
[ "def", "camera_trigger_send", "(", "self", ",", "time_usec", ",", "seq", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "camera_trigger_encode", "(", "time_usec", ",", "seq", ")", ",", "force_mavlink1", "=", ...
Camera-IMU triggering and synchronisation message. time_usec : Timestamp for the image frame in microseconds (uint64_t) seq : Image frame sequence (uint32_t)
[ "Camera", "-", "IMU", "triggering", "and", "synchronisation", "message", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L11411-L11419
train
229,947
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.log_erase_send
def log_erase_send(self, target_system, target_component, force_mavlink1=False): ''' Erase all logs target_system : System ID (uint8_t) target_component : Component ID (uint8_t) ''' return self.send(self.log_erase_encode(target_system, target_component), force_mavlink1=force_mavlink1)
python
def log_erase_send(self, target_system, target_component, force_mavlink1=False): ''' Erase all logs target_system : System ID (uint8_t) target_component : Component ID (uint8_t) ''' return self.send(self.log_erase_encode(target_system, target_component), force_mavlink1=force_mavlink1)
[ "def", "log_erase_send", "(", "self", ",", "target_system", ",", "target_component", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "log_erase_encode", "(", "target_system", ",", "target_component", ")", ",", "f...
Erase all logs target_system : System ID (uint8_t) target_component : Component ID (uint8_t)
[ "Erase", "all", "logs" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L11721-L11729
train
229,948
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.log_request_end_send
def log_request_end_send(self, target_system, target_component, force_mavlink1=False): ''' Stop log transfer and resume normal logging target_system : System ID (uint8_t) target_component : Component ID (uint8_t) ''' return self.send(self.log_request_end_encode(target_system, target_component), force_mavlink1=force_mavlink1)
python
def log_request_end_send(self, target_system, target_component, force_mavlink1=False): ''' Stop log transfer and resume normal logging target_system : System ID (uint8_t) target_component : Component ID (uint8_t) ''' return self.send(self.log_request_end_encode(target_system, target_component), force_mavlink1=force_mavlink1)
[ "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", ")",...
Stop log transfer and resume normal logging target_system : System ID (uint8_t) target_component : Component ID (uint8_t)
[ "Stop", "log", "transfer", "and", "resume", "normal", "logging" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L11741-L11749
train
229,949
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.power_status_send
def power_status_send(self, Vcc, Vservo, flags, force_mavlink1=False): ''' Power supply status Vcc : 5V rail voltage in millivolts (uint16_t) Vservo : servo rail voltage in millivolts (uint16_t) flags : power supply status flags (see MAV_POWER_STATUS enum) (uint16_t) ''' return self.send(self.power_status_encode(Vcc, Vservo, flags), force_mavlink1=force_mavlink1)
python
def power_status_send(self, Vcc, Vservo, flags, force_mavlink1=False): ''' Power supply status Vcc : 5V rail voltage in millivolts (uint16_t) Vservo : servo rail voltage in millivolts (uint16_t) flags : power supply status flags (see MAV_POWER_STATUS enum) (uint16_t) ''' return self.send(self.power_status_encode(Vcc, Vservo, flags), force_mavlink1=force_mavlink1)
[ "def", "power_status_send", "(", "self", ",", "Vcc", ",", "Vservo", ",", "flags", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "power_status_encode", "(", "Vcc", ",", "Vservo", ",", "flags", ")", ",", ...
Power supply status Vcc : 5V rail voltage in millivolts (uint16_t) Vservo : servo rail voltage in millivolts (uint16_t) flags : power supply status flags (see MAV_POWER_STATUS enum) (uint16_t)
[ "Power", "supply", "status" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L11828-L11837
train
229,950
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.terrain_check_send
def terrain_check_send(self, lat, lon, force_mavlink1=False): ''' 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. lat : Latitude (degrees *10^7) (int32_t) lon : Longitude (degrees *10^7) (int32_t) ''' return self.send(self.terrain_check_encode(lat, lon), force_mavlink1=force_mavlink1)
python
def terrain_check_send(self, lat, lon, force_mavlink1=False): ''' 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. lat : Latitude (degrees *10^7) (int32_t) lon : Longitude (degrees *10^7) (int32_t) ''' return self.send(self.terrain_check_encode(lat, lon), force_mavlink1=force_mavlink1)
[ "def", "terrain_check_send", "(", "self", ",", "lat", ",", "lon", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "terrain_check_encode", "(", "lat", ",", "lon", ")", ",", "force_mavlink1", "=", "force_mavlin...
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. lat : Latitude (degrees *10^7) (int32_t) lon : Longitude (degrees *10^7) (int32_t)
[ "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", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L12149-L12159
train
229,951
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.gps_input_encode
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): ''' GPS sensor input message. This is a raw sensor value sent by the GPS. This is NOT the global position estimate of the sytem. time_usec : Timestamp (micros since boot or Unix epoch) (uint64_t) gps_id : ID of the GPS for multiple GPS inputs (uint8_t) ignore_flags : Flags indicating which fields to ignore (see GPS_INPUT_IGNORE_FLAGS enum). All other fields must be provided. (uint16_t) time_week_ms : GPS time (milliseconds from start of GPS week) (uint32_t) time_week : GPS week number (uint16_t) fix_type : 0-1: no fix, 2: 2D fix, 3: 3D fix. 4: 3D with DGPS. 5: 3D with RTK (uint8_t) lat : Latitude (WGS84), in degrees * 1E7 (int32_t) lon : Longitude (WGS84), in degrees * 1E7 (int32_t) alt : Altitude (AMSL, not WGS84), in m (positive for up) (float) hdop : GPS HDOP horizontal dilution of position in m (float) vdop : GPS VDOP vertical dilution of position in m (float) vn : GPS velocity in m/s in NORTH direction in earth-fixed NED frame (float) ve : GPS velocity in m/s in EAST direction in earth-fixed NED frame (float) vd : GPS velocity in m/s in DOWN direction in earth-fixed NED frame (float) speed_accuracy : GPS speed accuracy in m/s (float) horiz_accuracy : GPS horizontal accuracy in m (float) vert_accuracy : GPS vertical accuracy in m (float) satellites_visible : Number of satellites visible. (uint8_t) ''' return MAVLink_gps_input_message(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)
python
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): ''' GPS sensor input message. This is a raw sensor value sent by the GPS. This is NOT the global position estimate of the sytem. time_usec : Timestamp (micros since boot or Unix epoch) (uint64_t) gps_id : ID of the GPS for multiple GPS inputs (uint8_t) ignore_flags : Flags indicating which fields to ignore (see GPS_INPUT_IGNORE_FLAGS enum). All other fields must be provided. (uint16_t) time_week_ms : GPS time (milliseconds from start of GPS week) (uint32_t) time_week : GPS week number (uint16_t) fix_type : 0-1: no fix, 2: 2D fix, 3: 3D fix. 4: 3D with DGPS. 5: 3D with RTK (uint8_t) lat : Latitude (WGS84), in degrees * 1E7 (int32_t) lon : Longitude (WGS84), in degrees * 1E7 (int32_t) alt : Altitude (AMSL, not WGS84), in m (positive for up) (float) hdop : GPS HDOP horizontal dilution of position in m (float) vdop : GPS VDOP vertical dilution of position in m (float) vn : GPS velocity in m/s in NORTH direction in earth-fixed NED frame (float) ve : GPS velocity in m/s in EAST direction in earth-fixed NED frame (float) vd : GPS velocity in m/s in DOWN direction in earth-fixed NED frame (float) speed_accuracy : GPS speed accuracy in m/s (float) horiz_accuracy : GPS horizontal accuracy in m (float) vert_accuracy : GPS vertical accuracy in m (float) satellites_visible : Number of satellites visible. (uint8_t) ''' return MAVLink_gps_input_message(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)
[ "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", ",", ...
GPS sensor input message. This is a raw sensor value sent by the GPS. This is NOT the global position estimate of the sytem. time_usec : Timestamp (micros since boot or Unix epoch) (uint64_t) gps_id : ID of the GPS for multiple GPS inputs (uint8_t) ignore_flags : Flags indicating which fields to ignore (see GPS_INPUT_IGNORE_FLAGS enum). All other fields must be provided. (uint16_t) time_week_ms : GPS time (milliseconds from start of GPS week) (uint32_t) time_week : GPS week number (uint16_t) fix_type : 0-1: no fix, 2: 2D fix, 3: 3D fix. 4: 3D with DGPS. 5: 3D with RTK (uint8_t) lat : Latitude (WGS84), in degrees * 1E7 (int32_t) lon : Longitude (WGS84), in degrees * 1E7 (int32_t) alt : Altitude (AMSL, not WGS84), in m (positive for up) (float) hdop : GPS HDOP horizontal dilution of position in m (float) vdop : GPS VDOP vertical dilution of position in m (float) vn : GPS velocity in m/s in NORTH direction in earth-fixed NED frame (float) ve : GPS velocity in m/s in EAST direction in earth-fixed NED frame (float) vd : GPS velocity in m/s in DOWN direction in earth-fixed NED frame (float) speed_accuracy : GPS speed accuracy in m/s (float) horiz_accuracy : GPS horizontal accuracy in m (float) vert_accuracy : GPS vertical accuracy in m (float) satellites_visible : Number of satellites visible. (uint8_t)
[ "GPS", "sensor", "input", "message", ".", "This", "is", "a", "raw", "sensor", "value", "sent", "by", "the", "GPS", ".", "This", "is", "NOT", "the", "global", "position", "estimate", "of", "the", "sytem", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L12663-L12688
train
229,952
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.message_interval_send
def message_interval_send(self, message_id, interval_us, force_mavlink1=False): ''' This interface replaces DATA_STREAM message_id : The ID of the requested MAVLink message. v1.0 is limited to 254 messages. (uint16_t) interval_us : The interval between two messages, in microseconds. A value of -1 indicates this stream is disabled, 0 indicates it is not available, > 0 indicates the interval at which it is sent. (int32_t) ''' return self.send(self.message_interval_encode(message_id, interval_us), force_mavlink1=force_mavlink1)
python
def message_interval_send(self, message_id, interval_us, force_mavlink1=False): ''' This interface replaces DATA_STREAM message_id : The ID of the requested MAVLink message. v1.0 is limited to 254 messages. (uint16_t) interval_us : The interval between two messages, in microseconds. A value of -1 indicates this stream is disabled, 0 indicates it is not available, > 0 indicates the interval at which it is sent. (int32_t) ''' return self.send(self.message_interval_encode(message_id, interval_us), force_mavlink1=force_mavlink1)
[ "def", "message_interval_send", "(", "self", ",", "message_id", ",", "interval_us", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "message_interval_encode", "(", "message_id", ",", "interval_us", ")", ",", "for...
This interface replaces DATA_STREAM message_id : The ID of the requested MAVLink message. v1.0 is limited to 254 messages. (uint16_t) interval_us : The interval between two messages, in microseconds. A value of -1 indicates this stream is disabled, 0 indicates it is not available, > 0 indicates the interval at which it is sent. (int32_t)
[ "This", "interface", "replaces", "DATA_STREAM" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L12903-L12911
train
229,953
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.extended_sys_state_send
def extended_sys_state_send(self, vtol_state, landed_state, force_mavlink1=False): ''' Provides state for additional features vtol_state : The VTOL state if applicable. Is set to MAV_VTOL_STATE_UNDEFINED if UAV is not in VTOL configuration. (uint8_t) landed_state : The landed state. Is set to MAV_LANDED_STATE_UNDEFINED if landed state is unknown. (uint8_t) ''' return self.send(self.extended_sys_state_encode(vtol_state, landed_state), force_mavlink1=force_mavlink1)
python
def extended_sys_state_send(self, vtol_state, landed_state, force_mavlink1=False): ''' Provides state for additional features vtol_state : The VTOL state if applicable. Is set to MAV_VTOL_STATE_UNDEFINED if UAV is not in VTOL configuration. (uint8_t) landed_state : The landed state. Is set to MAV_LANDED_STATE_UNDEFINED if landed state is unknown. (uint8_t) ''' return self.send(self.extended_sys_state_encode(vtol_state, landed_state), force_mavlink1=force_mavlink1)
[ "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", ")", ",", ...
Provides state for additional features vtol_state : The VTOL state if applicable. Is set to MAV_VTOL_STATE_UNDEFINED if UAV is not in VTOL configuration. (uint8_t) landed_state : The landed state. Is set to MAV_LANDED_STATE_UNDEFINED if landed state is unknown. (uint8_t)
[ "Provides", "state", "for", "additional", "features" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L12923-L12931
train
229,954
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.named_value_float_send
def named_value_float_send(self, time_boot_ms, name, value, force_mavlink1=False): ''' 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. time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t) name : Name of the debug variable (char) value : Floating point value (float) ''' return self.send(self.named_value_float_encode(time_boot_ms, name, value), force_mavlink1=force_mavlink1)
python
def named_value_float_send(self, time_boot_ms, name, value, force_mavlink1=False): ''' 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. time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t) name : Name of the debug variable (char) value : Floating point value (float) ''' return self.send(self.named_value_float_encode(time_boot_ms, name, value), force_mavlink1=force_mavlink1)
[ "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", ",", "...
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. time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t) name : Name of the debug variable (char) value : Floating point value (float)
[ "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", "experimen...
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L13101-L13113
train
229,955
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.named_value_int_send
def named_value_int_send(self, time_boot_ms, name, value, force_mavlink1=False): ''' 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. time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t) name : Name of the debug variable (char) value : Signed integer value (int32_t) ''' return self.send(self.named_value_int_encode(time_boot_ms, name, value), force_mavlink1=force_mavlink1)
python
def named_value_int_send(self, time_boot_ms, name, value, force_mavlink1=False): ''' 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. time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t) name : Name of the debug variable (char) value : Signed integer value (int32_t) ''' return self.send(self.named_value_int_encode(time_boot_ms, name, value), force_mavlink1=force_mavlink1)
[ "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", ",", "valu...
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. time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t) name : Name of the debug variable (char) value : Signed integer value (int32_t)
[ "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", "experim...
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L13129-L13141
train
229,956
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
MAVLink.debug_send
def debug_send(self, time_boot_ms, ind, value, force_mavlink1=False): ''' Send a debug value. The index is used to discriminate between values. These values show up in the plot of QGroundControl as DEBUG N. time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t) ind : index of debug variable (uint8_t) value : DEBUG value (float) ''' return self.send(self.debug_encode(time_boot_ms, ind, value), force_mavlink1=force_mavlink1)
python
def debug_send(self, time_boot_ms, ind, value, force_mavlink1=False): ''' Send a debug value. The index is used to discriminate between values. These values show up in the plot of QGroundControl as DEBUG N. time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t) ind : index of debug variable (uint8_t) value : DEBUG value (float) ''' return self.send(self.debug_encode(time_boot_ms, ind, value), force_mavlink1=force_mavlink1)
[ "def", "debug_send", "(", "self", ",", "time_boot_ms", ",", "ind", ",", "value", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "debug_encode", "(", "time_boot_ms", ",", "ind", ",", "value", ")", ",", "f...
Send a debug value. The index is used to discriminate between values. These values show up in the plot of QGroundControl as DEBUG N. time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t) ind : index of debug variable (uint8_t) value : DEBUG value (float)
[ "Send", "a", "debug", "value", ".", "The", "index", "is", "used", "to", "discriminate", "between", "values", ".", "These", "values", "show", "up", "in", "the", "plot", "of", "QGroundControl", "as", "DEBUG", "N", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L13186-L13197
train
229,957
JdeRobot/base
src/libs/comm_py/comm/ros/publisherMotors.py
PublisherMotors.sendVX
def sendVX(self, vx): ''' Sends VX velocity. @param vx: VX velocity @type vx: float ''' self.lock.acquire() self.data.vx = vx self.lock.release()
python
def sendVX(self, vx): ''' Sends VX velocity. @param vx: VX velocity @type vx: float ''' self.lock.acquire() self.data.vx = vx self.lock.release()
[ "def", "sendVX", "(", "self", ",", "vx", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "self", ".", "data", ".", "vx", "=", "vx", "self", ".", "lock", ".", "release", "(", ")" ]
Sends VX velocity. @param vx: VX velocity @type vx: float
[ "Sends", "VX", "velocity", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/publisherMotors.py#L138-L149
train
229,958
JdeRobot/base
src/libs/comm_py/comm/ros/publisherMotors.py
PublisherMotors.sendVY
def sendVY(self, vy): ''' Sends VY velocity. @param vy: VY velocity @type vy: float ''' self.lock.acquire() self.data.vy = vy self.lock.release()
python
def sendVY(self, vy): ''' Sends VY velocity. @param vy: VY velocity @type vy: float ''' self.lock.acquire() self.data.vy = vy self.lock.release()
[ "def", "sendVY", "(", "self", ",", "vy", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "self", ".", "data", ".", "vy", "=", "vy", "self", ".", "lock", ".", "release", "(", ")" ]
Sends VY velocity. @param vy: VY velocity @type vy: float
[ "Sends", "VY", "velocity", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/publisherMotors.py#L151-L162
train
229,959
JdeRobot/base
src/libs/comm_py/comm/ros/publisherMotors.py
PublisherMotors.sendAZ
def sendAZ(self, az): ''' Sends AZ velocity. @param az: AZ velocity @type az: float ''' self.lock.acquire() self.data.az = az self.lock.release()
python
def sendAZ(self, az): ''' Sends AZ velocity. @param az: AZ velocity @type az: float ''' self.lock.acquire() self.data.az = az self.lock.release()
[ "def", "sendAZ", "(", "self", ",", "az", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "self", ".", "data", ".", "az", "=", "az", "self", ".", "lock", ".", "release", "(", ")" ]
Sends AZ velocity. @param az: AZ velocity @type az: float
[ "Sends", "AZ", "velocity", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/publisherMotors.py#L164-L175
train
229,960
JdeRobot/base
src/libs/comm_py/comm/ros/listenerBumper.py
bumperEvent2BumperData
def bumperEvent2BumperData(event): ''' Translates from ROS BumperScan to JderobotTypes BumperData. @param event: ROS BumperScan to translate @type event: BumperScan @return a BumperData translated from event # bumper LEFT = 0 CENTER = 1 RIGHT = 2 # state RELEASED = 0 PRESSED = 1 ''' bump = BumperData() bump.state = event.state bump.bumper = event.bumper #bump.timeStamp = event.header.stamp.secs + (event.header.stamp.nsecs *1e-9) return bump
python
def bumperEvent2BumperData(event): ''' Translates from ROS BumperScan to JderobotTypes BumperData. @param event: ROS BumperScan to translate @type event: BumperScan @return a BumperData translated from event # bumper LEFT = 0 CENTER = 1 RIGHT = 2 # state RELEASED = 0 PRESSED = 1 ''' bump = BumperData() bump.state = event.state bump.bumper = event.bumper #bump.timeStamp = event.header.stamp.secs + (event.header.stamp.nsecs *1e-9) return bump
[ "def", "bumperEvent2BumperData", "(", "event", ")", ":", "bump", "=", "BumperData", "(", ")", "bump", ".", "state", "=", "event", ".", "state", "bump", ".", "bumper", "=", "event", ".", "bumper", "#bump.timeStamp = event.header.stamp.secs + (event.header.stamp.nsecs...
Translates from ROS BumperScan to JderobotTypes BumperData. @param event: ROS BumperScan to translate @type event: BumperScan @return a BumperData translated from event # bumper LEFT = 0 CENTER = 1 RIGHT = 2 # state RELEASED = 0 PRESSED = 1
[ "Translates", "from", "ROS", "BumperScan", "to", "JderobotTypes", "BumperData", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/listenerBumper.py#L11-L36
train
229,961
JdeRobot/base
src/libs/comm_py/comm/ros/listenerBumper.py
ListenerBumper.__callback
def __callback (self, event): ''' Callback function to receive and save Bumper Scans. @param event: ROS BumperScan received @type event: BumperScan ''' bump = bumperEvent2BumperData(event) if bump.state == 1: self.lock.acquire() self.time = current_milli_time() self.data = bump self.lock.release()
python
def __callback (self, event): ''' Callback function to receive and save Bumper Scans. @param event: ROS BumperScan received @type event: BumperScan ''' bump = bumperEvent2BumperData(event) if bump.state == 1: self.lock.acquire() self.time = current_milli_time() self.data = bump self.lock.release()
[ "def", "__callback", "(", "self", ",", "event", ")", ":", "bump", "=", "bumperEvent2BumperData", "(", "event", ")", "if", "bump", ".", "state", "==", "1", ":", "self", ".", "lock", ".", "acquire", "(", ")", "self", ".", "time", "=", "current_milli_time...
Callback function to receive and save Bumper Scans. @param event: ROS BumperScan received @type event: BumperScan
[ "Callback", "function", "to", "receive", "and", "save", "Bumper", "Scans", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/listenerBumper.py#L58-L73
train
229,962
JdeRobot/base
src/libs/comm_py/comm/ros/listenerBumper.py
ListenerBumper.getBumperData
def getBumperData(self): ''' Returns last BumperData. @return last JdeRobotTypes BumperData saved ''' self.lock.acquire() t = current_milli_time() if (t - self.time) > 500: self.data.state = 0 bump = self.data self.lock.release() return bump
python
def getBumperData(self): ''' Returns last BumperData. @return last JdeRobotTypes BumperData saved ''' self.lock.acquire() t = current_milli_time() if (t - self.time) > 500: self.data.state = 0 bump = self.data self.lock.release() return bump
[ "def", "getBumperData", "(", "self", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "t", "=", "current_milli_time", "(", ")", "if", "(", "t", "-", "self", ".", "time", ")", ">", "500", ":", "self", ".", "data", ".", "state", "=", "0", ...
Returns last BumperData. @return last JdeRobotTypes BumperData saved
[ "Returns", "last", "BumperData", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/listenerBumper.py#L89-L103
train
229,963
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_battery.py
BatteryModule.cmd_bat
def cmd_bat(self, args): '''show battery levels''' 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)))
python
def cmd_bat(self, args): '''show battery levels''' 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)))
[ "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%%\"", ...
show battery levels
[ "show", "battery", "levels" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_battery.py#L38-L44
train
229,964
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_battery.py
BatteryModule.battery_update
def battery_update(self, SYS_STATUS): '''update battery level''' # main flight battery 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
python
def battery_update(self, SYS_STATUS): '''update battery level''' # main flight battery 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
[ "def", "battery_update", "(", "self", ",", "SYS_STATUS", ")", ":", "# main flight battery", "self", ".", "battery_level", "=", "SYS_STATUS", ".", "battery_remaining", "self", ".", "voltage_level", "=", "SYS_STATUS", ".", "voltage_battery", "self", ".", "current_batt...
update battery level
[ "update", "battery", "level" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_battery.py#L92-L99
train
229,965
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_calibration.py
CalibrationModule.cmd_accelcal
def cmd_accelcal(self, args): '''do a full 3D accel calibration''' mav = self.master # ack the APM to begin 3D calibration of accelerometers 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
python
def cmd_accelcal(self, args): '''do a full 3D accel calibration''' mav = self.master # ack the APM to begin 3D calibration of accelerometers 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
[ "def", "cmd_accelcal", "(", "self", ",", "args", ")", ":", "mav", "=", "self", ".", "master", "# ack the APM to begin 3D calibration of accelerometers", "mav", ".", "mav", ".", "command_long_send", "(", "mav", ".", "target_system", ",", "mav", ".", "target_compone...
do a full 3D accel calibration
[ "do", "a", "full", "3D", "accel", "calibration" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_calibration.py#L34-L42
train
229,966
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_calibration.py
CalibrationModule.cmd_gyrocal
def cmd_gyrocal(self, args): '''do a full gyro calibration''' 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)
python
def cmd_gyrocal(self, args): '''do a full gyro calibration''' 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)
[ "def", "cmd_gyrocal", "(", "self", ",", "args", ")", ":", "mav", "=", "self", ".", "master", "mav", ".", "mav", ".", "command_long_send", "(", "mav", ".", "target_system", ",", "mav", ".", "target_component", ",", "mavutil", ".", "mavlink", ".", "MAV_CMD...
do a full gyro calibration
[ "do", "a", "full", "gyro", "calibration" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_calibration.py#L44-L49
train
229,967
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_calibration.py
CalibrationModule.cmd_magcal
def cmd_magcal(self, args): '''control magnetometer calibration''' 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, # target_system 0, # target_component mavutil.mavlink.MAV_CMD_DO_START_MAG_CAL, # command 0, # confirmation 0, # p1: mag_mask 0, # p2: retry 1, # p3: autosave 0, # p4: delay 0, # param5 0, # param6 0) # param7 elif args[0] == 'accept': self.master.mav.command_long_send( self.settings.target_system, # target_system 0, # target_component mavutil.mavlink.MAV_CMD_DO_ACCEPT_MAG_CAL, # command 0, # confirmation 0, # p1: mag_mask 0, # param2 1, # param3 0, # param4 0, # param5 0, # param6 0) # param7 elif args[0] == 'cancel': self.master.mav.command_long_send( self.settings.target_system, # target_system 0, # target_component mavutil.mavlink.MAV_CMD_DO_CANCEL_MAG_CAL, # command 0, # confirmation 0, # p1: mag_mask 0, # param2 1, # param3 0, # param4 0, # param5 0, # param6 0)
python
def cmd_magcal(self, args): '''control magnetometer calibration''' 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, # target_system 0, # target_component mavutil.mavlink.MAV_CMD_DO_START_MAG_CAL, # command 0, # confirmation 0, # p1: mag_mask 0, # p2: retry 1, # p3: autosave 0, # p4: delay 0, # param5 0, # param6 0) # param7 elif args[0] == 'accept': self.master.mav.command_long_send( self.settings.target_system, # target_system 0, # target_component mavutil.mavlink.MAV_CMD_DO_ACCEPT_MAG_CAL, # command 0, # confirmation 0, # p1: mag_mask 0, # param2 1, # param3 0, # param4 0, # param5 0, # param6 0) # param7 elif args[0] == 'cancel': self.master.mav.command_long_send( self.settings.target_system, # target_system 0, # target_component mavutil.mavlink.MAV_CMD_DO_CANCEL_MAG_CAL, # command 0, # confirmation 0, # p1: mag_mask 0, # param2 1, # param3 0, # param4 0, # param5 0, # param6 0)
[ "def", "cmd_magcal", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "<", "1", ":", "print", "(", "\"Usage: magcal <start|accept|cancel>\"", ")", "return", "if", "args", "[", "0", "]", "==", "'start'", ":", "self", ".", "master", "."...
control magnetometer calibration
[ "control", "magnetometer", "calibration" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_calibration.py#L114-L158
train
229,968
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py
FenceModule.set_fence_enabled
def set_fence_enabled(self, do_enable): '''Enable or disable fence''' 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)
python
def set_fence_enabled(self, do_enable): '''Enable or disable fence''' 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)
[ "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_EN...
Enable or disable fence
[ "Enable", "or", "disable", "fence" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py#L96-L102
train
229,969
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py
FenceModule.cmd_fence_move
def cmd_fence_move(self, args): '''handle fencepoint move''' 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 try: latlon = self.module('map').click_position except Exception: print("No map available") return if latlon is None: print("No map click position available") return # note we don't subtract 1, as first fence point is the return point self.fenceloader.move(idx, latlon[0], latlon[1]) if self.send_fence(): print("Moved fence point %u" % idx)
python
def cmd_fence_move(self, args): '''handle fencepoint move''' 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 try: latlon = self.module('map').click_position except Exception: print("No map available") return if latlon is None: print("No map click position available") return # note we don't subtract 1, as first fence point is the return point self.fenceloader.move(idx, latlon[0], latlon[1]) if self.send_fence(): print("Moved fence point %u" % idx)
[ "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 poin...
handle fencepoint move
[ "handle", "fencepoint", "move" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py#L104-L130
train
229,970
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py
FenceModule.cmd_fence_remove
def cmd_fence_remove(self, args): '''handle fencepoint remove''' 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) return # note we don't subtract 1, as first fence point is the return point self.fenceloader.remove(idx) if self.send_fence(): print("Removed fence point %u" % idx) else: print("Failed to remove fence point %u" % idx)
python
def cmd_fence_remove(self, args): '''handle fencepoint remove''' 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) return # note we don't subtract 1, as first fence point is the return point self.fenceloader.remove(idx) if self.send_fence(): print("Removed fence point %u" % idx) else: print("Failed to remove fence point %u" % idx)
[ "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 ...
handle fencepoint remove
[ "handle", "fencepoint", "remove" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py#L132-L151
train
229,971
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py
FenceModule.send_fence
def send_fence(self): '''send fence points from fenceloader''' # must disable geo-fencing when loading 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.mavlink.FENCE_ACTION_NONE, 3) self.param_set('FENCE_TOTAL', self.fenceloader.count(), 3) for i in range(self.fenceloader.count()): p = self.fenceloader.point(i) self.master.mav.send(p) p2 = self.fetch_fence_point(i) if p2 is None: self.param_set('FENCE_ACTION', action, 3) return False if (p.idx != p2.idx or abs(p.lat - p2.lat) >= 0.00003 or abs(p.lng - p2.lng) >= 0.00003): print("Failed to send fence point %u" % i) self.param_set('FENCE_ACTION', action, 3) return False self.param_set('FENCE_ACTION', action, 3) return True
python
def send_fence(self): '''send fence points from fenceloader''' # must disable geo-fencing when loading 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.mavlink.FENCE_ACTION_NONE, 3) self.param_set('FENCE_TOTAL', self.fenceloader.count(), 3) for i in range(self.fenceloader.count()): p = self.fenceloader.point(i) self.master.mav.send(p) p2 = self.fetch_fence_point(i) if p2 is None: self.param_set('FENCE_ACTION', action, 3) return False if (p.idx != p2.idx or abs(p.lat - p2.lat) >= 0.00003 or abs(p.lng - p2.lng) >= 0.00003): print("Failed to send fence point %u" % i) self.param_set('FENCE_ACTION', action, 3) return False self.param_set('FENCE_ACTION', action, 3) return True
[ "def", "send_fence", "(", "self", ")", ":", "# must disable geo-fencing when loading", "self", ".", "fenceloader", ".", "target_system", "=", "self", ".", "target_system", "self", ".", "fenceloader", ".", "target_component", "=", "self", ".", "target_component", "se...
send fence points from fenceloader
[ "send", "fence", "points", "from", "fenceloader" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py#L208-L231
train
229,972
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py
FenceModule.fetch_fence_point
def fetch_fence_point(self ,i): '''fetch one fence point''' 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(0.1) continue if p is None: self.console.error("Failed to fetch point %u" % i) return None return p
python
def fetch_fence_point(self ,i): '''fetch one fence point''' 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(0.1) continue if p is None: self.console.error("Failed to fetch point %u" % i) return None return p
[ "def", "fetch_fence_point", "(", "self", ",", "i", ")", ":", "self", ".", "master", ".", "mav", ".", "fence_fetch_point_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "i", ")", "tstart", "=", "time", ".", "time", "("...
fetch one fence point
[ "fetch", "one", "fence", "point" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py#L233-L248
train
229,973
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py
FenceModule.fence_draw_callback
def fence_draw_callback(self, points): '''callback from drawing a fence''' 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 = (lat+width/2, lon+height/2) self.fenceloader.add_latlon(center[0], center[1]) for p in points: self.fenceloader.add_latlon(p[0], p[1]) # close it self.fenceloader.add_latlon(points[0][0], points[0][1]) self.send_fence() self.have_list = True
python
def fence_draw_callback(self, points): '''callback from drawing a fence''' 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 = (lat+width/2, lon+height/2) self.fenceloader.add_latlon(center[0], center[1]) for p in points: self.fenceloader.add_latlon(p[0], p[1]) # close it self.fenceloader.add_latlon(points[0][0], points[0][1]) self.send_fence() self.have_list = True
[ "def", "fence_draw_callback", "(", "self", ",", "points", ")", ":", "self", ".", "fenceloader", ".", "clear", "(", ")", "if", "len", "(", "points", ")", "<", "3", ":", "return", "self", ".", "fenceloader", ".", "target_system", "=", "self", ".", "targe...
callback from drawing a fence
[ "callback", "from", "drawing", "a", "fence" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py#L250-L266
train
229,974
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_console.py
ConsoleModule.add_menu
def add_menu(self, menu): '''add a new menu''' self.menu.add(menu) self.mpstate.console.set_menu(self.menu, self.menu_callback)
python
def add_menu(self, menu): '''add a new menu''' self.menu.add(menu) self.mpstate.console.set_menu(self.menu, self.menu_callback)
[ "def", "add_menu", "(", "self", ",", "menu", ")", ":", "self", ".", "menu", ".", "add", "(", "menu", ")", "self", ".", "mpstate", ".", "console", ".", "set_menu", "(", "self", ".", "menu", ",", "self", ".", "menu_callback", ")" ]
add a new menu
[ "add", "a", "new", "menu" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_console.py#L67-L70
train
229,975
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_console.py
ConsoleModule.estimated_time_remaining
def estimated_time_remaining(self, lat, lon, wpnum, speed): '''estimate time remaining in mission in seconds''' 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.wp(idx) if w.command == mavutil.mavlink.MAV_CMD_DO_JUMP: idx = int(w.param1) continue idx += 1 if (w.x != 0 or w.y != 0) and w.command in [mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, mavutil.mavlink.MAV_CMD_NAV_LOITER_UNLIM, mavutil.mavlink.MAV_CMD_NAV_LOITER_TURNS, mavutil.mavlink.MAV_CMD_NAV_LOITER_TIME, mavutil.mavlink.MAV_CMD_NAV_LAND, mavutil.mavlink.MAV_CMD_NAV_TAKEOFF]: distance += mp_util.gps_distance(lat, lon, w.x, w.y) lat = w.x lon = w.y if w.command == mavutil.mavlink.MAV_CMD_NAV_LAND: break return distance / speed
python
def estimated_time_remaining(self, lat, lon, wpnum, speed): '''estimate time remaining in mission in seconds''' 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.wp(idx) if w.command == mavutil.mavlink.MAV_CMD_DO_JUMP: idx = int(w.param1) continue idx += 1 if (w.x != 0 or w.y != 0) and w.command in [mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, mavutil.mavlink.MAV_CMD_NAV_LOITER_UNLIM, mavutil.mavlink.MAV_CMD_NAV_LOITER_TURNS, mavutil.mavlink.MAV_CMD_NAV_LOITER_TIME, mavutil.mavlink.MAV_CMD_NAV_LAND, mavutil.mavlink.MAV_CMD_NAV_TAKEOFF]: distance += mp_util.gps_distance(lat, lon, w.x, w.y) lat = w.x lon = w.y if w.command == mavutil.mavlink.MAV_CMD_NAV_LAND: break return distance / speed
[ "def", "estimated_time_remaining", "(", "self", ",", "lat", ",", "lon", ",", "wpnum", ",", "speed", ")", ":", "idx", "=", "wpnum", "if", "wpnum", ">=", "self", ".", "module", "(", "'wp'", ")", ".", "wploader", ".", "count", "(", ")", ":", "return", ...
estimate time remaining in mission in seconds
[ "estimate", "time", "remaining", "in", "mission", "in", "seconds" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_console.py#L90-L117
train
229,976
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
Vector3.angle
def angle(self, v): '''return the angle between this vector and another vector''' return acos((self * v) / (self.length() * v.length()))
python
def angle(self, v): '''return the angle between this vector and another vector''' return acos((self * v) / (self.length() * v.length()))
[ "def", "angle", "(", "self", ",", "v", ")", ":", "return", "acos", "(", "(", "self", "*", "v", ")", "/", "(", "self", ".", "length", "(", ")", "*", "v", ".", "length", "(", ")", ")", ")" ]
return the angle between this vector and another vector
[ "return", "the", "angle", "between", "this", "vector", "and", "another", "vector" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L114-L116
train
229,977
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
Matrix3.from_euler
def from_euler(self, roll, pitch, yaw): '''fill the matrix from Euler angles in radians''' 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 * sy) + (cr * cy) self.b.z = (cr * sp * sy) - (sr * cy) self.c.x = -sp self.c.y = sr * cp self.c.z = cr * cp
python
def from_euler(self, roll, pitch, yaw): '''fill the matrix from Euler angles in radians''' 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 * sy) + (cr * cy) self.b.z = (cr * sp * sy) - (sr * cy) self.c.x = -sp self.c.y = sr * cp self.c.z = cr * cp
[ "def", "from_euler", "(", "self", ",", "roll", ",", "pitch", ",", "yaw", ")", ":", "cp", "=", "cos", "(", "pitch", ")", "sp", "=", "sin", "(", "pitch", ")", "sr", "=", "sin", "(", "roll", ")", "cr", "=", "cos", "(", "roll", ")", "sy", "=", ...
fill the matrix from Euler angles in radians
[ "fill", "the", "matrix", "from", "Euler", "angles", "in", "radians" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L154-L171
train
229,978
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
Matrix3.from_euler312
def from_euler312(self, roll, pitch, yaw): '''fill the matrix from Euler angles in radians in 312 convention''' 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 = c3*s1 + s3*s2*c1 self.b.z = s1*s3 - s2*c1*c3 self.c.x = -s3*c2 self.c.y = s2
python
def from_euler312(self, roll, pitch, yaw): '''fill the matrix from Euler angles in radians in 312 convention''' 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 = c3*s1 + s3*s2*c1 self.b.z = s1*s3 - s2*c1*c3 self.c.x = -s3*c2 self.c.y = s2
[ "def", "from_euler312", "(", "self", ",", "roll", ",", "pitch", ",", "yaw", ")", ":", "c3", "=", "cos", "(", "pitch", ")", "s3", "=", "sin", "(", "pitch", ")", "s2", "=", "sin", "(", "roll", ")", "c2", "=", "cos", "(", "roll", ")", "s1", "=",...
fill the matrix from Euler angles in radians in 312 convention
[ "fill", "the", "matrix", "from", "Euler", "angles", "in", "radians", "in", "312", "convention" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L201-L218
train
229,979
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
Matrix3.rotate
def rotate(self, g): '''rotate the matrix by a given amount on 3 axes''' 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 = b.z * g.x - b.x * g.z temp_matrix.b.z = b.x * g.y - b.y * g.x temp_matrix.c.x = c.y * g.z - c.z * g.y temp_matrix.c.y = c.z * g.x - c.x * g.z temp_matrix.c.z = c.x * g.y - c.y * g.x self.a += temp_matrix.a self.b += temp_matrix.b self.c += temp_matrix.c
python
def rotate(self, g): '''rotate the matrix by a given amount on 3 axes''' 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 = b.z * g.x - b.x * g.z temp_matrix.b.z = b.x * g.y - b.y * g.x temp_matrix.c.x = c.y * g.z - c.z * g.y temp_matrix.c.y = c.z * g.x - c.x * g.z temp_matrix.c.z = c.x * g.y - c.y * g.x self.a += temp_matrix.a self.b += temp_matrix.b self.c += temp_matrix.c
[ "def", "rotate", "(", "self", ",", "g", ")", ":", "temp_matrix", "=", "Matrix3", "(", ")", "a", "=", "self", ".", "a", "b", "=", "self", ".", "b", "c", "=", "self", ".", "c", "temp_matrix", ".", "a", ".", "x", "=", "a", ".", "y", "*", "g", ...
rotate the matrix by a given amount on 3 axes
[ "rotate", "the", "matrix", "by", "a", "given", "amount", "on", "3", "axes" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L262-L279
train
229,980
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
Matrix3.normalize
def normalize(self): '''re-normalise a rotation matrix''' 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())
python
def normalize(self): '''re-normalise a rotation matrix''' 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())
[ "def", "normalize", "(", "self", ")", ":", "error", "=", "self", ".", "a", "*", "self", ".", "b", "t0", "=", "self", ".", "a", "-", "(", "self", ".", "b", "*", "(", "0.5", "*", "error", ")", ")", "t1", "=", "self", ".", "b", "-", "(", "se...
re-normalise a rotation matrix
[ "re", "-", "normalise", "a", "rotation", "matrix" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L281-L289
train
229,981
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
Matrix3.trace
def trace(self): '''the trace of the matrix''' return self.a.x + self.b.y + self.c.z
python
def trace(self): '''the trace of the matrix''' return self.a.x + self.b.y + self.c.z
[ "def", "trace", "(", "self", ")", ":", "return", "self", ".", "a", ".", "x", "+", "self", ".", "b", ".", "y", "+", "self", ".", "c", ".", "z" ]
the trace of the matrix
[ "the", "trace", "of", "the", "matrix" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L291-L293
train
229,982
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
Matrix3.from_axis_angle
def from_axis_angle(self, axis, angle): '''create a rotation matrix from axis and 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 = ct + (1-ct) * uy**2 self.b.z = uy*uz*(1-ct) - ux*st self.c.x = uz*ux*(1-ct) - uy*st self.c.y = uz*uy*(1-ct) + ux*st self.c.z = ct + (1-ct) * uz**2
python
def from_axis_angle(self, axis, angle): '''create a rotation matrix from axis and 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 = ct + (1-ct) * uy**2 self.b.z = uy*uz*(1-ct) - ux*st self.c.x = uz*ux*(1-ct) - uy*st self.c.y = uz*uy*(1-ct) + ux*st self.c.z = ct + (1-ct) * uz**2
[ "def", "from_axis_angle", "(", "self", ",", "axis", ",", "angle", ")", ":", "ux", "=", "axis", ".", "x", "uy", "=", "axis", ".", "y", "uz", "=", "axis", ".", "z", "ct", "=", "cos", "(", "angle", ")", "st", "=", "sin", "(", "angle", ")", "self...
create a rotation matrix from axis and angle
[ "create", "a", "rotation", "matrix", "from", "axis", "and", "angle" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L295-L310
train
229,983
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
Matrix3.from_two_vectors
def from_two_vectors(self, vec1, vec2): '''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''' angle = vec1.angle(vec2) cross = vec1 % vec2 if cross.length() == 0: # the two vectors are colinear return self.from_euler(0,0,angle) cross.normalize() return self.from_axis_angle(cross, angle)
python
def from_two_vectors(self, vec1, vec2): '''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''' angle = vec1.angle(vec2) cross = vec1 % vec2 if cross.length() == 0: # the two vectors are colinear return self.from_euler(0,0,angle) cross.normalize() return self.from_axis_angle(cross, angle)
[ "def", "from_two_vectors", "(", "self", ",", "vec1", ",", "vec2", ")", ":", "angle", "=", "vec1", ".", "angle", "(", "vec2", ")", "cross", "=", "vec1", "%", "vec2", "if", "cross", ".", "length", "(", ")", "==", "0", ":", "# the two vectors are colinear...
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
[ "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" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L313-L323
train
229,984
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
Line.plane_intersection
def plane_intersection(self, plane, forward_only=False): '''return point where line intersects with a plane''' l_dot_n = self.vector * plane.normal if l_dot_n == 0.0: # line is parallel to the plane 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
python
def plane_intersection(self, plane, forward_only=False): '''return point where line intersects with a plane''' l_dot_n = self.vector * plane.normal if l_dot_n == 0.0: # line is parallel to the plane 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
[ "def", "plane_intersection", "(", "self", ",", "plane", ",", "forward_only", "=", "False", ")", ":", "l_dot_n", "=", "self", ".", "vector", "*", "plane", ".", "normal", "if", "l_dot_n", "==", "0.0", ":", "# line is parallel to the plane", "return", "None", "...
return point where line intersects with a plane
[ "return", "point", "where", "line", "intersects", "with", "a", "plane" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L348-L357
train
229,985
JdeRobot/base
src/libs/comm_py/comm/ice/rgbdIceClient.py
RgbdCamera.getRgbd
def getRgbd(self): ''' Returns last Rgbd. @return last JdeRobotTypes Rgbd saved ''' img = Rgb() if self.hasproxy(): self.lock.acquire() img = self.image self.lock.release() return img
python
def getRgbd(self): ''' Returns last Rgbd. @return last JdeRobotTypes Rgbd saved ''' img = Rgb() if self.hasproxy(): self.lock.acquire() img = self.image self.lock.release() return img
[ "def", "getRgbd", "(", "self", ")", ":", "img", "=", "Rgb", "(", ")", "if", "self", ".", "hasproxy", "(", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "img", "=", "self", ".", "image", "self", ".", "lock", ".", "release", "(", ")", ...
Returns last Rgbd. @return last JdeRobotTypes Rgbd saved
[ "Returns", "last", "Rgbd", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ice/rgbdIceClient.py#L97-L109
train
229,986
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_graph.py
Graph.add_mavlink_packet
def add_mavlink_packet(self, msg): '''add data to the graph''' 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) if self.livegraph is not None: self.livegraph.add_values(self.values)
python
def add_mavlink_packet(self, msg): '''add data to the graph''' 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) if self.livegraph is not None: self.livegraph.add_values(self.values)
[ "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", ...
add data to the graph
[ "add", "data", "to", "the", "graph" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_graph.py#L104-L115
train
229,987
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/generator/mavgen_javascript.py
generate
def generate(basename, xml): '''generate complete javascript implementation''' 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[0].little_endian: m.fmtstr = '<' else: m.fmtstr = '>' for f in m.ordered_fields: m.fmtstr += mavfmt(f) m.order_map = [ 0 ] * len(m.fieldnames) for i in range(0, len(m.fieldnames)): m.order_map[i] = m.ordered_fieldnames.index(m.fieldnames[i]) print("Generating %s" % filename) outf = open(filename, "w") generate_preamble(outf, msgs, filelist, xml[0]) generate_enums(outf, enums) generate_message_ids(outf, msgs) generate_classes(outf, msgs) generate_mavlink_class(outf, msgs, xml[0]) generate_footer(outf) outf.close() print("Generated %s OK" % filename)
python
def generate(basename, xml): '''generate complete javascript implementation''' 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[0].little_endian: m.fmtstr = '<' else: m.fmtstr = '>' for f in m.ordered_fields: m.fmtstr += mavfmt(f) m.order_map = [ 0 ] * len(m.fieldnames) for i in range(0, len(m.fieldnames)): m.order_map[i] = m.ordered_fieldnames.index(m.fieldnames[i]) print("Generating %s" % filename) outf = open(filename, "w") generate_preamble(outf, msgs, filelist, xml[0]) generate_enums(outf, enums) generate_message_ids(outf, msgs) generate_classes(outf, msgs) generate_mavlink_class(outf, msgs, xml[0]) generate_footer(outf) outf.close() print("Generated %s OK" % filename)
[ "def", "generate", "(", "basename", ",", "xml", ")", ":", "if", "basename", ".", "endswith", "(", "'.js'", ")", ":", "filename", "=", "basename", "else", ":", "filename", "=", "basename", "+", "'.js'", "msgs", "=", "[", "]", "enums", "=", "[", "]", ...
generate complete javascript implementation
[ "generate", "complete", "javascript", "implementation" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/generator/mavgen_javascript.py#L538-L574
train
229,988
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavflightmodes.py
flight_modes
def flight_modes(logfile): '''show flight modes for a log file''' 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_match(type=['SYS_STATUS','HEARTBEAT','MODE'], condition='MAV.flightmode!="%s"' % mlog.flightmode) if m is None: break print('%s MAV.flightmode=%-12s (MAV.timestamp=%u %u%%)' % ( time.asctime(time.localtime(m._timestamp)), mlog.flightmode, m._timestamp, mlog.percent)) mode = mlog.flightmode if (mode not in time_in_mode): time_in_mode[mode] = 0 if (mode_start_timestamp == -1): mode_start_timestamp = m._timestamp elif (previous_mode != "" and previous_mode != mode): time_in_mode[previous_mode] = time_in_mode[previous_mode] + (m._timestamp - mode_start_timestamp) #figure out how many seconds per percentage point so I can #caculate how many seconds for the final mode if (seconds_per_percent == -1 and previous_percent != -1 and previous_percent != mlog.percent): seconds_per_percent = (m._timestamp - mode_start_timestamp) / (mlog.percent - previous_percent) mode_start_timestamp = m._timestamp previous_mode = mode previous_percent = mlog.percent #put a whitespace line before the per-mode report print() print("Time per mode:") #need to get the time in the final mode if (seconds_per_percent != -1): seconds_remaining = (100.0 - previous_percent) * seconds_per_percent time_in_mode[previous_mode] = time_in_mode[previous_mode] + seconds_remaining total_flight_time = 0 for key, value in time_in_mode.iteritems(): total_flight_time = total_flight_time + value for key, value in time_in_mode.iteritems(): print('%-12s %s %.2f%%' % (key, str(datetime.timedelta(seconds=int(value))), (value / total_flight_time) * 100.0)) else: #can't print time in mode if only one mode during flight print(previous_mode, " 100% of flight time")
python
def flight_modes(logfile): '''show flight modes for a log file''' 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_match(type=['SYS_STATUS','HEARTBEAT','MODE'], condition='MAV.flightmode!="%s"' % mlog.flightmode) if m is None: break print('%s MAV.flightmode=%-12s (MAV.timestamp=%u %u%%)' % ( time.asctime(time.localtime(m._timestamp)), mlog.flightmode, m._timestamp, mlog.percent)) mode = mlog.flightmode if (mode not in time_in_mode): time_in_mode[mode] = 0 if (mode_start_timestamp == -1): mode_start_timestamp = m._timestamp elif (previous_mode != "" and previous_mode != mode): time_in_mode[previous_mode] = time_in_mode[previous_mode] + (m._timestamp - mode_start_timestamp) #figure out how many seconds per percentage point so I can #caculate how many seconds for the final mode if (seconds_per_percent == -1 and previous_percent != -1 and previous_percent != mlog.percent): seconds_per_percent = (m._timestamp - mode_start_timestamp) / (mlog.percent - previous_percent) mode_start_timestamp = m._timestamp previous_mode = mode previous_percent = mlog.percent #put a whitespace line before the per-mode report print() print("Time per mode:") #need to get the time in the final mode if (seconds_per_percent != -1): seconds_remaining = (100.0 - previous_percent) * seconds_per_percent time_in_mode[previous_mode] = time_in_mode[previous_mode] + seconds_remaining total_flight_time = 0 for key, value in time_in_mode.iteritems(): total_flight_time = total_flight_time + value for key, value in time_in_mode.iteritems(): print('%-12s %s %.2f%%' % (key, str(datetime.timedelta(seconds=int(value))), (value / total_flight_time) * 100.0)) else: #can't print time in mode if only one mode during flight print(previous_mode, " 100% of flight time")
[ "def", "flight_modes", "(", "logfile", ")", ":", "print", "(", "\"Processing log %s\"", "%", "filename", ")", "mlog", "=", "mavutil", ".", "mavlink_connection", "(", "filename", ")", "mode", "=", "\"\"", "previous_mode", "=", "\"\"", "mode_start_timestamp", "=",...
show flight modes for a log file
[ "show", "flight", "modes", "for", "a", "log", "file" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavflightmodes.py#L18-L80
train
229,989
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py
have_graph
def have_graph(name): '''return true if we have a graph of the given name''' for g in mestate.graphs: if g.name == name: return True return False
python
def have_graph(name): '''return true if we have a graph of the given name''' for g in mestate.graphs: if g.name == name: return True return False
[ "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
[ "return", "true", "if", "we", "have", "a", "graph", "of", "the", "given", "name" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py#L67-L72
train
229,990
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py
expression_ok
def expression_ok(expression): '''return True if an expression is OK with current messages''' 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
python
def expression_ok(expression): '''return True if an expression is OK with current messages''' 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
[ "def", "expression_ok", "(", "expression", ")", ":", "expression_ok", "=", "True", "fields", "=", "expression", ".", "split", "(", ")", "for", "f", "in", "fields", ":", "try", ":", "if", "f", ".", "endswith", "(", "':2'", ")", ":", "f", "=", "f", "...
return True if an expression is OK with current messages
[ "return", "True", "if", "an", "expression", "is", "OK", "with", "current", "messages" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py#L129-L142
train
229,991
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py
load_graph_xml
def load_graph_xml(xml, filename, load_all=False): '''load a graph from one xml string''' 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.expression] if load_all: ret.append(GraphDefinition(name, e, g.description.text, expressions, filename)) continue if have_graph(name): continue for e in expressions: if expression_ok(e): ret.append(GraphDefinition(name, e, g.description.text, expressions, filename)) break return ret
python
def load_graph_xml(xml, filename, load_all=False): '''load a graph from one xml string''' 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.expression] if load_all: ret.append(GraphDefinition(name, e, g.description.text, expressions, filename)) continue if have_graph(name): continue for e in expressions: if expression_ok(e): ret.append(GraphDefinition(name, e, g.description.text, expressions, filename)) break return ret
[ "def", "load_graph_xml", "(", "xml", ",", "filename", ",", "load_all", "=", "False", ")", ":", "ret", "=", "[", "]", "try", ":", "root", "=", "objectify", ".", "fromstring", "(", "xml", ")", "except", "Exception", ":", "return", "[", "]", "if", "root...
load a graph from one xml string
[ "load", "a", "graph", "from", "one", "xml", "string" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py#L144-L167
train
229,992
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py
cmd_condition
def cmd_condition(args): '''control MAVExporer conditions''' 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
python
def cmd_condition(args): '''control MAVExporer conditions''' 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
[ "def", "cmd_condition", "(", "args", ")", ":", "if", "len", "(", "args", ")", "==", "0", ":", "print", "(", "\"condition is: %s\"", "%", "mestate", ".", "settings", ".", "condition", ")", "return", "mestate", ".", "settings", ".", "condition", "=", "' '"...
control MAVExporer conditions
[ "control", "MAVExporer", "conditions" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py#L260-L267
train
229,993
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ualberta.py
MAVLink.ualberta_sys_status_send
def ualberta_sys_status_send(self, mode, nav_mode, pilot, force_mavlink1=False): ''' System status specific to ualberta uav mode : System mode, see UALBERTA_AUTOPILOT_MODE ENUM (uint8_t) nav_mode : Navigation mode, see UALBERTA_NAV_MODE ENUM (uint8_t) pilot : Pilot mode, see UALBERTA_PILOT_MODE (uint8_t) ''' return self.send(self.ualberta_sys_status_encode(mode, nav_mode, pilot), force_mavlink1=force_mavlink1)
python
def ualberta_sys_status_send(self, mode, nav_mode, pilot, force_mavlink1=False): ''' System status specific to ualberta uav mode : System mode, see UALBERTA_AUTOPILOT_MODE ENUM (uint8_t) nav_mode : Navigation mode, see UALBERTA_NAV_MODE ENUM (uint8_t) pilot : Pilot mode, see UALBERTA_PILOT_MODE (uint8_t) ''' return self.send(self.ualberta_sys_status_encode(mode, nav_mode, pilot), force_mavlink1=force_mavlink1)
[ "def", "ualberta_sys_status_send", "(", "self", ",", "mode", ",", "nav_mode", ",", "pilot", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "ualberta_sys_status_encode", "(", "mode", ",", "nav_mode", ",", "pilo...
System status specific to ualberta uav mode : System mode, see UALBERTA_AUTOPILOT_MODE ENUM (uint8_t) nav_mode : Navigation mode, see UALBERTA_NAV_MODE ENUM (uint8_t) pilot : Pilot mode, see UALBERTA_PILOT_MODE (uint8_t)
[ "System", "status", "specific", "to", "ualberta", "uav" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ualberta.py#L7434-L7443
train
229,994
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ualberta.py
MAVLink.button_change_send
def button_change_send(self, time_boot_ms, last_change_ms, state, force_mavlink1=False): ''' Report button state change time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t) last_change_ms : Time of last change of button state (uint32_t) state : Bitmap state of buttons (uint8_t) ''' return self.send(self.button_change_encode(time_boot_ms, last_change_ms, state), force_mavlink1=force_mavlink1)
python
def button_change_send(self, time_boot_ms, last_change_ms, state, force_mavlink1=False): ''' Report button state change time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t) last_change_ms : Time of last change of button state (uint32_t) state : Bitmap state of buttons (uint8_t) ''' return self.send(self.button_change_encode(time_boot_ms, last_change_ms, state), force_mavlink1=force_mavlink1)
[ "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"...
Report button state change time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t) last_change_ms : Time of last change of button state (uint32_t) state : Bitmap state of buttons (uint8_t)
[ "Report", "button", "state", "change" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ualberta.py#L12186-L12195
train
229,995
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/lib/ANUGA/redfearn.py
convert_from_latlon_to_utm
def convert_from_latlon_to_utm(points=None, latitudes=None, longitudes=None, false_easting=None, false_northing=None): """Convert latitude and longitude data to UTM as a list of coordinates. Input points: list of points given in decimal degrees (latitude, longitude) or latitudes: list of latitudes and longitudes: list of longitudes false_easting (optional) false_northing (optional) Output points: List of converted points zone: Common UTM zone for converted points Notes Assume the false_easting and false_northing are the same for each list. If points end up in different UTM zones, an ANUGAerror is thrown. """ old_geo = Geo_reference() utm_points = [] if points == None: assert len(latitudes) == len(longitudes) points = map(None, latitudes, longitudes) for point in points: zone, easting, northing = redfearn(float(point[0]), float(point[1]), false_easting=false_easting, false_northing=false_northing) new_geo = Geo_reference(zone) old_geo.reconcile_zones(new_geo) utm_points.append([easting, northing]) return utm_points, old_geo.get_zone()
python
def convert_from_latlon_to_utm(points=None, latitudes=None, longitudes=None, false_easting=None, false_northing=None): """Convert latitude and longitude data to UTM as a list of coordinates. Input points: list of points given in decimal degrees (latitude, longitude) or latitudes: list of latitudes and longitudes: list of longitudes false_easting (optional) false_northing (optional) Output points: List of converted points zone: Common UTM zone for converted points Notes Assume the false_easting and false_northing are the same for each list. If points end up in different UTM zones, an ANUGAerror is thrown. """ old_geo = Geo_reference() utm_points = [] if points == None: assert len(latitudes) == len(longitudes) points = map(None, latitudes, longitudes) for point in points: zone, easting, northing = redfearn(float(point[0]), float(point[1]), false_easting=false_easting, false_northing=false_northing) new_geo = Geo_reference(zone) old_geo.reconcile_zones(new_geo) utm_points.append([easting, northing]) return utm_points, old_geo.get_zone()
[ "def", "convert_from_latlon_to_utm", "(", "points", "=", "None", ",", "latitudes", "=", "None", ",", "longitudes", "=", "None", ",", "false_easting", "=", "None", ",", "false_northing", "=", "None", ")", ":", "old_geo", "=", "Geo_reference", "(", ")", "utm_p...
Convert latitude and longitude data to UTM as a list of coordinates. Input points: list of points given in decimal degrees (latitude, longitude) or latitudes: list of latitudes and longitudes: list of longitudes false_easting (optional) false_northing (optional) Output points: List of converted points zone: Common UTM zone for converted points Notes Assume the false_easting and false_northing are the same for each list. If points end up in different UTM zones, an ANUGAerror is thrown.
[ "Convert", "latitude", "and", "longitude", "data", "to", "UTM", "as", "a", "list", "of", "coordinates", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/lib/ANUGA/redfearn.py#L199-L243
train
229,996
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/quaternion.py
QuaternionBase.dcm
def dcm(self): """ Get the DCM :returns: 3x3 array """ if self._dcm is None: if self._q is not None: # try to get dcm from q self._dcm = self._q_to_dcm(self.q) elif self._euler is not None: # try to get get dcm from euler self._dcm = self._euler_to_dcm(self._euler) return self._dcm
python
def dcm(self): """ Get the DCM :returns: 3x3 array """ if self._dcm is None: if self._q is not None: # try to get dcm from q self._dcm = self._q_to_dcm(self.q) elif self._euler is not None: # try to get get dcm from euler self._dcm = self._euler_to_dcm(self._euler) return self._dcm
[ "def", "dcm", "(", "self", ")", ":", "if", "self", ".", "_dcm", "is", "None", ":", "if", "self", ".", "_q", "is", "not", "None", ":", "# try to get dcm from q", "self", ".", "_dcm", "=", "self", ".", "_q_to_dcm", "(", "self", ".", "q", ")", "elif",...
Get the DCM :returns: 3x3 array
[ "Get", "the", "DCM" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/quaternion.py#L128-L141
train
229,997
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavgpslock.py
lock_time
def lock_time(logfile): '''work out gps lock times for a log file''' 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.mktime(time.localtime(m._timestamp)) while True: m = mlog.recv_match(type=['GPS_RAW_INT','GPS_RAW'], condition=args.condition) if m is None: if locked: total_time += time.mktime(t) - start_time if total_time > 0: print("Lock time : %u:%02u" % (int(total_time)/60, int(total_time)%60)) return total_time t = time.localtime(m._timestamp) if m.fix_type >= 2 and not locked: print("Locked at %s after %u seconds" % (time.asctime(t), time.mktime(t) - unlock_time)) locked = True start_time = time.mktime(t) elif m.fix_type == 1 and locked: print("Lost GPS lock at %s" % time.asctime(t)) locked = False total_time += time.mktime(t) - start_time unlock_time = time.mktime(t) elif m.fix_type == 0 and locked: print("Lost protocol lock at %s" % time.asctime(t)) locked = False total_time += time.mktime(t) - start_time unlock_time = time.mktime(t) return total_time
python
def lock_time(logfile): '''work out gps lock times for a log file''' 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.mktime(time.localtime(m._timestamp)) while True: m = mlog.recv_match(type=['GPS_RAW_INT','GPS_RAW'], condition=args.condition) if m is None: if locked: total_time += time.mktime(t) - start_time if total_time > 0: print("Lock time : %u:%02u" % (int(total_time)/60, int(total_time)%60)) return total_time t = time.localtime(m._timestamp) if m.fix_type >= 2 and not locked: print("Locked at %s after %u seconds" % (time.asctime(t), time.mktime(t) - unlock_time)) locked = True start_time = time.mktime(t) elif m.fix_type == 1 and locked: print("Lost GPS lock at %s" % time.asctime(t)) locked = False total_time += time.mktime(t) - start_time unlock_time = time.mktime(t) elif m.fix_type == 0 and locked: print("Lost protocol lock at %s" % time.asctime(t)) locked = False total_time += time.mktime(t) - start_time unlock_time = time.mktime(t) return total_time
[ "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...
work out gps lock times for a log file
[ "work", "out", "gps", "lock", "times", "for", "a", "log", "file" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavgpslock.py#L19-L58
train
229,998
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py
MPSlipMapFrame.on_menu
def on_menu(self, event): '''handle menu selection''' state = self.state # see if it is a popup menu 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, 0, obj.layer, obj.selection_info())], ret)) state.popup_object = None state.popup_latlon = None if state.default_popup is not None: ret = state.default_popup.popup.find_selected(event) if ret is not None: ret.call_handler() state.event_queue.put(SlipMenuEvent(state.popup_latlon, event, [], ret)) # otherwise a normal menu ret = self.menu.find_selected(event) if ret is None: return ret.call_handler() if ret.returnkey == 'toggleGrid': state.grid = ret.IsChecked() elif ret.returnkey == 'toggleFollow': state.follow = ret.IsChecked() elif ret.returnkey == 'toggleDownload': state.download = ret.IsChecked() elif ret.returnkey == 'setService': state.mt.set_service(ret.get_choice()) elif ret.returnkey == 'gotoPosition': state.panel.enter_position() elif ret.returnkey == 'increaseBrightness': state.brightness *= 1.25 elif ret.returnkey == 'decreaseBrightness': state.brightness /= 1.25 state.need_redraw = True
python
def on_menu(self, event): '''handle menu selection''' state = self.state # see if it is a popup menu 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, 0, obj.layer, obj.selection_info())], ret)) state.popup_object = None state.popup_latlon = None if state.default_popup is not None: ret = state.default_popup.popup.find_selected(event) if ret is not None: ret.call_handler() state.event_queue.put(SlipMenuEvent(state.popup_latlon, event, [], ret)) # otherwise a normal menu ret = self.menu.find_selected(event) if ret is None: return ret.call_handler() if ret.returnkey == 'toggleGrid': state.grid = ret.IsChecked() elif ret.returnkey == 'toggleFollow': state.follow = ret.IsChecked() elif ret.returnkey == 'toggleDownload': state.download = ret.IsChecked() elif ret.returnkey == 'setService': state.mt.set_service(ret.get_choice()) elif ret.returnkey == 'gotoPosition': state.panel.enter_position() elif ret.returnkey == 'increaseBrightness': state.brightness *= 1.25 elif ret.returnkey == 'decreaseBrightness': state.brightness /= 1.25 state.need_redraw = True
[ "def", "on_menu", "(", "self", ",", "event", ")", ":", "state", "=", "self", ".", "state", "# see if it is a popup menu", "if", "state", ".", "popup_object", "is", "not", "None", ":", "obj", "=", "state", ".", "popup_object", "ret", "=", "obj", ".", "pop...
handle menu selection
[ "handle", "menu", "selection" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L49-L88
train
229,999