What's wrong with my symbolic function?

3 visualizaciones (últimos 30 días)
Terlumun Nyamor
Terlumun Nyamor el 26 de Feb. de 2020
Respondida: Walter Roberson el 27 de Feb. de 2020
Hello,
I writing a function that when given a deseride end point, it calculates an intermediate point for use in the kinematics of a continuum robot.
My code works how I want it to. However, when I try turning the script into a function I get a bunch of errors. Does anyone know why I am recieving this error?
this is a piece of the code before I make it a function. It works in this form.
This is the error I recieve after I make me script a function and try to pass it the same Inputs (s, pc) that I used to test the code in the first place.
"Error using mupadengine/feval_internal (line 172)
Symbolic parameters not supported in nonpolynomial equations.
Error in sym/vpasolve (line 172)
sol = eng.feval_internal('symobj::vpasolve',eqns,vars,X0);
Error in pointGenerator (line 22)
temp = vpasolve(eqn1,ys);"

Respuestas (2)

Walter Roberson
Walter Roberson el 27 de Feb. de 2020
MATLAB does not offer the syntax
Value1 Relationship1 Value2 Relationship2 Value3
in the meaning you were thinking. In MATLAB the syntax means
((Value1 Relationship1 Value2) Relationship2 Value3)
The first relationship evaluates to either 0 (false) or 1 (true) and it is that 0 or 1 that is passed along to be tested by Relationship2 to Value3. 0 and 1 are both <= 3 so your first if was always true.
You need to code with a & or && operator, like
-3 <= y && y <= 3

Terlumun Nyamor
Terlumun Nyamor el 27 de Feb. de 2020
Oh geeze, sorry, this is going to be long. I working on simulating the inverse kinematics of a continuum robot manipulator. I have the code mostly functional at this point, but I noticed that the segments of the manipulator would extend or contract to reach certain end point rather than change orientation. I needed some method of constrainig the code so that the segment of the arm never change size. Each segment of the robot arm is essential a perfect arc rotated in space. I want to ensure that the arc length of a given arm never changes even if the end point or rotation is changed. the equation for the arc length is S = Radius*theta. Both the radius and the angle of the arc can be be described in terms of x y z, which is also the desired end-point of the manipulator arm. to of the points can b arbitray as long as I constrain 1 of them by the the arc-length formula in this case used the vpasolve function to solve for y based of given x z and S values. My code isn't very robust yet and if the z posit changes too much I get wierd artifacts that I haven't figured out yet. The section of cod you highlighted isn't very important is in only meant to ensure that z doesn't change too much. I'll try making z a constant value and see if the code works. Down below is th part of the script that generates the next intermediate point for the manipulator arm kinematics.
syms xs ys zs s
pc=[1 2 1];
s = 8;
xs = pc(1)+((s+pc(1))/2- pc(1))*rand(1,1);
if -3<= pc(3) <= 3
zs = pc(3)+1;
elseif pc(3) > 3
zs = Pc(3)-1;
elseif pc(3) < -3
zs = pc(3)+1;
end
if zs >= 0
eqn = (xs^2 + ys^2 + zs^2)/(2*sqrt(xs^2 + ys^2))*acos(1-(2*sqrt(xs^2 + ys^2)/(xs^2 + ys^2 + zs^2))*sqrt(xs^2 + ys^2)) == s;
else
eqn = (xs^2 + ys^2 + zs^2)/(2*sqrt(xs^2 + ys^2))*(2*pi-acos(1-(2*sqrt(xs^2 + ys^2)/(xs^2 + ys^2 + zs^2))*sqrt(xs^2 + ys^2))) == s;
end
temp = vpasolve(eqn,ys);
ys = double(abs(temp(1,1)))
phi = double(atan2(ys,xs));
k = double(2*sqrt(xs^2 + ys^2)/(xs^2 + ys^2 + zs^2));
r = double(1/k);
C = double([r*cos(phi), r*sin(phi), 0]);
if zs >= 0
theta = acos(1-k*sqrt(xs^2 + ys^2));
else
theta = 2*pi - acos(1-k*sqrt(xs^2 + ys^2));
end
pnext = [xs ys zs];

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by