Changing the Position and Posture

This section describes how to perform basic operations to change the position and posture of a Body model.

The description here uses the PA10 model introduced in Loading a Model as an example. So, load and display the model before confirming how to perform operations in Choreonoid.

Kinematics Bar

The behavior of an operation for the position and posture of a Body model varies depending on the state of the following “kinematics bar”.

../_images/KinematicsBar.png

The first three buttons are especially important. These buttons are designed in such a way that only one of them is turned on, and used to switch the “kinematics mode”. They are:

  • Forward kinematics
  • Preset kinematics
  • Inverse kinematics

from the left.

There is no problem for now if the “preset kinematics” button is on (default). Details on these modes and the functions of other buttons are described later in this manual.

Changing the Posture Using the Joint Slider View

To change the posture of a model, you basically change joint angles. Although various functions can achieve this, this section describes how to change joint angles using the “joint slider view”, which is one of the basic views.

As preparation, select the body item of PA10 in the item tree view. This sets PA10 as the target model of the joint slider view.

Note

Not just when using the joint slider view, when performing an operation on a model through a view or the toolbar, you must select the target Body item beforehand to specify the target of the operation. Once you select the item, there is no problem if you deselect it later. The Body item selected last remains as the target until another Body item is selected next. Note that, when using another view or the toolbar as described in this section, you basically must also specify a Body item beforehand by performing this operation.

Then, the display of the joint slider view will be as follows.

../_images/jointslider_pa10_initial.png

This view has buttons for switching the display at the top. In the main area under the buttons, interfaces to display/change the states of the joints are arranged in the order of joint IDs from the top to down. The joint name, current joint angle value, minimum angle, joint angle slider, and maximum angle of each joint are arranged from the left to the right. Turn on the “ID” button at the top to also display joint ID values.

Note

Although the term “angle” is used here, it applies to the case in which the joints are “rotary joints”. While many of the joints of a robot are rotary joints, it also has “linear motion joints”. Actually, the model of PA10 has linear motion joints: “HAND_L” and “HAND_R”, which correspond to the grippers at the tips of the hands. The value of the current position of a linear motion joint should be called “position”, not “angle”, in a normal way. However, this section uses the term “joint angle” as is for general description that covers both the former and latter.

Users can change the joint angle values and slider positions in this view. The internal state of the model and the display in the scene view change in synchronization with the user’s operation. For example, change the value or slider position of the “J4” joint. Then, the joint in the middle of the arm of PA10 will bend as shown below.

../_images/pa10_j4.png

You can also move other joints in the same way. Try it out.

Changing a Joint Angle in the Scene View

You can change a joint angle by directly dragging the position of the joint with the mouse in the scene view.

This operation is performed in “edit mode”, which is described in View Mode and Edit Mode in Basic Concept and Operations - Displaying a Scene . Switch the scene view to the edit mode first by following the description there. Then, move the mouse cursor to the position of the J4 link, which you operated earlier, to obtain the following display.

../_images/j4_drag.png

The red markers around the bottom of the PA10 model indicate that this part is the current base link. The markers appear when the scene view is switched to the edit mode. Therefore, you can see that the view is in edit mode from the markers. The red box surrounding the J4 link indicates that the mouse cursor points to the J4 link and the link is the target of edit operations. If you move the cursor to another link, the link will be surrounded by a red box.

In this state, drag the mouse while pressing the left mouse button. Then, you can see that the J4 joint moves with mouse drag. In this way, you can change the posture by dragging joints intuitively in the scene view.

Even when you drag a joint in the scene view, the state of the above joint slider view changes synchronously. This applies not only to the joint slider view but also all the views for displaying and editing the state of a Body model. Thus, consistency on the GUI is always maintained through synchronization of the behaviors of the views.

Moving a Model

You can move the Body model as a whole by dragging the base link. For example, when the “BASE” link at the bottom of the PA10 model is the base link, click the link to obtain the following display.

../_images/pa10_move.png

Drag the mouse in this state to move the whole model as if it follows the drag.

By default, a marker consisting of three-colored arrows and rings (the position dragger) also appears as shown in the figure above. You can also move or even rotate (change the position of) a model by dragging the marker. Specifically, dragging an arrow part achieves translation along the axis of the arrow, and dragging a ring part achieves rotation along the outer circumference of the ring. The red, green, and blue colors of the arrows and rings correspond to X, Y, and Z axes, respectively, in the local coordinate system of the link.

You can specify whether to display the position dragger using the following button of the kinematics bar.

../_images/PositionDraggerButton.png

This button is on by default. However, if the dragger interferes with your edit operation, you can hide it by deselecting the button.

Undo and Redo of a Position/Posture Change Operation

When you are editing the position or posture, sometimes you may want to restore the last state. In that case, press “Ctrl + Z” while the mouse cursor points to the model in edit mode. This invokes the last position or posture. A state earlier than it can also be invoked by repeatedly performing the Undo operation.

An Redo operation is performed by pressing “Shift + Ctrl + Z”. This also enables you to cancel the state restored by an Undo operation. The Redo operation can also be repeated as many times as you need.

Body Bar

While editing the position or posture of a model, sometimes you may want to record a state of the model and invoke the state later again or to restore the initial or standard state. The following “body bar” provides the functions to perform these operations.

../_images/BodyBar.png

Click the first button from the left to record the current position and posture. You can invoke the recorded state by clicking the second button.

The third button from the left moves the position of the root link of the model to the origin position and returns the posture to its initial state (in which the local coordinate system matches the global one).

The fourth button restores the “initial posture” in which all the joint angles are zero. The fifth button changes all the joints of the model in such a way that the preset “standard posture” is restored. Although it depends on the definition of the model, the standard posture is generally different from the initial one. In the example of PA10, for example, the initial posture is one in which the arm stands upright, but the following posture is registered as the standard posture.

../_images/pa10_standard.png

It is considered that when this robot actually operates as a manipulator, it rarely operate an object directly above it with an upright posture, and it often starts operating a surrounding object with the posture like this. After consideration of these matters, this posture is registered as the standard posture of the model of PA10 and distinguished from the initial posture.

Changing the Posture Using Inverse Kinematics

As a method to change the posture of a model, the method to directly change the joint angle of a specific joint has been described so far. The procedure in this case is “first specify the angle of a joint and, as a result, the position and posture of each link change”. Such a process is called “forward kinematics”.

Although forward kinematics is one of the effective techniques to obtain a desired posture, it is very hard to obtain a desired position and posture of a certain type of link (e.g. tip of a manipulator) by using forward kinematics. So, there are cases in which you want to perform a process that is inverse of forward kinematics, that is, “specify the position and posture of a link and then the joint angle achieving them change”. This is called “inverse kinematics”. In Choreonoid, you can also use this technique to change the posture of a model.

Rather than reading such description, inverse kinematics may be easier to understand if you try the technique by actually moving a link. Try this by using the model of PA10. First, click the “standard posture” button of the Body bar introduced earlier in this manual to put PA10 in the standard posture. Also confirm that the “BASE” link is the base link (default).

Then, drag the link (J7) at the head of PA10. The display changes as shown in the figure below. The head link should move by following the mouse cursor. (As with when Moving a Model , you can also move the link by dragging each axis of the position dragger of the head link.)

../_images/pa10_ik.png

As you move the head link, you can see that the joint in the middle moves by following the link. In this way, inverse kinematics enables you to directly change the position and posture of a link. You can utilize this inverse kinematics operation when you want to intuitively move a specific link to achieve its desired position and posture.

Note

The reason why we first put the model in the standard posture is that the initial posture in which the manipulator stands upright is a “singular posture” of the robot, where calculation to move the head link with inverse kinematics cannot be performed. Like the “standard posture”, a posture in which each joint is bent to some degree is not a singular posture. Pay attention to this point when you use inverse kinematics. However, some models have analytical solution for inverse kinematics. In that case, you can move a link without paying so much attention to singular postures, although details are not covered here.

Switching Kinematics Modes

In Changing a Joint Angle in the Scene View , we changed the posture using forward kinematics by dragging the J4 link of PA10 in the scene view. In addition, in Changing the Posture Using Inverse Kinematics , we changed the posture using inverse kinematics by dragging the J7 link. For these operations, we did not explicitly specify whether to use forward kinematics or inverse kinematics. This is because Choreonoid was in a mode in which a type of kinematics was automatically selected depending on the dragged link. However, there may be cases in which you want to move the J4 link using inverse kinematics or the J7 link using forward kinematics. For such occasions, Choreonoid is designed to enable you to explicitly switch the types of kinematics. To do so, use the following three buttons at the head of the kinematics bar.

../_images/KinematicsBarModeButtons.png

The center button is on by default. The button sets the “preset kinematics mode”, where the type of kinematics is automatically switched depending on the link. The correspondence between links and kinematics types is predefined for each model. In the case of the PA10 model, the correspondence is as follows.

Link Kinematics Type
BASE, J1〜J5 Forward kinematics
J6〜J7 Inverse kinematics
HAND_L, HAND_R Forward kinematics

The above correspondence relationship in preset kinematics mode is determined based on a policy that inverse kinematics should be set for links that are considered to be often moved using inverse kinematics, and is probably enough for many posture change operations. (Actually this setting is configured in Preset Kinematics Settings in Writing Additional Information in YAML .)

If you want to specify a kinematics type manually, use the other two buttons. The left button is for “forward kinematics mode” and the right button is for “inverse kinematics mode”. When either of the buttons is on, the selected kinematics type is applied regardless of the link to be dragged. Use an appropriate mode as needed.