Area between two different kinds of data sets
2 views (last 30 days)
Show older comments
Hello everyone .. So i am designing a GUI which reads in data points of the actual position of a car beign driven by a person. The driver is to change his/her lane according to the commanded lane changes..... I have plotted the data.. there were 18 different commaded lane changes .. therefore i really didnt find a nice way of plotting the reference trajectory. So i used the function line and some code to map out the reference trajectory. .. Teh code for that is included below .. now I need to find the area between the actual trajectory and the reference trajectory. I cant seem to find a convincing way to find the area between a set of data points and a line that is defined with the help of the function "line" in Matlab. The plot of the output from the GUI is also attached below ... so the squigly line is the data points plotted .. and the solid line is the reference traj .. any help would be greatly appreciated :)
left=-3.85; % if the required trajectory is to the left
right=3.85; % if the required trajectory is to the right
middle=0; % if the required trajectory is to the middle
lane=middle; % variable to save which lane the car was in before it went to the next test section
% plot the rest of the reference trajectory
for tt=2:1:length(marker_pos)-1
if (strcmp(Data_ref(tt),'m')==1)
% if(lane==middle)
% line([ref_traj_start_for_graphing(tt) ref_traj_end_of_lane_change(tt)],[middle middle])
% line([ref_traj_end_of_lane_change(tt) marker_pos(tt)],[middle middle])
% line([marker_pos(tt),ref_traj_start_for_graphing(tt+1)],[middle middle])
% lane=middle;
% end
if (lane==left)
line([ref_traj_start_for_graphing(tt) ref_traj_end_of_lane_change(tt)],[left middle])
line([ref_traj_end_of_lane_change(tt) marker_pos(tt)],[middle middle])
line([marker_pos(tt),ref_traj_start_for_graphing(tt+1)],[middle middle])
lane=middle;
end
if(lane==right)
line([ref_traj_start_for_graphing(tt) ref_traj_end_of_lane_change(tt)],[right middle])
line([ref_traj_end_of_lane_change(tt) marker_pos(tt)],[middle middle])
line([marker_pos(tt),ref_traj_start_for_graphing(tt+1)],[middle middle])
lane=middle;
end
elseif ((strcmp(Data_ref(tt),'l'))==1)
if(lane==middle)
line([ref_traj_start_for_graphing(tt) ref_traj_end_of_lane_change(tt)],[middle left]) % problem
line([ref_traj_end_of_lane_change(tt) marker_pos(tt)],[left left])
line([marker_pos(tt),ref_traj_start_for_graphing(tt+1)],[left left])
lane=left;
end
% if (lane==left)
% line([ref_traj_start_for_graphing(tt) ref_traj_end_of_lane_change(tt)],[left left])
% line([ref_traj_end_of_lane_change(tt) marker_pos(tt)],[left left])
% line([marker_pos(tt),ref_traj_start_for_graphing(tt+1)],[left left])
% lane=left;
% end
if(lane==right)
line([ref_traj_start_for_graphing(tt) ref_traj_end_of_lane_change(tt)],[right left])
line([ref_traj_end_of_lane_change(tt) marker_pos(tt)],[left left])
line([marker_pos(tt),ref_traj_start_for_graphing(tt+1)],[left left])
lane=left;
end
else
if(lane==middle)
line([ref_traj_start_for_graphing(tt) ref_traj_end_of_lane_change(tt)],[middle right]) % problem
line([ref_traj_end_of_lane_change(tt) marker_pos(tt)],[right right])
line([marker_pos(tt),ref_traj_start_for_graphing(tt+1)],[right right])
lane=right;
end
if (lane==left)
line([ref_traj_start_for_graphing(tt) ref_traj_end_of_lane_change(tt)],[left right]) % problem
line([ref_traj_end_of_lane_change(tt) marker_pos(tt)],[right right])
line([marker_pos(tt),ref_traj_start_for_graphing(tt+1)],[right right])
lane=right;
end
% if(lane==right)
% line([ref_traj_start_for_graphing(tt) ref_traj_end_of_lane_change(tt)],[right right])
% line([ref_traj_end_of_lane_change(tt) marker_pos(tt)],[right right])
% line([marker_pos(tt),ref_traj_start_for_graphing(tt+1)],[right right])
% lane=right;
% end
end
% drawing the last section of the graph
if(tt==18)
if (lane==left)
line([ref_traj_start_for_graphing(19) ref_traj_end_of_lane_change(19)],[left middle])
line([ref_traj_end_of_lane_change(19) marker_pos(19)],[middle middle])
line([marker_pos(19),marker_pos(19)+150],[middle middle])
elseif(lane==right)
line([ref_traj_start_for_graphing(19) ref_traj_end_of_lane_change(19)],[right middle])
line([ref_traj_end_of_lane_change(19) marker_pos(19)],[middle middle])
line([marker_pos(19),marker_pos(19)+150],[middle middle])
else
line([ref_traj_start_for_graphing(19) ref_traj_end_of_lane_change(19)],[middle middle])
line([ref_traj_end_of_lane_change(19) marker_pos(19)],[middle middle])
line([marker_pos(19),marker_pos(19)+150],[middle middle])
end
end
end
0 Comments
Answers (1)
See Also
Categories
Find more on Automated Driving Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!