simscape Mechanics Explorer trajectory show

17 visualizaciones (últimos 30 días)
wenlong
wenlong el 14 de Oct. de 2025 a las 2:23
Comentada: Umar el 15 de Oct. de 2025 a las 4:34
Hello, I have built a Simscape simulation model of a robotic arm and run the animation in Mechanics Explorer. Now I want to display the trajectory of the fingertip in Mechanics Explorer. How can I achieve this? What modules are needed? How should I set it up? How should I connect the wires? Please provide detailed instructions. Thank you.

Respuestas (1)

Umar
Umar el 14 de Oct. de 2025 a las 14:47

Hi @Wenlong,

Thanks for reaching out! To display the trajectory of your robotic arm's fingertip in Mechanics Explorer, you'll need to use a combination of the Transform Sensor block and the Spline block. Here's the approach:

1. Transform Sensor (Simscape > Multibody > Frames and Transforms) 2. PS-Simulink Converter blocks (Simscape > Utilities) - you'll need 3 of these 3. To Workspace blocks (Simulink > Sinks) - 3 blocks to capture X, Y, Z coordinates 4. Spline block (Simscape > Multibody > Body Elements)

And here are the setup steps

Add a Transform Sensor block to measure the fingertip position relative to the World Frame. Then, connect the base port (B) to your World Frame and the follower port (F) to the fingertip frame. In the Transform Sensor dialog, select Translation > X, Y, and Z to output all three coordinates.Connect each output through a PS-Simulink Converter (set units appropriately, e.g., "m" or "cm"). Use To Workspace blocks to save the trajectory data (name them x_traj, y_traj, z_traj). Add a Spline block and configure it to display the trajectory curve in Mechanics Explorer

Important Note: The trajectory will display as a complete curve throughout the simulation rather than drawing incrementally in real-time. You'll need to pass all the XYZ coordinate points to the Spline block.

Helpful Resources:

Hope this helps!

  2 comentarios
wenlong
wenlong el 15 de Oct. de 2025 a las 3:31
Now that I have completed the setup of Transform Sensor to To Workspace, how should I configure the Spline module? Is the variable name of the spline the same as the variable name in To Workspace? Will there be a trajectory once the Spline module variable name is configured?
Umar
Umar el 15 de Oct. de 2025 a las 4:34

Hi @wenlong,

It is good that you are making progress. After going through your comments, I have to admit that spline block doesn't work the way you're trying to use it. It requires coordinate data directly in its Parameters dialog box as an N-by-3 matrix, not workspace variable names.

See the documentation here: https://www.mathworks.com/help/sm/ref/spline.html

For displaying your fingertip trajectory after the Transform Sensor ->To Workspace setup you've completed, use one of these approaches:

1. MATLAB 3D Plot (Recommended for 3D trajectories) After your simulation completes, run:

figure;
plot3(x_traj.Data, y_traj.Data, z_traj.Data, 'LineWidth', 2);
xlabel('X (m)'); ylabel('Y (m)'); zlabel('Z (m)');
grid on;
title('Fingertip Trajectory');

Documentation: https://www.mathworks.com/help/matlab/ref/plot3.html

2. XY Graph Block (For 2D real-time visualization)

  • Add an XY Graph block from Simulink > Sinks library
  • Connect two PS-Simulink Converter outputs directly to the XY Graph inputs
  • The plot updates during simulation

Documentation: https://www.mathworks.com/help/simulink/ug/plot-circle-with-xy-graph.html

3. Simulation Data Inspector (For post-simulation analysis) After simulation, use Data Inspector to view your logged signals on an XY plot with replay controls.

Documentation: https://www.mathworks.com/help/simulink/ug/visualize-simulation-data-on-an-xy-plot.html

The Spline block is designed for defining fixed geometric curves as mechanical constraints, not for dynamic trajectory visualization during or after simulation.

Post me about your progress.

Iniciar sesión para comentar.

Categorías

Más información sobre Model Import en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by