
how to get each path point for uavDubinsConnection?
5 次查看(过去 30 天)
显示 更早的评论
I am trying to turn my 2d dubins path to 3d by using the uavDubinsConnection code. My old code was;
dubinsSpace = stateSpaceDubins([0 500000; -100000 100000;-pi pi]); %In this line I determined the limits of the map
dubinsSpace.MinTurningRadius = 200;
pathobj = navPath(dubinsSpace);
append(pathobj,wayPoints); %waypoints is a matrix which consists 20 waypoints and corresponding angles
interpolate(pathobj,max(size(wayPoints))*10000); %in this line the code divides the path between two waypoints as the number ı have written
When I run this code ı get a pathobj and it has 3 properties in it, which are StateSpace, States ad NumStates.
For uavDubinsConnection I ran the code below.
connectionObj = uavDubinsConnection;
connectionObj.MaxRollAngle = deg2rad(5);
connectionObj.AirSpeed = 300;
for i = 1:1:39
pathSegObj = uavDubinsPathSegment(connectionObj,wayPoints(i,:),wayPoints(i+1,:));
end
%waypoints include x y z and heading degree of each point
When ı run the code aboje ı get a pathSegObj which includes the properties StartPose, GoalPose, FlightPathAngle, AirSpeed, MinTurningRadius, HelixRadius, MotionTypes,MotionLengths and Length. But, I dont get the states as I need. How could I get it, and how could I use the interpolate function for uavDubinsConnection.
0 个评论
回答(1 个)
Raag
2025-5-2
Hi Sinem,
From what I gather, you want to obtain all the interpolated states along a 3D Dubins path generated using ‘uavDubinsConnection’, like your previous 2D workflow.
In 3D, the path is constructed as a sequence of ‘uavDubinsPathSegment’ objects, each representing the path between two waypoints. The ‘interpolate method‘of each segment object allows you to sample points along it.
Here is how you can do this:
% Example waypoints
wayPoints = [
0 0 0 0;
100 0 10 pi/6;
200 50 20 pi/4
];
connectionObj = uavDubinsConnection;
connectionObj.MaxRollAngle = deg2rad(5);
connectionObj.AirSpeed = 30;
allStates = [];
for i = 1:size(wayPoints,1)-1
pathSegObj = uavDubinsPathSegment(connectionObj, wayPoints(i,:), wayPoints(i+1,:));
N = 20; % Number of samples per segment
lengths = linspace(0, pathSegObj.Length, N);
states = interpolate(pathSegObj, lengths);
if i == 1
allStates = [allStates; states];
else
allStates = [allStates; states(2:end,:)];
end
end
Output:

Here we are using the interpolate method for each ’uavDubinsPathSegment’ to obtain path points and then concatenate results for the full path, like your 2D workflow.
For a better understanding of the above solution, refer to the following MATLAB documentations:
1. uavdubinsconnection: https://www.mathworks.com/help/releases/R2021a/uav/ref/uavdubinsconnection.html
2. uavdubinspathsegment https://www.mathworks.com/help/releases/R2021a/uav/ref/uavdubinspathsegment.html
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!