Design-time considerations

Workflow overview

In order to make your robot possible to export, you need to follow some conventions. The summary is as follows:

  • onshape-to-robot exports an assembly of the robot,

  • Be sure this assembly is a top-level assembly, where instances are robot links (they can be parts or sub-assemblies),

  • The first instance in the assembly list will be considered as the base link,

  • All the instances in the assembly will become links in the export

  • Mate connectors should have special names (see below for details):

    • dof_name: for degrees of freedom

    • frame_name: to create a frame (site in MuJoCo)

    • fix_name: fix two links together, causing onshape-to-robot to merge them

    • closing_name: to close a kinematic loop (see Handling kinematic loops)

    • Other mates are not considered by onshape-to-robot

  • Orphaned links (that are not part of the kinematic chain) will be fixed to the base link, with a warning

_images/design.png

Specifying degrees of freedom

To create a degree of freedom, you should use the dof_ prefix when placing a mate connector.

  • If the mate connector is cylindrical or revolute, a revolute joint will be issued (or a continuous joint, which has no limits, if its name contains the word wheel or continuous, e.g. dof_left_wheel)

  • If the mate connector is a slider, a prismatic joint will be issued

  • If the mate connector is a ball, a ball joint will be issued (not supported by URDF, see ball_to_euler)

  • If the mate connector is fastened, a fixed joint will be issued

Note

You can specify joint limits in Onshape, they will be understood and exported

Inverting axis orientation

You sometime might want your robot joint to rotate in the opposite direction than the one in the Onshape assembly.

To that end, use the inv suffix in the mate connector name. For instance, dof_head_pitch_inv will result in a joint named head_pitch having the axis inverted with the one from the Onshape assembly.

Degrees of freedom in sub-assemblies

dof_ mates can also be placed inside sub-assemblies, at any depth. Such a sub-assembly is split into one link per instance it contains, and its mates and mate connectors are processed like the top-level ones. Sub-assemblies that contain no dof_ mate are still exported as a single rigid link.

To keep an articulated sub-assembly rigid in a given robot, lock its instance in Onshape (padlock icon in the instance list): a locked instance is exported as a single rigid link and its dof_ mates are ignored, as well as those of the sub-assemblies it contains.

Note

Before this feature, dof_ mates inside sub-assemblies were ignored and every sub-assembly was exported as a single rigid link. If your assembly has dof_ mates in sub-assemblies (for example a gripper that you also export on its own), they now become joints: lock those instances to get the previous result.

Names coming from a sub-assembly are prefixed with the names of the instances leading to it. For instance, dof_elbow in a sub-assembly instance named Right arm <1> results in a joint named right_arm_elbow. The <1> suffix is dropped.

Duplicated and custom joint names

Several DOFs can end up with the same name, for example when the same articulated sub-assembly is instantiated several times (Onshape names its instances Arm <1>, Arm <2>, … and doesn’t let you rename them). In that case, all of them are numbered with the <n> of the instance they come from: dof_elbow in Arm <1> and Arm <2> gives arm_elbow_1 and arm_elbow_2. When the instance numbers don’t tell them apart (for example two DOFs with the same name at the top level), they are numbered _1, _2, … in the order they are found. Names coming from frame_ and link_ entries of a reused sub-assembly are numbered the same way (arm_hand_1, arm_hand_2).

Links of parts inside a sub-assembly are named after their part, like the other links (doubleu, doubleu_2, …): only joints, frames and link_ names get the sub-assembly prefix.

To give the joints meaningful names, use the rename_dofs entry of config.json, for example {"arm_elbow_1": "left_elbow", "arm_elbow_2": "right_elbow"}.

Adding custom frames in your model

You can add your own custom frames (such as the end effector or the tip of a leg) to your model.

  • In URDF, it will produce a dummy link connected to the parent link with a fixed joint

  • In SDF, a frame element will be added

  • In MuJoCo, it will result in a site

To do so, either:

  • Add a mate connector where you want your frame to be, and name it frame_something, where something is the name of your frame

OR

  • Add any relation between a body representing your frame and the body you want to attach it to. Name this relation frame_something.

_images/frames.png

Here is a document that can be used (be sure to turn on “composite parts” when inserting it, use the frame composite part): Onshape frame part

Note

The instance used for frame representation is only here for visualization purpose and is excluded from the robot. You can however include it by setting draw_frames to true in the config file, mostly for debugging purposes.

Joint frames

Joint frames are the ones you see in Onshape when you click on the joint in the tree on the left. Thus, they are always revolving around the z axis, or translating along the z axis.

_images/zaxis.png

Fixed robot

If you want to export a robot that is fixed to the ground, use the “Fixed” feture of Onshape:

_images/fixed.png

Gear relations

Gear relations are exported by onshape-to-robot. Be sure to click the source joint first, and then the target joint. They will be exported as <mimic> in URDF and SDF formats, and as equality constraints in MuJoCo.

_images/gear.png