How to change waypoints while running the simulation model when using UAV toolbox(Path Manager)?

I want to achieve a flight path like this:
There are some cars along the road, once the UAV has detected a car, it would fly towards the car, otherwise it would fly along the road.
I am trying to modify the UAV package delivery example(https://ww2.mathworks.cn/help/uav/ug/uav-package-delivery.html) to achieve this in simulink.
But it seems that the PathManager block only receive the waypoint set once.
For example,
Here I have 12 waypoints along the road, the first waypoint pair is (point1,point2), if there is no car along this road,
then the next waypoint pair is (point2, point3)
But when I change the value of GCScommands in the Multirotor block, it didn't recieve the value.
(I changed the value directly from the data dictionary)
After the UAV reach point2, it will stuck at there instead of moving forward, even I have changed the value of GCSCommands into (point2,point3).
It will still take the first 2 points as waypoints.
How can I solve this?

 Accepted Answer

Hi Shichen,
Mission data is loaded in "uavPackageDelivery/Ground Control Station/Get Flight Mission/noQGC" subsystem when model simulation starts in this example. If you want to dynamically update the mission, you can modify this subsystem to accept run time changes. Alternatviely, you can add a state machine before the control reaches "uavPackageDelivery/Multirotor (MultirotorModel)/Guidance Logic/Full Guidance Logic/Guidance Stateflow" subsystem and switch to alternative control modes when you detect a car.
Thanks,
Jianxin

5 Comments

Thank you for your reply.
Then how can I modify the "noQGC" subsystem to accept run time change? Is this in the block parameters or where can I find it?
Thank you.
You can create a matlab function block that takes in the mission values and update the corresponding items in it.
The mission value is defined as a struct with each item corresponding to one waypoint. The following function in a function block will update the 2nd waypoint according to the input.
function mission = fcn(mission, newWaypoint)
mission(2).position(:) = newWaypoint;
You can then insert this MATLAB function block between the variant select and outport and input the newWaypoint from the 2nd input port to the MATLAB function block. Similar to the attached image.
I tried implementing this but I receive an error. It seems that the function is not returning the correct type of value. I also tried making some variations by changing the name of the output (e.g., newMission) but still same error. I also tried changing the constant to [0;0;0] but still same error.
I can however manually edit the waypoints in the command window. But I need it to be in the simulink model.
I tried just passing the waypoints through the function block but it gives the same error.
function newMission = fcn(mission)
newMission = mission;
It seems like the function block does not return any signal at all. Is there any configuration I need to make to the function block to make this work?
Hi Robert,
I tried your modification. I think you need to explict set the data type for your MATLAB function block output. It should be set to Bus:uavPathManagerBus type like the screenshot shown below. You can refer to https://www.mathworks.com/help/simulink/ug/ports-and-data-manager.html to find out how to open the dialog below for MATLAB function block.
Thanks,
Jianxin

Sign in to comment.

More Answers (1)

This is an example of using MATLAB 3D Animation Toolbox for object detection and tracking with an Unmanned Aerial Vehicle. I hope this can be of help.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!