Tải bản đầy đủ (.pptx) (12 trang)

TÌ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 FPRIMECÁCH THỨC VIẾT CODE KHÔNG có lỗi

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (601.81 KB, 12 trang )

NHĨM 5
TÌ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

Giảng viên hướng dẫn:

Danh sách thành viên:

PhD. Huy-Dzung Han

Hồ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
9/2/21

Nhóm 5

1


Part 1: MARS HELICOPTER [1]

Input:

• Các lệnh từ mặt đất
• Cảm biến đo lường
Output:
Các lệnh truyền động



9/2/21

Nhóm 5

2


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ở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

9/2/21


Nhóm 5

3


NAVIGATION 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í hố 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:

9/2/21

Nhóm 5

4


Cá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.
2.


Xác định hình ảnh đầu tiên là hình ảnh cơ sở (Base Image)
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.
4.
5.

Xác định hình ảnh tiếp theo là hình ảnh tìm kiếm (Search image)
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.
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]

9/2/21

Nhóm 5

5


Part 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.

9/2/21

Nhóm 5

6


3. 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

9/2/21

Nhóm 5

7


5. 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

9/2/21

Nhóm 5

8


7. 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

9/2/21


Nhóm 5

9


9. 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




Use several linters and tools to analyze your code. No warning shall be ignored.

9/2/21

Nhóm 5

10


REFERENCES
[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] />fbclid=IwAR3jf4fC2gLYi9T0YU9vLCDBAB8vRMkyNOt0n_in-PvJfbOpHK7fMRhH7Cg

9/2/21

Nhóm 5

11




×