test_linearTranslationNDOFStateEffector

test_linearTranslationNDOFStateEffector.randomValidInertia()[source]

Generate a random diagonal inertia tensor that is physically realizable.

test_linearTranslationNDOFStateEffector.test_translatingBody(show_plots, function)[source]

Validation Test Description

This unit test sets up a spacecraft with four single-axis translating rigid bodies attached to a rigid hub. Each translating body’s center of mass is off-center from the translating axis and the position of the axis is arbitrary. The scenario includes gravity acting on both the spacecraft and the effector.

Description of Variables Being Tested

In this file we are checking the principles of conservation of energy and angular momentum. Both the orbital and rotational energy and angular momentum must be maintained when conservative forces like gravity are present. Therefore, the values of the variables

  • finalOrbAngMom

  • finalOrbEnergy

  • finalRotAngMom

  • finalRotEnergy

against their initial values.

test_linearTranslationNDOFStateEffector.test_translatingBodyConfigurationValidation(chain, shouldRaise, scheduleEffector)[source]

Verify that initialization rejects a chain the equations of motion cannot represent, and that a massless body used to build a multiple degree of freedom joint is not one of them.

The joint mass matrix sums the masses outboard of each axis. A body may be left massless so that several single axis bodies compose one multi-axis joint, but the matrix is singular whenever some nonzero combination of axis rates leaves every body carrying mass at rest. That covers a massless outermost body and a massless body sharing its axis with the body outboard of it, and it is a collective condition rather than a pairwise one: massless stages along x and y followed by a massive stage along x + y have pairwise independent axes yet span only two dimensions, so they are rejected as well. Inverting a singular matrix fills the spacecraft state with NaN rather than raising, which is why this is asserted as an error at initialization instead of as a tolerance on a trajectory. The axes are fixed in their parents and a translating body does not rotate, so the matrix never changes during the integration. The singular cases also verify that the error reports this collective condition rather than a more restrictive axis-independence rule. The rotation matrix and inertia tensor checks match those the spinning body effectors already apply, including skipping the inertia check for a massless body, whose inertia tensor is legitimately zero.

An accepted chain is integrated as well, because initializing without error would not show that a massless body carries the correct dynamics. Every damper is zero, so the rotational energy and the rotational angular momentum about the vehicle center of mass must both be conserved.

Test Parameters:

  • chain: [string]

    translating body configuration to initialize

  • shouldRaise: [bool]

    whether initialization must reject the configuration

  • scheduleEffector: [bool]

    whether the effector is added to the task in addition to the spacecraft

The scheduling parameter matters because the checks must not depend on it. Spacecraft initialization calls registerStates() on every attached state effector but never calls Reset(), which runs only for a module added to a task. The module user guide adds the effector to the spacecraft alone, so validation reached from Reset() would miss the documented setup and let a singular chain integrate to NaN.

test_linearTranslationNDOFStateEffector.test_translatingBodyDynamicEffectorSegmentBounds(segment, shouldRaise)[source]

Verify that dynamic effectors can attach only to existing translating bodies.

A three-body chain accepts its first and last body numbers and rejects the adjacent values outside the valid one-based range.

Test Parameters:

  • segment: [int]

    one-based body number supplied to addDynamicEffector

  • shouldRaise: [bool]

    whether the body number is outside the valid range

test_linearTranslationNDOFStateEffector.test_translatingBodyMassSetterBoundary()[source]

Verify that the mass setter accepts zero and rejects a negative mass.

test_linearTranslationNDOFStateEffector.test_translatingBodyOutputMessagesMatchOneDOF()[source]

Verify both output-message vectors against the equivalent one-DOF model.

A single-body N-DOF effector and a one-DOF effector are given identical geometry, mass properties, and initial states on their own spacecraft in one simulation. The hub starts with a non-identity attitude and nonzero translational and angular velocity so that every inertial transformation contributes. The displacement, displacement rate, inertial position, inertial velocity, attitude, and angular velocity are compared at every step.

test_linearTranslationNDOFStateEffector.translatingBodyCommandedForce(show_plots)[source]

This test includes a commanded force to the link, so energy is not conserved.

test_linearTranslationNDOFStateEffector.translatingBodyLockAxis(show_plots)[source]

This test locks the axis, so the displacement is kept constant throughout the simulation.

test_linearTranslationNDOFStateEffector.translatingBodyNoInput(show_plots)[source]

This test does not use any input messages or lock flags, so the links are free to move.