Main Content

viewSolution

Open Multibody Explorer to visualize KinematicsSolver solution

Description

viewSolution(ks) opens the Multibody Explorer to visualize the mechanism corresponding to the latest solution computed by the solve method 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.

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