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

13 views (last 30 days)
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 Comments
Ameer Hamza
Ameer Hamza on 29 Mar 2020
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.

Sign in to comment.

Accepted Answer

Steve Miller
Steve Miller on 5 Jun 2021
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 Comments
Steve Miller
Steve Miller on 15 Mar 2022
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

Sign in to comment.

More Answers (0)

Categories

Find more on Simulation and Analysis in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!