Preprogrammed

We have pre programmed a number of handy constants for the user:

Note

For the preprogrammed steps associated with specific locomotion experiments presented in the NeuroMechFly v2 paper, see the locomotion example page.

DoFs

# All actively actuatable DoFs in the legs
>>> flygym.preprogrammed.all_leg_dofs
['joint_LFCoxa', 'joint_LFCoxa_roll', 'joint_LFCoxa_yaw', 'joint_LFFemur', 'joint_LFFemur_roll', 'joint_LFTibia', 'joint_LFTarsus1', 'joint_LMCoxa', 'joint_LMCoxa_roll', 'joint_LMCoxa_yaw', 'joint_LMFemur', 'joint_LMFemur_roll', 'joint_LMTibia', 'joint_LMTarsus1', 'joint_LHCoxa', 'joint_LHCoxa_roll', 'joint_LHCoxa_yaw', 'joint_LHFemur', 'joint_LHFemur_roll', 'joint_LHTibia', 'joint_LHTarsus1', 'joint_RFCoxa', 'joint_RFCoxa_roll', 'joint_RFCoxa_yaw', 'joint_RFFemur', 'joint_RFFemur_roll', 'joint_RFTibia', 'joint_RFTarsus1', 'joint_RMCoxa', 'joint_RMCoxa_roll', 'joint_RMCoxa_yaw', 'joint_RMFemur', 'joint_RMFemur_roll', 'joint_RMTibia', 'joint_RMTarsus1', 'joint_RHCoxa', 'joint_RHCoxa_roll', 'joint_RHCoxa_yaw', 'joint_RHFemur', 'joint_RHFemur_roll', 'joint_RHTibia', 'joint_RHTarsus1']

# 3 DoFs per leg used in the CPG optimization task performed in Lobato-Rios et al., 2022.
# These are the most variable DoFs during tethered locomotion
>>> flygym.preprogrammed.leg_dofs_3_per_leg
['joint_LFCoxa', 'joint_LFFemur', 'joint_LFTibia', 'joint_LMCoxa_roll', 'joint_LMFemur', 'joint_LMTibia', 'joint_LHCoxa_roll', 'joint_LHFemur', 'joint_LHTibia', 'joint_RFCoxa', 'joint_RFFemur', 'joint_RFTibia', 'joint_RMCoxa_roll', 'joint_RMFemur', 'joint_RMTibia', 'joint_RHCoxa_roll', 'joint_RHFemur', 'joint_RHTibia']

Body segments

# All tarsal segments, useful for defining leg-ground contacts
>>> flygym.preprogrammed.all_tarsi_links
['LFTarsus1', 'LFTarsus2', 'LFTarsus3', 'LFTarsus4', 'LFTarsus5', 'LMTarsus1', 'LMTarsus2', 'LMTarsus3', 'LMTarsus4', 'LMTarsus5', 'LHTarsus1', 'LHTarsus2', 'LHTarsus3', 'LHTarsus4', 'LHTarsus5', 'RFTarsus1', 'RFTarsus2', 'RFTarsus3', 'RFTarsus4', 'RFTarsus5', 'RMTarsus1', 'RMTarsus2', 'RMTarsus3', 'RMTarsus4', 'RMTarsus5', 'RHTarsus1', 'RHTarsus2', 'RHTarsus3', 'RHTarsus4', 'RHTarsus5']
flygym.preprogrammed.get_collision_geometries(config: str = 'all') List[str]

Get the list of collision geometries given the key: “all” (all body segments), “legs-no-coxa” (all leg segments excluding the coxa segments), “tarsi” (all tarsus segments), and “none” (nothing).

Pose

flygym.preprogrammed.get_preprogrammed_pose(pose: str) KinematicPose

Load the preprogrammed pose given the key. Available poses are found in the data directory: flygym/data/pose/pose_{key}.yaml. Included poses are:

  • “stretch”: all legs are fully extended sideways to ensure that the legs are not embedded into the ground upon initialization, which breaks the physics. This is the suggested initial pose.

  • “tripod”: a snapshot of a tethered fly walking in a tripod gait.

  • “zero”: the zero pose of the NeuroMechFly model. Not that the fly should be spawned significantly above the ground to ensure that the legs are not extended into the ground upon initialization.

CPG phase biases

We have preprogrammed the CPG phase biases (see tutorial on CPGs for details) for three gait types: tripod, tetrapod, and wave. These can be retrieved using the following function:

flygym.preprogrammed.get_cpg_biases(gait: str) ndarray

Define CPG biases for different gaits.

Parameters:
gaitstr

The gait to use. Available gaits are “tripod”, “tetrapod”, and “wave”.

Returns:
np.ndarray

The CPG biases as a (6, 6) array, where each row/column corresponds to a leg and each element corresponds to the phase bias between the two legs. The order of the legs is: LF, LM, LH, RF, RM, RH (L = left, R = right, F = front, M = middle, H = hind).