Robot creation in Matlab with multiple bases
Show older comments
Hi all,
I have the following problem: I want to create a robot that consists out of the following rigid bodies. At the connection of body 1 and 4 a motor is located for rotation.

The problem is that I don't know how to implement a 'second' base, above or below the first one. Thus a way of constraining the a point of body 1 and 4 above eachother.
The code which I have now is as follows (not fully functional):
clc, clear all, close all
%-----------------------------------------------------------
robot = robotics.RigidBodyTree; %creates body tree
body1 = robotics.RigidBody('body1'); % creates body
jnt1 = robotics.Joint('jnt1','revolute');
jnt1.HomePosition = pi/2;
tform = trvec2tform([1, 0 , 0]); %
setFixedTransform(jnt1,tform);
body1.Joint = jnt1; %assigns joint to body
addBody(robot,body1,'base') %adds body to tree base
body2 = robotics.RigidBody('body2');
jnt2 = robotics.Joint('jnt2','revolute');
jnt2.HomePosition = pi/4;
tform2 = trvec2tform([0,0,-2]);
setFixedTransform(jnt2,tform2);
body2.Joint = jnt2;
addBody(robot,body2,'body1'); % Add body2 to body1
body3 = robotics.RigidBody('body3');
jnt3 = robotics.Joint('jnt3','revolute');
tform3 = trvec2tform([1, 0, 0])*eul2tform([0, 0, 0]); % User defined
setFixedTransform(jnt3,tform3);
jnt3.HomePosition = 0; % User defined
body3.Joint = jnt3
addBody(robot,body3,'body2'); % Add body3 to body2
body5 = robotics.RigidBody('body5');
jnt5 = robotics.Joint('jnt5','revolute');
tform5 = trvec2tform([1, 2, 0]); % User defined
setFixedTransform(jnt5,tform5);
jnt5.HomePosition = pi/4; % User defined
addBody(robot,body5,'body3')
show(robot)
Thanks in advance!
Answers (0)
Categories
Find more on Coordinate Transformations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!