Main Content

copy

로봇 모델 복사

설명

예제

newrobot = copy(robot)은 동일한 속성을 가진 robot의 깊은 복사본을 생성합니다. newrobot에서의 변경 내용이 robot에 반영되지 않습니다.

예제

모두 축소

기존 rigidBodyTree 객체를 변경합니다. 강체 트리에서 조인트, 바디, 하위 트리를 바꿀 수 있습니다.

Robotics System Toolbox™ loadrobot 함수를 사용하여 ABB IRB-120T 매니퓰레이터를 불러옵니다. 이는 rigidBodyTree 객체로 지정됩니다.

manipulator = loadrobot("abbIrb120T");

show를 사용해서 로봇을 표시하고 showdetails.를 사용해서 로봇의 세부 정보를 읽습니다.

show(manipulator);

Figure contains an axes object. The axes object with xlabel X, ylabel Y contains 24 objects of type patch, line. These objects represent base_link, base, link_1, link_2, link_3, link_4, link_5, link_6, tool0, link_1_mesh, link_2_mesh, link_3_mesh, link_4_mesh, link_5_mesh, link_6_mesh, base_link_mesh.

showdetails(manipulator)
--------------------
Robot: (8 bodies)

 Idx     Body Name            Joint Name            Joint Type     Parent Name(Idx)   Children Name(s)
 ---     ---------            ----------            ----------     ----------------   ----------------
   1          base        base_link-base                 fixed         base_link(0)   
   2        link_1               joint_1              revolute         base_link(0)   link_2(3)  
   3        link_2               joint_2              revolute            link_1(2)   link_3(4)  
   4        link_3               joint_3              revolute            link_2(3)   link_4(5)  
   5        link_4               joint_4              revolute            link_3(4)   link_5(6)  
   6        link_5               joint_5              revolute            link_4(5)   link_6(7)  
   7        link_6               joint_6              revolute            link_5(6)   tool0(8)  
   8         tool0          joint6-tool0                 fixed            link_6(7)   
--------------------

속성을 검사할 바디를 가져옵니다. link_3 바디의 자식은 link_4 바디뿐입니다. 특정 바디를 복사할 수도 있습니다.

body3 = getBody(manipulator,"link_3");
childBody = body3.Children{1}
childBody = 
  rigidBody with properties:

            Name: 'link_4'
           Joint: [1x1 rigidBodyJoint]
            Mass: 1.3280
    CenterOfMass: [0.2247 1.5000e-04 4.1000e-04]
         Inertia: [0.0028 0.0711 0.0723 1.3052e-05 -1.3878e-04 -6.6037e-05]
          Parent: [1x1 rigidBody]
        Children: {[1x1 rigidBody]}
         Visuals: {'Mesh Filename link_4.stl'}
      Collisions: {'Mesh Filename link_4.stl'}

body3Copy = copy(body3);

link_3 바디의 조인트를 바꿉니다. 다운스트림 바디의 기하 도형이 영향을 받지 않도록 하려면 새 Joint 객체를 만들고 replaceJoint를 사용해야 합니다. 바디 간의 변환을 정의하기 위해 필요한 경우 디폴트 단위 행렬을 사용하는 대신 setFixedTransform을 호출합니다.

newJoint = rigidBodyJoint("prismatic");
replaceJoint(manipulator,"link_3",newJoint);

showdetails(manipulator)
--------------------
Robot: (8 bodies)

 Idx     Body Name            Joint Name            Joint Type     Parent Name(Idx)   Children Name(s)
 ---     ---------            ----------            ----------     ----------------   ----------------
   1          base        base_link-base                 fixed         base_link(0)   
   2        link_1               joint_1              revolute         base_link(0)   link_2(3)  
   3        link_2               joint_2              revolute            link_1(2)   link_3(4)  
   4        link_3             prismatic                 fixed            link_2(3)   link_4(5)  
   5        link_4               joint_4              revolute            link_3(4)   link_5(6)  
   6        link_5               joint_5              revolute            link_4(5)   link_6(7)  
   7        link_6               joint_6              revolute            link_5(6)   tool0(8)  
   8         tool0          joint6-tool0                 fixed            link_6(7)   
--------------------

removeBody를 사용하여 전체 바디를 제거하고, 결과로 생성된 하위 트리를 가져옵니다. 제거된 바디는 하위 트리에 포함됩니다.

subtree = removeBody(manipulator,"link_4")
subtree = 
  rigidBodyTree with properties:

     NumBodies: 4
        Bodies: {[1x1 rigidBody]  [1x1 rigidBody]  [1x1 rigidBody]  [1x1 rigidBody]}
          Base: [1x1 rigidBody]
     BodyNames: {'link_4'  'link_5'  'link_6'  'tool0'}
      BaseName: 'link_3'
       Gravity: [0 0 0]
    DataFormat: 'struct'

show(subtree);

Figure contains an axes object. The axes object with xlabel X, ylabel Y contains 12 objects of type patch, line. These objects represent link_3, link_4, link_5, link_6, tool0, link_4_mesh, link_5_mesh, link_6_mesh.

수정된 link_3 바디를 제거합니다. 복사한 원래 link_3 바디를 link_2 바디에 추가한 다음, 반환된 하위 트리를 추가합니다. 로봇 모델은 동일하게 유지됩니다. 자세한 비교는 showdetails를 통해 확인하십시오.

removeBody(manipulator,"link_3");
addBody(manipulator,body3Copy,"link_2")
addSubtree(manipulator,"link_3",subtree)

showdetails(manipulator)
--------------------
Robot: (8 bodies)

 Idx     Body Name            Joint Name            Joint Type     Parent Name(Idx)   Children Name(s)
 ---     ---------            ----------            ----------     ----------------   ----------------
   1          base        base_link-base                 fixed         base_link(0)   
   2        link_1               joint_1              revolute         base_link(0)   link_2(3)  
   3        link_2               joint_2              revolute            link_1(2)   link_3(4)  
   4        link_3               joint_3              revolute            link_2(3)   link_4(5)  
   5        link_4               joint_4              revolute            link_3(4)   link_5(6)  
   6        link_5               joint_5              revolute            link_4(5)   link_6(7)  
   7        link_6               joint_6              revolute            link_5(6)   tool0(8)  
   8         tool0          joint6-tool0                 fixed            link_6(7)   
--------------------

입력 인수

모두 축소

로봇 모델로, rigidBodyTree 객체로 지정됩니다.

출력 인수

모두 축소

로봇 모델로, rigidBodyTree 객체로 반환됩니다.

확장 기능

버전 내역

R2016b에 개발됨