まず、私のセットアップについて少し説明します。ポイントと動作パターンをプログラムできるロボット アームがあります。目標は、入力に基づいて特定の方法で移動させることです。
ロボット アームと同じテーブルには、人間の力で動き、空間のどこにあるかを感知できる別のアームがあります。2 本の腕は既に座標系を共有していますが、特定の計算に問題があり、頭痛の種になっています。
現在の目標は、具体的にはセンシング アームで 3 つの点を取得し、それを 3 つの点を通過する半楕円弧に変換することです。この円弧は、最初の点から始まり、2 番目の点で頂点に達し、3 番目の点で終わり、必要に応じて 3 つの次元すべてを通過する必要があります。3 つの点は Visual Studio を通過し、MATLAB に入力され、99 個の xyz 座標の配列に変換されます。
MATLAB 関数を除いて、すべてのステップが機能しています。ポイント間の関係は問題ないように見えますが、ポイントは実際の座標にはほど遠いです。コードの何が問題なのか誰か教えてもらえますか?
これまでの内容は次のとおりです。
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
編集: 入出力情報を忘れました。以下に例を示します。
入力:
>> 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)
出力: