Is it possible to change the color of an object in Simscape Multibody during a simulation?

5 次查看(过去 30 天)
I would like to be able to visually communicate system parameters by the color of a body. For example, a linkage turns yellow when it gets within 10 degrees of its limits, or a wheel turns red when it stops turning, etc.
Is this possible? Or does anyone have any tricks to convey this information synchronously with the model animation?
  5 个评论
Ameer Hamza
Ameer Hamza 2020-3-29
I tried the event listener approach; it appears that it does not work for the blocks inside the simscape library.
I am not sure about any other software, but If you have the 3D model of each link of your robot, then you can create an animation using the graphics function provided by MATLAB, e.g., patch(). It will require a bit of knowledge about 3D transformations, but eventually, you will be able to control the appearance of each link independently.

请先登录,再进行评论。

采纳的回答

Steve Miller
Steve Miller 2021-6-5
Through MATLAB release R2021a, you cannot cannot change the color of a solid based on an input signal. What you can do, though, is put another solid just behind it that has the new color, and then when you want the color to change move that solid in front of the other solid.
In the video in this LinkedIn post, we used a set of solids to have the battery color change gradually as it heats up:
--Steve
  3 个评论
Steve Miller
Steve Miller 2022-3-15
Hi Dean,
To give the appearance that a solid's color has changed, you can
  1. For something like a lamp or an indicator....create two solids of different colors (for example red and blue), and mount one of them on a prismatic joint (for example, the blue one). At the start of the simulation, make sure the blue one is positioned "behind" the red one along the viewpoint axis. When you want the color of the lamp to change, move the blue one so that it is in front of the red one. This will obviously only work along one axis.
  2. For something like the batteries in the simulation above, we created a set of Variable Brick Solid blocks each assigned a different color. As we wanted the color to change, we changed the dimensions of the Variable Brick Solid with the desired color to "big" and make all other Variable Brick Solid blocks small (but not zero)
--Steve

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simscape Multibody 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by