UAVPathManagerBus issue in the 3D Obstacle Avoidance UAV Package delivery
4 views (last 30 days)
Show older comments
Tudor-Stefan Tonca
on 2 Feb 2023
Commented: Tudor-Stefan Tonca
on 6 Feb 2023
Hi,
I'm trying to modify the UAV Package Delivery project such as it allows multiple waypoints while avoiding obstacles, using QGroundConrol. Until now I have done these:
-modified replaced FollowWaypoints with the guidance from FullGuidanceLogic
However, MissionData input must be bus signal "uavPathManagerBus"
Currently, the MissionData comes from the function that contains the OA algorithm:
function [y, DTD, needHover] = computeLPWaypoints(mission, Steer,UAVState)
%#codegen
Wp1 = [mission(1).position' mission(1).params(4)];
Wp2x = mission(2).position(1);
Wp2y = mission(2).position(2);
needHover = false;
% Follow obstacle avoidance steer direction when UAV is above 5 meters
% above ground
if (~any(isnan(Steer)) && (UAVState.z < -5))
if (Steer(5) == 0)
% Compute look ahead point 6 meters along the steering direction
LAP_local = 6*Steer(2:4)';
% Follow yaw command from obstacle avoidance
yaw = Steer(1);
LAP = [LAP_local yaw] + [UAVState.x, UAVState.y, UAVState.z, 0];
if(isnan(LAP(4)))
LAP(4) = 0;
end
y = [ Wp1(1,:) ; LAP ; Wp2x , Wp2y , 0 , LAP(4) ];
DTD = norm([Wp2x Wp2y] - LAP(1:2));
else
% Rotate in place
y = [ Wp1(1,:) ; UAVState.x, UAVState.y, UAVState.z Steer(1); Wp2x , Wp2y , 0 , Steer(1) ];
DTD = norm([Wp2x Wp2y] - [UAVState.x, UAVState.y]);
needHover = true;
end
else
% If there is no good steer direction or UAV is too low, fly up
y = [ Wp1(1,:) ; UAVState.x , UAVState.y , UAVState.z-2 , 0 ; Wp2x , Wp2y , 0 , 0 ];
DTD = norm([Wp2x Wp2y] - [UAVState.x, UAVState.y]);
end
if(DTD<5)
% When close to target point, switch to landing
y = [ Wp1(1,:) ; Wp2x , Wp2y, -11 , 0 ; Wp2x , Wp2y , -1 , 0 ];
end
end
I get this obvious error when I try to run the simulation:
I have tried sending the sigal from the GCS dirrectly into the MissionData (as expected), but then the quadcopter just flies back and forth around the first waypoint of the mission:
I would very much appreciate any advice on how to move further with this.
Regards,
Tudor
0 Comments
Accepted Answer
Jianxin Sun
on 2 Feb 2023
Hi Tudor,
I gave it a try to combine uavPackageDelivery/Multirotor (MultirotorModel)/Guidance Logic/Full Guidance Logic and the uavPackageDelivery/Multirotor (MultirotorModel)/Guidance Logic/Obstacle Avoidance3D so that the guidance logic and takes in the complete mission and uses Lidar for guidance when the UAV is in waypoint following mode. The goal is to create OBCCommands from path manager consists of two waypoints and pass it outside to the Onboard Computer module for obstacle avoidance. Also takes in OBCMsgs from Onboard Computer and generate position command when UAV is in waypoint following mode.
Regards,
Jianxin
8 Comments
Jianxin Sun
on 6 Feb 2023
At this point I suspect the issue is in how obstacle avoidance algorithm is tuned for your environment and sensor setup. But the model seems to be taking in the multiple waypoints from QGC.
I would suggest you take a look at the following examples and adjust your OA algorithm:
https://www.mathworks.com/help/uav/ug/uav-obstacle-avoidance-in-simulink.html
https://www.mathworks.com/help/uav/ug/tune-3d-vector-field-histogram-controller-for-obstacle-avoidance-in-3d-scene.html
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!