フィルターのクリア

Cube with different side color in RGB

1 回表示 (過去 30 日間)
jari jafri
jari jafri 2024 年 4 月 25 日
編集済み: Karsh Tharyani 2024 年 5 月 3 日
I created a cube using rigid body tree (code below). Then I wanted to color different sides of the cube, red, gree, blue, etc... but when I use the command
addVisual(body, 'box', [1 1 1], 'FaceColor', 'r');
for a side to be in red color, the issue is, it is giving me error of too many arguments.
cube = rigidBodyTree;
body1 = rigidBody('body1');
joint1 = rigidBodyJoint('joint1','floating');
body1.Joint = joint1;
addVisual(body1, 'box', [1 1 1], 'FaceColor', 'r');
Error using robotics.manip.internal/RigidBody/validateAddVisualInputs
Too many input arguments.

Error in robotics.manip.internal.RigidBody/addVisual (line 215)
validType = validateAddVisualInputs(obj, type, parameter, varargin{:});

Error in rigidBody/addVisual (line 231)
obj.BodyInternal.addVisual(Inputs{:});
addVisual(body1, 'box', [1 1 1]);
%addVisual(body1, 'box', [1 1 1], 'FaceColor', colors{i});
addBody(cube,body1,cube.BaseName);
  2 件のコメント
DGM
DGM 2024 年 4 月 26 日
I don't have that toolbox, but I think you might just have to set those properties after calling addVisual(). That's what other examples seem to do.
jari jafri
jari jafri 2024 年 4 月 26 日
Thanks

サインインしてコメントする。

回答 (1 件)

Karsh Tharyani
Karsh Tharyani 2024 年 5 月 3 日
編集済み: Karsh Tharyani 2024 年 5 月 3 日
The addVisual function on a rigidBody doesn't support the additional name-value arguments that you are trying to pass i.e., "FaceColor". I have conveyed this enhancement request to the development team at MathWorks for a future release of MATLAB.
As a workaround, you can try to use findobj and set to modify the patch colors.
Here are some code snippets to illustrate:
rbt=loadrobot('kinovagen3');
ax=show(rbt);
% All the visual mesh patches on the rigid body tree visualization
patches=findobj(ax.Children,'-regexp','DisplayName','_mesh');
patches =
8x1 Patch array: Patch (DO_NOT_EDIT_CTQxT) Patch (DO_NOT_EDIT_CTQxT) Patch (DO_NOT_EDIT_CTQxT) Patch (DO_NOT_EDIT_CTQxT) Patch (DO_NOT_EDIT_CTQxT) Patch (DO_NOT_EDIT_CTQxT) Patch (DO_NOT_EDIT_CTQxT) Patch (DO_NOT_EDIT_CTQxT)
% Set the ForeArm_Link's visual mesh color to "magenta".
forearmlinkmeshes=findobj(patches,'-regexp','DisplayName','ForeArm_Link_mesh');
set(forearmlinkmeshes,'FaceColor','magenta');
% Set all the visual mesh patches of the robot to the color 'blue'
set(patches,'FaceColor','blue');
Hope this helps,
Karsh

カテゴリ

Help Center および File ExchangeRobotics についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by