Clear Filters
Clear Filters

Is it possible to show and control two interactiveRigidBodyTree in the same Figure?

4 views (last 30 days)
Hello everybody,
I'm designing a robotic solution that comprises two ur3e arms with different poses and using the robotics toolbox I do not manage to represent the two interactiveRigidBodyTree of each arm in the same Figure. So far I have managed to load both robots into a single figure but just as a representation, without the possibility to control the arms interactively. Is there a workaround to represent and control both arms in the same Figure?
Thank you in advance for your help!

Accepted Answer

Karan Singh
Karan Singh on 31 Oct 2023
Hi Virgilio,
From what I understand, the goal is to represent and control both arms in the same figure using the Robotics Toolbox in MATLAB.
Yes, there is a solution to represent and control both UR3e arms in the same figure using the Robotics Toolbox in MATLAB. Here's a possible approach:
  1. Create separate interactiveRigidBodyTree objects for each UR3e arm. Let's say you have robot1 and robot2 representing the two arms.
  2. Create a single figure to display both arms using the figure command in MATLAB.
  3. Use the axes command to create two separate axes within the figure, one for each arm.
  4. Set the Parent property of each interactiveRigidBodyTree object to the respective axes.
  5. Now you can control each arm interactively by manipulating the joint angles or end effector poses using the interactiveRigidBodyTree objects robot1 and robot2.
Here's an example of how you can modify the code to achieve this:
% Import the necessary classes from the Robotics Toolbox
import robotics.*
import robotics.manip.internal.*
% Create two UR3e robot models
robot1 = importrobot('ur3e.urdf');
robot2 = importrobot('ur3e.urdf');
% Create separate interactiveRigidBodyTree objects for each robot
irt1 = interactiveRigidBodyTree(robot1);
irt2 = interactiveRigidBodyTree(robot2);
% Create a figure to display both arms
figure('Name', 'Dual UR3e Arms');
ax1 = axes('Parent', gcf, 'Position', [0.05, 0.1, 0.4, 0.8]);
ax2 = axes('Parent', gcf, 'Position', [0.55, 0.1, 0.4, 0.8]);
% Set the Parent property of each interactiveRigidBodyTree object to the respective axes
irt1.Parent = ax1;
irt2.Parent = ax2;
% Set initial joint angles for each arm
jointAngles1 = zeros(1, 6);
jointAngles2 = [pi/4, -pi/4, pi/3, -pi/2, pi/4, 0];
irt1.setJointPosition(jointAngles1);
irt2.setJointPosition(jointAngles2);
% Control the arms interactively
while true
% Get user input for joint angles or end effector poses
jointAngles1 = input('Enter joint angles for arm 1: ');
jointAngles2 = input('Enter joint angles for arm 2: ');
% Set the joint angles for each arm
irt1.setJointPosition(jointAngles1);
irt2.setJointPosition(jointAngles2);
% Update the figure to reflect the new arm configurations
drawnow;
end
Attached below are some documentation links that you may find helpful:
Hope this helps!
Karan Singh Khati

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!