Main Content

viewSolution

Open Kinematics Solver Viewer window to visualize KinematicsSolver solution

Since R2020a

Description

viewSolution(ks) opens a Kinematics Solver Viewer window to visualize the mechanism corresponding to the latest solution computed by the solve function for the KinematicsSolver object ks.

Note

  • An error occurs if the solve function was not invoked before calling the viewSolution function.

  • If the statusFlag corresponding to the last call to solve is -3, the state returned by the solver is not kinematically feasible. In this case, the mechanism rendered in the viewer is not physically realizable.

The Kinematics Solver Viewer window is shown in the following figure. This pane provides visual feedback on the mechanism that you are analysing. Select the Update Visualization button or press F5 to view the mechanism that corresponds to the latest solution of ks. Use the viewer to examine the mechanism from different perspectives by selecting the standard view or by rotating, panning, and zooming the mechanism. Right-click the window to access a context-sensitive menu. This menu provides additional options that allow you to change the background color, split the visualization window into multiple tiles, and modify the view convention from the default +Z up (XY Top) setting.

Kinematics Solver Viewer Window

Examples

collapse all

Open the example and create a KinematicsSolver object for the double pendulum model.

mdl = "DoublePendulum";
load_system(mdl);
ks = simscape.multibody.KinematicsSolver(mdl);

List all of the joint position variables.

jointPositionVariables(ks)
ans=2×4 table
       ID           JointType                   BlockPath               Unit 
    _________    ________________    _______________________________    _____

    "j1.Rz.q"    "Revolute Joint"    "DoublePendulum/Lower Revolute"    "deg"
    "j2.Rz.q"    "Revolute Joint"    "DoublePendulum/Upper Revolute"    "deg"

Assign the upper and lower revolute joint angles as target variables.

targetIDs = ["j1.Rz.q";"j2.Rz.q"];
addTargetVariables(ks,targetIDs);

Solve the forward kinematics problem with given joint angles.

targets = [90,0];
outputVec = solve(ks,targets);

Open the Kinematics Solver Viewer. At the MATLAB® command prompt, enter:

viewSolution(ks);

Click the Front view button to view the solution.

Close the viewer.

closeViewer(ks);

Input Arguments

collapse all

Kinematics solver object, specified as a KinematicsSolver object that is the representation of the Simscape™ Multibody™ model used for kinematic analysis.

Example: ks = simscape.multibody.KinematicsSolver("DoublePendulumExample​'​')

Version History

Introduced in R2020a