simscape Mechanics Explorer trajectory show

조회 수: 17 (최근 30일)
wenlong
wenlong 2025년 10월 14일 2:23
댓글: Umar 2025년 10월 15일 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.

답변 (1개)

Umar
Umar 2025년 10월 14일 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
wenlong
wenlong 2025년 10월 15일 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 2025년 10월 15일 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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Model Import에 대해 자세히 알아보기

태그

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by