Creating a semi-elliptical path in MATLAB from three input points through a three-dimensional space for filing in Visual Studio and, ultimately, a robotic arm

Firstly, a little about my setup: I have a robotic arm into which points and movement patterns can be programmed. The goal is to make it move in a certain way based on the input that we put into it.

In the same table as the robotic arm, is the other arm that moves under human power and can sense where it is in space. Two hands already have a coordinate system, but I am having problems with a certain rating, which gives me a headache.

The current goal is to take three points with a sensitive lever, and then translate it into an arc with a semi-ellipse that passes through three of them. This arc should start from the first point, reach the peak at the second and end with the third, moving across all three dimensions to do this, if necessary. Three points are transmitted through Visual Studio, then placed in MATLAB and converted into an array of 99 xyz coordinates.

We have every step, except for the MATLAB function. The points are nowhere close to the actual coordinates, although the relationship between them seems good. Can someone tell me what is wrong with the code?

Here is what we have so far:

function P = getEllipticalPath(h0,hl,hr) %define center of ellipse center = (hl+hr)/2; %want everything centered at (0,0,0) h0 = h0 - center; hl = hl - center; hr = hr - center; %xz plane direction between h0 and center d = [h0(1),0,0]/49; %now get the major/minor axis of the ellipse %minor axis(along z axis) a = h0(3); b = hr(2);%arbitrary with hr %set increment of orbit incr = (pi)/99; %by symmetry, only need to compute first half of orbit %allocation Pf = zeros(99,3); for i=1:99 if(i < 50) newpt = [0, b*cos(i*incr), a*sin(i*incr)] + (i*d); else newpt = [0, b*cos(i*incr), a*sin(i*incr)] + (99 - i)*d; end Pf(i,:) = [newpt(1), newpt(2), newpt(3)]; end P = addOffset(Pf,-h0); end %simply adds a fixed translational offset to the given list of vectors %(n*3 matrix). Assumes a matrix that is longer than 3. function P = addOffset(points,offset) newpoints = zeros(length(points),3); for i=1:length(points); newpoints(i,:) = points(i,:) + offset; end P = newpoints; end 

EDIT: entry and exit information; here is an example:

Input:

 >> h0 = [-10.06 14.17 0.53 ] h0 = -10.0600 14.1700 0.5300 >> hl = [-45.49 7.87 1.07 ] hl = -45.4900 7.8700 1.0700 >> hr = [-4.52 -20.73 1.02 ] hr = -4.5200 -20.7300 1.0200 >> P = getEllipticalPath(h0,hl,hr) 

Output:

This is very different from ecpectations. We would expect it to start on hl, move in increments through h0 and end on hr, but instead we get this.

+4
source share
1 answer

I think you have complicated all the biases and stuff for yourself. I think you want to do this:

  • Get the center vertex C of the ellipse as (hl + hr) / 2

  • Get the B major axis vector as (center-hl)

  • Get the small axis vector A as (h0-center)

  • Get angular delta float INCR as (pi) / 99

  • Now you can calculate each vertex in PF from i = 1 to 99 as center *(vertex)* + B*cos(i*incr) *(vector)* + A*sin(i*incr) *(vector)*

Basically, you start at the center, moving in the hr or hl direction according to the angle of inclination and moving to h0 as a sin of the angle, using these vectors to control how far and in which direction you are moving.

0
source

All Articles