Skip to main content
Sensor modules consume spacecraft state messages and produce corrupted, noisy measurements that mimic real flight hardware. Each module reads a truth state, applies a configurable noise and bias model, and writes a sensor-specific output message.
Most sensor modules apply corruption models documented in the Basilisk sensor corruption framework. Corruption types include Gaussian noise, bias, scale factor, saturation, and fault injection.

Attitude sensors

Simulates a three-axis Inertial Measurement Unit (IMU). The module computes delta-velocity and delta-angle outputs from spacecraft state truth, then applies configurable noise and bias.
On the first simulation step the module outputs a zeroed message. IMU data is only available from the second step onwards.
Messages
MessageTypeDirectionDescription
scStateInMsgSCStatesMsgPayloadInputSpacecraft state truth
sensorOutMsgIMUSensorMsgPayloadOutputIMU delta-velocity and delta-angle measurements
from Basilisk.simulation import imuSensor
from Basilisk.utilities import macros

imu = imuSensor.ImuSensor()
imu.ModelTag = 'imuSensor'

# Mount orientation: sensor frame relative to body frame
imu.setBodyToPlatformDCM(0.0, 0.0, 0.0)  # psi, theta, phi Euler 3-2-1

# Noise
imu.senRotNoiseStd = [1e-5, 1e-5, 1e-5]  # [rad/s] gyro noise std
imu.senTransNoiseStd = [1e-4, 1e-4, 1e-4] # [m/s^2] accel noise std

imu.scStateInMsg.subscribeTo(scObject.scStateOutMsg)
sim.AddModelToTask(taskName, imu)
Simulates a star tracker that measures the spacecraft inertial attitude as a quaternion. The module reads spacecraft attitude truth and applies configurable Gaussian noise.Messages
MessageTypeDirectionDescription
scStateInMsgSCStatesMsgPayloadInputSpacecraft state truth
sensorOutMsgSTSensorMsgPayloadOutputMeasured quaternion attitude
from Basilisk.simulation import starTracker

st = starTracker.StarTracker()
st.ModelTag = 'starTracker'
st.sigmaStarTracker = 20.0 / 3600.0 * (3.14159 / 180.0)  # [rad] 20 arcsec noise
st.scStateInMsg.subscribeTo(scObject.scStateOutMsg)

sim.AddModelToTask(taskName, st)

Sun sensors

Models a single Coarse Sun Sensor (CSS). The module outputs ADC counts proportional to the cosine of the angle between the sensor boresight and the sun direction, with a configurable field of view, noise, and saturation model.The module supports a companion CSSConstellation class that aggregates multiple CSS units into a single array output message.Fault modes
FaultDescription
CSSFAULT_OFFSensor output is permanently zero
CSSFAULT_STUCK_CURRENTOutput stuck at the value from the previous step
CSSFAULT_STUCK_MAXOutput stuck at the maximum value
CSSFAULT_STUCK_RANDOutput stuck at a random value
CSSFAULT_RANDOutput is random noise
Messages
MessageTypeDirectionDescription
sunInMsgSpicePlanetStateMsgPayloadInputSun ephemeris
stateInMsgSCStatesMsgPayloadInputSpacecraft state
cssDataOutMsgCSSRawDataMsgPayloadOutputCSS output counts
cssConfigLogOutMsgCSSConfigLogMsgPayloadOutputCSS configuration log
sunEclipseInMsgEclipseMsgPayloadInput (optional)Eclipse state
albedoInMsgAlbedoMsgPayloadInput (optional)Albedo contribution
from Basilisk.simulation import coarseSunSensor

css = coarseSunSensor.CoarseSunSensor()
css.ModelTag = 'css1'
css.fov = 80.0 * (3.14159 / 180.0)  # [rad] half-angle field of view
css.maxOutput = 1.0                  # normalized max output
css.minOutput = 0.0
css.senNoiseStd = 0.001              # Gaussian noise standard deviation
css.nHat_B = [0.0, 0.0, 1.0]        # boresight in body frame

css.sunInMsg.subscribeTo(sunMsg)
css.stateInMsg.subscribeTo(scObject.scStateOutMsg)

# Inject a fault if needed
# css.faultState = coarseSunSensor.CSSFAULT_OFF

sim.AddModelToTask(taskName, css)
When creating CSS objects in a loop, store a reference to each instance on your simulation object. Python will garbage-collect CSS objects that go out of scope, causing unexpected behavior.

Magnetic sensors

Simulates a Three-Axis Magnetometer (TAM). The module transforms the truth magnetic field vector from the inertial frame into the sensor frame and applies Gaussian noise, bias, scale factor, and saturation.Fault modes
FaultDescription
MAG_FAULT_STUCK_CURRENTMeasurement freezes at the current value
MAG_FAULT_STUCK_VALUEMeasurement sticks to a user-specified value
MAG_FAULT_SPIKINGMeasurement spikes with configurable probability and amplitude
Messages
MessageTypeDirectionDescription
stateInMsgSCStatesMsgPayloadInputSpacecraft state
magInMsgMagneticFieldMsgPayloadInputInertial magnetic field truth
tamDataOutMsgTAMSensorMsgPayloadOutputTAM measurement in sensor frame
from Basilisk.simulation import magnetometer, magneticFieldCenteredDipole

magField = magneticFieldCenteredDipole.MagneticFieldCenteredDipole()
magField.ModelTag = 'CenteredDipole'
magField.addSpacecraftToModel(scObject.scStateOutMsg)

tam = magnetometer.Magnetometer()
tam.ModelTag = 'TAM'
tam.setBodyToSensorDCM(0.0, 0.0, 0.0)  # psi, theta, phi Euler 3-2-1
tam.senNoiseStd = [100e-9, 100e-9, 100e-9]  # [T] 100 nT noise
tam.senBias = [0.0, 0.0, 0.0]               # [T] bias

tam.stateInMsg.subscribeTo(scObject.scStateOutMsg)
tam.magInMsg.subscribeTo(magField.envOutMsgs[0])

sim.AddModelToTask(taskName, magField)
sim.AddModelToTask(taskName, tam)

Camera

Applies realistic image degradations to an input camera image. The module reads raw image data (from a Vizard render or a file) and applies a configurable corruption pipeline in this fixed order:
  1. Gaussian noise
  2. Box blur
  3. Dark current
  4. HSV color adjustment
  5. BGR color adjustment
  6. Dead and stuck pixels (salt and pepper)
  7. Cosmic ray streaks
Set any corruption parameter to 0 to disable that stage.Messages
MessageTypeDirectionDescription
imageInMsgCameraImageMsgPayloadInputRaw camera image
cameraConfigOutMsgCameraConfigMsgPayloadOutputCamera configuration
imageOutMsgCameraImageMsgPayloadOutputCorrupted camera image
from Basilisk.simulation import camera
from Basilisk.utilities import macros

cam = camera.Camera()
cam.ModelTag = 'camera'
cam.cameraIsOn = 1
cam.sigma_CB = [0, 0, 1]        # camera to body MRP

# Corruption parameters (0 = disabled)
cam.gaussian = 2                 # Gaussian noise level
cam.darkCurrent = 1              # Dark current level
cam.saltPepper = 2               # Dead/stuck pixel probability scale
cam.cosmicRays = 1               # Number of cosmic ray events
cam.blurParam = 3                # Box blur kernel size (must be odd)
cam.hsv = [30 * macros.D2R, 0, 0]  # [rad, %, %] hue, saturation, value

cam.imageInMsg.subscribeTo(inputCamMsg)
sim.AddModelToTask(taskName, cam)

Utility sensors

simpleMassProps

Estimates spacecraft mass properties from a connected state effector configuration. Outputs an SCMassPropsMsgPayload for use by estimation algorithms.

simpleVoltEstimator

Estimates battery voltage from a power storage state message. Provides a simple VoltMsgPayload output for voltage-dependent fault detection logic.

hingedRigidBodyMotorSensor

Measures the state (angle and rate) of a hinged rigid body motor actuator, simulating encoder feedback for deployed appendages.

Build docs developers (and LLMs) love