How to fix Error using atan2 Inputs must be real?
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Konard Adams
il 26 Gen 2022
Risposto: Konard Adams
il 27 Gen 2022

Function
function ConcLin = Line(A,B)
%% Linear Moving along desired path
% **** Linear First Movement ***
% Calling Inverse Kinematics to
%% number of increments
ResLin = 100;
%% Equations
DeltaX = (B(1,1) - A(1,1)) / ResLin;
DeltaY = (B(1,2) - A(1,2)) / ResLin;
DeltaZ = (B(1,3) - A(1,3)) / ResLin;
%% Looping through each point of the line
tic;
AnglesLin = zeros(6); %preallocating memory
for f = 1:ResLin
%% calculating actual point
A(1,1) = A(1,1) + DeltaX * f;
A(1,2) = A(1,2) + DeltaY * f;
A(1,3) = A(1,3) + DeltaZ * f;
AnglesLin(f,:) = IKine(A);
end
toc
%% Increments of Time
tic;
TimeLin = zeros(1); %preallocating memory
for clockLin = 1:ResLin
TickTockLin = clockLin*0.1+10;
TimeLin(clockLin,:) = TickTockLin;
end
toc
%% Concatenating Time & Angles. Time will be the first column
ConcLin = [TimeLin,AnglesLin];
Main
%% Coordinates Input
% LINE desired Paths. If Input method is used, comment out this block of code.
% *****We will define these as one matrix 1x12*****
Lin1 = [750, -75, 670, 0, 0, 1, 0, -1, 0, 1, 0, 0];%A
% Xa = Lin1(1,1); Ya = Lin1(1,2); Za = Lin1(1,3);
Lin2 = [750, -75, 550, 0, 0, 1, 0, -1, 0, 1, 0, 0];%B
% Xb = Lin2(1,1); Yb = Lin2(1,2); Zb = Lin2(1,3);
Lin3 = [750, 75, 550, 0, 0, 1, 0, -1, 0, 1, 0, 0];
Lin4 = [750, 75, 670, 0, 0, 1, 0, -1, 0, 1, 0, 0];
Lin5 = [750, 0, 700, 0, 0, 1, 0, -1, 0, 1, 0, 0];
Lin6 = [750, 0, 550, 0, 0, 1 0, -1, 0, 1, 0, 0];
%% Calling Linear Motion
ConcLin = Line(Lin1, Lin2);
5 Commenti
Steven Lord
il 26 Gen 2022
You're assuming d3/p1 is strictly less than or equal to 1. What guarantee do you have that this is the case?
If it was ever so slightly greater than 1:
d3 = 2;
p1 = 2 - eps(2); % Just barely less than 2
s = (d3/p1)
s > 1 % true
sqrt(1-s^2) % complex
You can use min and max to ensure s is strictly in a desired range.
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Point Cloud Processing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!