주요 콘텐츠

replaceBody

로봇 바디 교체

설명

replaceBody(robot,bodyname,newbody)는 로봇 모델의 바디를 새로운 바디로 교체합니다. Parent 속성과 Children 속성을 제외한 바디의 모든 속성이 이 변경에 따라 업데이트됩니다. 나머지 로봇 모델은 영향을 받지 않습니다.

예제

예제

모두 축소

동역학 함수를 사용하여 조인트 토크와 조인트 가속도를 계산하기 위해 rigidBodyTree 객체와 rigidBody에 대한 동역학 속성을 지정합니다.

강체 트리 모델을 만듭니다. 연결할 두 개의 강체를 만듭니다.

robot = rigidBodyTree('DataFormat','row');
body1 = rigidBody('body1');
body2 = rigidBody('body2');

바디에 연결할 조인트를 지정합니다. body2의 고정 변환을 body1로 설정합니다. 이 변환은 x 방향으로 1미터입니다.

joint1 = rigidBodyJoint('joint1','revolute');
joint2 = rigidBodyJoint('joint2');
setFixedTransform(joint2,trvec2tform([1 0 0]))
body1.Joint = joint1;
body2.Joint = joint2;

두 바디에 대한 동역학 속성을 지정합니다. 로봇 모델에 두 바디를 추가합니다. 이 예제에서는 구형 질량(body2)이 연결된 막대(body1)에 대한 기본값이 제공됩니다.

body1.Mass = 2;
body1.CenterOfMass = [0.5 0 0];
body1.Inertia = [0.001 0.67 0.67 0 0 0];

body2.Mass = 1;
body2.CenterOfMass = [0 0 0];
body2.Inertia = 0.0001*[4 4 4 0 0 0];

addBody(robot,body1,'base');
addBody(robot,body2,'body1');

전체 로봇의 질량 중심 위치를 계산합니다. 로봇에 그 위치를 플로팅합니다. xy 평면 보기로 바꿉니다.

comPos = centerOfMass(robot);

show(robot);
hold on
plot(comPos(1),comPos(2),'or')
view(2)

Figure contains an axes object. The axes object with xlabel X, ylabel Y contains 6 objects of type patch, line. One or more of the lines displays its values using only markers These objects represent base, body1, body2.

두 번째 바디의 질량을 변경합니다. 질량 중심이 변하는 것을 알 수 있습니다.

body2.Mass = 20;
replaceBody(robot,'body2',body2)

comPos2 = centerOfMass(robot);
plot(comPos2(1),comPos2(2),'*g')
hold off

Figure contains an axes object. The axes object with xlabel X, ylabel Y contains 7 objects of type patch, line. One or more of the lines displays its values using only markers These objects represent base, body1, body2.

입력 인수

모두 축소

로봇 모델로, rigidBodyTree 객체로 지정됩니다. 강체가 이 객체에 추가되고, bodyname에 의해 지정된 강체에 연결됩니다.

바디 이름으로, string형 스칼라 또는 문자형 벡터로 지정됩니다. 이 바디는 robot으로 지정된 로봇 모델에 있어야 합니다.

데이터형: char | string

강체로, rigidBody 객체로 지정됩니다.

확장 기능

모두 확장

버전 내역

R2016b에 개발됨