Dựa trên các lệnh từ một trạm mặt đất thì: • Mô-đun Mode Commander sẽ chịu trách nhiệm thiết lập chế độ của các mô-đun phần mềm khác theo giai đoạn hiện tại của chuyến bay, đồng thời khở
Trang 1TÌM HIỂU 1 VÍ DỤ CU THỂ VỀ ĐẦU VÀO, ĐẦU
RA, THUẬT TOÁN CHO 1 ỨNG DỤNG VỚI
FPRIME CÁCH THỨC VIẾT CODE KHÔNG CÓ LỖI
Danh sách thành viên:
Hoàng Bích Phượng – 20172763
Lê Công Luận – 20172673
Phạm Thị Phượng – 20172764
Phan Doãn Đức – 20172486
Lê Đình Minh – 20172698
Giảng viên hướng dẫn:
PhD Huy-Dzung Han
N H Ó M 5
Trang 2• Các lệnh từ mặt đất
• Cảm biến đo lường
Output:
Các lệnh truyền động
Part 1: MARS HELICOPTER [1]
Trang 3Dựa trên các lệnh từ một trạm mặt đất thì:
• Mô-đun Mode Commander sẽ chịu trách nhiệm thiết lập chế độ của các mô-đun phần mềm khác theo giai đoạn hiện tại của chuyến bay, đồng thời khởi động bất kỳ hành động nào liên quan đến chuyển đổi giữa các chế độ.
• Mô-đun Navigation sử dụng dữ liệu cảm biến để ước tính trạng thái của phương tiện
• Mô-đun Guidance tạo ra quỹ đạo tham chiếu và tín hiệu điều khiển chuyển tiếp dựa trên giai đoạn hiện tại của chuyến bay
• Mô-đun Control bổ sung điều khiển phản hồi dựa trên sự khác biệt giữa quỹ đạo tham chiếu và trạng thái ước tính => Đưa ra lệnh của bộ truyền động
Trang 4NAVIGATION ALGORITHM [1, 2]
Thuật toán được chọn cho ứng dụng của Mars Helicopter
là MAVeN (Minimal Augmented state algorithm for
Vision-based Navigation)
• Hoạt động tương tự SLAM, trừ việc tránh tang cường
các vector đăc trưng
• MAVeN được cơ khí hoá như một bộ lọc Kalman mở
rộng (EKF) và có một số ưu điểm so với các phương
pháp đo vận tốc dựa trên tầm nhìn khác.
Vector bộ lọc 21 trạng thái được liên kết với MAVeN:
Trang 5Các thuộc tính độc nhất của MAVeN: chiếu các đặc điểm hình ảnh lên mô hình hình dạng của bề mặt đất để sử dụng làm điểm mốc giả cho hình ảnh tiếp theo
Cụ thể:
1 Xác định hình ảnh đầu tiên là hình ảnh cơ sở (Base Image)
2 Sử dụng kết quả ước tính hiện tại pB, qB để ánh xạ các đối
tượng địa lý trong hình ảnh cơ sở lên mô hình bề mặt
phẳng Ví dụ: f1; f2; f3 Các vị trí đặc trưng này sẽ đóng vai
trò là các điểm mốc giả.
3 Xác định hình ảnh tiếp theo là hình ảnh tìm kiếm (Search
image)
4 Khớp các tính năng hình ảnh tìm kiếm với các địa danh giả
được ánh xạ từ hình ảnh cơ sở gần nhất.
5 Kết hợp m mốc giả với hình học hiện tại để tạo thành một
phép đo là một hàm của cả trạng thái Cơ sở và Tìm kiếm
hiện tại:
6 Nếu số lượng các tính năng phù hợp giảm xuống dưới
ngưỡng => hãy khai báo hình ảnh tiếp theo làhình ảnh Cơ
sở mới và thực hiện [1] Nếu không, hãy khai báo hình ảnh
tiếp theo là hình ảnh Tìm kiếm và chuyển đến [3]
Trang 6Part 2 Cách thức viết code không có lỗi [3]
1 Avoid complex flow constructs, such as goto and recursion
• Do not use “ go to” statements, setjmp or longjmp contructs, and direct or indirect recursion
• ”switch contructs” requires “ break” to close the block There will be bugs
2 All loops must have fixed bounds This prevents runaway code
• To make sure that the loop won't exceed a given number of iterations
• Make sure that you always work with pages that are of a reasonable size and this way you won't need loops that could run forever
Trang 73 Avoid heap memory allocation.
• Do not use dynamic memory allocation after initialization
• Given any accepted input the memory consumption won't go beyond a
certain point
4 Restrict functions to a single printed page
• No more than about 60 lines of code per function
• You can easily organize your code into functions of about that size or smaller
and that you can easily understand those functions
• Nobody likes to land on a 1000-lines function that seems to do a gazillion
things at the same time
Trang 85 Use a minimum of two runtime assertions per function.
• The assertion density of the code should average to a minimum of two assertions per function
• Assertions must always be side-effect free and should be defined as Boolean tests
6 Restrict the scope of data to the smallest possible
• In short, don't use global variables
• You can hide your data in classes, modules, second-order functions, etc
Trang 97 Check the return value of all non-void functions, or cast to void to indicate the return value is useless.
• The return value of non-void functions must be checked by each calling function, and the validity of parameters must be checked inside each function.
• Let exceptions bubble up until you properly recover and/or report them.
8 Use the preprocessor sparingly.
• The use of the preprocessor must be limited to the inclusion of header files and simple macro definitions
• If you use transpilers, make sure that they solve more problems than they bring
Trang 109 Limit pointer use to a single dereference, and do not use function pointers
• Don't use references even if your language supports it
• Copy arguments instead of mutating them, unless it's the explicit purpose of the function
• Use as many type-safety features as you can
10 Compile with all possible warnings active; all warnings should then be addressed before release of the software
• The warnings are very smart and helpful
• Spell checkers are also surprisingly important because they will allow you to sniff out typos regardless of type analysis or any complicated static code analysis
Trang 11[1] J (Bob) Balaram, Timothy Canham, Courtney Duncan, Matt Golombek, Håvard Fjær Grip, Wayne Johnson, Justin Maki?, Amelia Quon?, Ryan Stern and David
Zhu, Mars Helicopter Technology Demonstrator DOI: 10.2514/6.2018-0023
[2] David S Bayard, Dylan T Conway, Roland Brockers, Jeff Delaune, Larry Matthies, Havard F Grip, k Gene Merewether, Travis Brown, A Miguel San
Martin, Vision-Based Navigation for the NASA Mars Helicopter DOI: 10.2514/6.2019-1411
[3]
https://dev.to/xowap/10-rules-to-code-like-nasa-applied-to-interpreted-
languages-40dd?fbclid=IwAR3jf4fC2gLYi9T0YU9vLCDBAB8vRMkyNOt0n_in-PvJfbOpHK7fMRhH7Cg