How to set a new waypoint after reaching the previous one in a Simulink flight simulation
11 次查看(过去 30 天)
显示 更早的评论
I have a PID controller for a quadcopter. Rather than inputting a time-series trajectory for it to follow, I would like to input a list of waypoints for it to visit. I have coded a boolean variable in one of the functions that turns True when the total distance to the waypoint is less than an arbitrary threshold. How do I connect this to the list of waypoints to specify that the aircraft can start heading toward the next one as soon as this boolean variable turns True?
0 个评论
回答(1 个)
Ashok
2024-12-31,5:23
Hello Benjamin,
Waypoint switching logic can be manually constructed by storing waypoints in a matrix or table and indexing through them. This can be implemented using either a MATLAB Function block or a Selector block in Simulink. Here's an example of both methods:
The flagGenerator function produces a Boolean signal that indicates when to switch to the next waypoint. The waypointSelector1 subsystem is an enabled subsystem that executes only when the flag is True; otherwise, it retains the previous output. Within this subsystem, a MATLAB function block contains the switching logic.
Alternatively, in the waypointSelector2 subsystem, a counter is created using Sum and Unit Delay blocks, and waypoint selection is performed using a Selector block. The scope output shows waypoint switching based on the flag.
For reference, the corresponding Simulink file, example_R2021a.slx, is attached. More information about the Selector block can be found in the documentation:
If waypoint navigation is to be performed using a lookahead point, check out the Waypoint Follower block.
I believe this will assist you!
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!