scenarioArmWithThrusters

It’s recommended to review the following scenario(s) first (and any recommended scenario(s) that they may have):

  1. examples/mujoco/scenarioReactionWheel.py

This scripts shows how to simulate a spacecraft that deploys two thrusters at the end of a 4-link branching deployable arm. This uses the MuJoCo-based DynamicObject MJScene.

The multi-body system is defined in the XML file sat_w_deployable_thruster.xml. This XML file defines a ‘hub’ body and a branching deployable arm with 4 links. The first link (‘arm_1’) is attached to the ‘hub’ body, and the second link (‘arm_2’) is attached to the first link. The third link (‘arm_3’) AND the fourth link (‘arm_4’) are both attached to the second link. Both of the last two links have a site attached to them (‘thruster_1’ and ‘thruster_2’, respectively), which defines the point at which the thrust vector is applied. The joints between the links are revolute joints.

The thrusters are turned on and off at specific times. The thrust direction and application point on the link body (‘arm_3’ or ‘arm_4’) are fixed throughout the simulation. However, because the ‘arm_3’ and ‘arm_4’ will move with respect the inertial frame (the ‘hub’ body is free-floating, the arm joints move), the effective thrust points and directions will change.

Note that the only actuators defined are the ones used to model the thrusters (‘thruster_1’ and ‘thruster_2’). We could opt to define actuators for the joints of the arm, so that deploying the arm is modeled as an actuation. In this case, the script would have to define the torque to be applied at these joints to deploy the arm. This is complex, and generally requires a control system to be implemented (see mujoco/scenarioDeployPanels.py). Instead, we opt for a simpler approach: we constrain the motion of the joints.

Prescribing the motion of joints can be useful to model a system that we can assume is very accurately controlled by some unknown system. Essentially, we let the dynamic object know what the motion of the joint should be, and the dynamic engine will compute the forces necessary to achieve that motion. This implies that the joint will not have exactly the motion we constrain, since we are numerically solving the inverse dynamic problem (i.e., given the motion, what are the forces?). However, the motion will be very close to what we constrain. It should be noted that this comes at a considerable computational cost.

To constrain the motion of the joints, we connect to the constrainedStateInMsg of the joint object.

This script also showcases the use of the XXXInterpolator models, which are utility models that interpolate a set of points to generate a profile between them. In this script these are used in two occasions:

  1. To constrain the motion of the joints of the deployable arm.

  2. To define the thrust of the thrusters.

For the first case, we use a linear interpolation, so that the joints move at a constant rate. For the second case, we use a piecewise interpolation, so that the thrusters are turned on and off at specific times.

The datapoints for each interpolator are defined in the dictionaries JOINT_INTERPOLATION_POINTS and ACTUATOR_INTERPOLATION_POINTS. Each interpolator takes a numpy matrix with >=2 columns, where the first column is the time at which the point is defined, and the rest of the columns are the values of the points. In this script we demonstrate the use of mujoco.SingleActuatorInterpolator and mujoco.ScalarJointStateInterpolator, both of which need only 2 columns.

Note that the interpolator models are added to the dynamics task, so that the interpolation happens at every integrator step. All models in the dynamics task are updated at every integrator step. If we had added the models to the regular task, the interpolation would only happen at the task rate, which means that the thrust/joint values would only be updated at the fixed rate of 1 Hz. Whether you add a model to the dynamics task or the regular task depends on the specific use case.

scenarioArmWithThrusters.run(showPlots: bool = False, visualize: bool = False)[source]

Main function, see scenario description.

Parameters:
  • showPlots (bool, optional) – If True, simulation results are plotted and show. Defaults to False.

  • visualize (bool, optional) – If True, the MJScene visualization tool is run on the simulation results. Defaults to False.