Open Kinematics Solver Viewer window to visualize KinematicsSolver solution
An error occurs if the
solvefunction was not invoked before calling the
statusFlagcorresponding 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
Visualize the Solution of a Forward Kinematics Problem of a Double Pendulum Model
Create a KinematicsSolver object for the double pendulum model.
openExample("sm/VisualizeFKDoublePendulumExample"); mdl = "DoublePendulum"; load_system(mdl); ks = simscape.multibody.KinematicsSolver(mdl);
List all of the joint position variables.
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:
Click the Front view button to view the solution.
Close the viewer.
ks — Kinematics solver object
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'')
Introduced in R2020a