MATLAB Answers

Load Map text file with X and Y coordinates, want to plot those coordinates and plot the vehicle dimensions inside the plot

3 views (last 30 days)
Max Wright
Max Wright on 17 Jun 2021
Commented: KSSV on 17 Jun 2021
MATLAB Version 9.7 (R2019b)
Hi,
working on an automonous vehicle project, where the vehicle will drive through the plotted area in the text file.
i have a text file with X and Y coordinates (M1_layout.txt), have the dimensions of a vehicle which will drive through the X and Y coordinates.
I Want to plot out a figure of X & Y coordinates (with dots or crosses), also to add the vehicle inside that plot as it will be driving through the X and Y coordinates.
So far i know how to load the text file, parse the text file and when attempting to plot the text file getting a blank figure.
M-file script code:
dx_snr = 0.0; % Longitudinal distance between the center of the vehicle and the t antenna center point
dy_snr= 2.125; % Lateral distance between the center of the vehicle and the t antenna center point
nominalR = 0.75; % Nominal wheel radius
dx_wheel = 3.85; % longitudinal distance of the wheel centre
dy_wheel = 2.266; % lateral distance of the wheel from centre
t_map ='M1_layout.txt';
Map = GroundMap();
Map.LoadMap( t_map );
MS = NurbsSet;
RS = MS.Route;
L = RS.Size;
%% Display T Map
me = Map.Export();
nn = length(me);
map_pos = reshape([me.pos],2,nn)';
figure('Name','T Map Locations');
plot(map_pos(:,1),map_pos(:,2),'r.'); %X axis is all column 1, Y axis all column 2, red dots
axis equal;
for ii = 1:L
NN = RS.GetMotion(ii);
pos = NN.GetPose(s);
hold on;
plot(pos(:,1),pos(:,2),'b-'); % X axis is all column 1, Y axis all column 2, blue dash
hold off;
end
  2 Comments
Max Wright
Max Wright on 17 Jun 2021
  • GroundMap class:- is used for holding and accessing t maps (M1_layout.txt)
  • NURBS class:- handles the curve functions, such as getting length, position, pose, velocity, etc. However, as a NURBS it works from progress values i.e. from 0 to 1.
  • NURBSset class:- allows you to load & filter routes from the M1_layout.txt file. You can access them and/or generate a routing set, which produces lanes, transitions and lane-changes
Note: these are MATLAB MEX wrappers mentioned

Sign in to comment.

Answers (1)

KSSV
KSSV on 17 Jun 2021
T = readtable('M1_layout.txt') ;
pos = [T.(2) T.(3)] ;
plot(pos(:,1),pos(:,2),'.r')

Tags

Community Treasure Hunt

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

Start Hunting!