Module: hingedRigidBodyMotorSensor

Executive Summary

Outputs measured angle and angle rate for a hinged rigid body. By default the angle measurement does not contain any measurement errors. The module can be configured to add gaussian noise, a bias or a discretization error to the measured state.

Message Connection Descriptions

The following table lists all the module input and output messages. The module msg connection is set by the user from python. The msg type contains a link to the message structure definition, while the description provides information on what this message is used for.

Module I/O Messages

Msg Variable Name

Msg Type

Description

hingedRigidBodyMotorSensorInMsg

HingedRigidBodyMsgPayload

input hinged rigid body state

hingedRigidBodyMotorSensorOutMsg

HingedRigidBodyMsgPayload

sensed hinged rigid body state

Detailed Model Description

This module adds optional noise, bias, and discretization to a hinged rigid body state.

User Guide

This section contains a conceptual overview of the code and an example for the prospective user.

Module Setup

The interface module is created in python using:

1testModule = hingedRigidBodyMotorSensor.HingedRigidBodyMotorSensor()
2testModule.ModelTag = "motorSensor"

The sensor adds an optional noise (defined by a standard deviation), bias, and discretization to theta and thetaDot. If no noise is specified then the default behavior is for the actual panel states to be passed along as the sensed state.

A sample setup is done using:

1testModule.thetaNoiseStd = thetaNoiseStd # [rad]
2testModule.thetaDotNoiseStd = thetaDotNoiseStd # [rad/s]
3testModule.thetaBias = thetaBias # [rad]
4testModule.thetaDotBias = thetaDotBias # [rad/s]
5testModule.thetaLSB = thetaLSB # [rad] smallest resolution of sensor
6testModule.thetaDotLSB = thetaDotLSB # [rad/s] smallest sensor rate resolution

When discretizing, the value is rounded up or down to the nearest sensor state resolution. The seed used for the noise can also be changed using:

1testModule.RNGSeed = newSeed

Where newSeed is the unsigned integer value of the new RNG seed.


class HingedRigidBodyMotorSensor : public SysModel
#include <hingedRigidBodyMotorSensor.h>

Outputs measured angle and angle rate for a hinged rigid body, adding optional noise, bias, and discretization.

Public Functions

HingedRigidBodyMotorSensor()

This is the constructor for the module class. It sets default variable values and initializes the various parts of the model

~HingedRigidBodyMotorSensor()

Module Destructor

void Reset(uint64_t CurrentSimNanos)

This method is used to reset the module and checks that required input messages are connect.

Returns:

void

void UpdateState(uint64_t CurrentSimNanos)

This is the main method that gets called every time the module is updated. Adds Gaussian noise and bias and diescretizes output.

Returns:

void

void setRNGSeed(unsigned int newSeed)

for setting the seed

This allows the RNGSeed to be changed.

Returns:

void

Public Members

double thetaNoiseStd

[rad] standard deviation for Gaussian noise to theta

double thetaDotNoiseStd

[rad/s] standard deviation for Gaussian noise to theta dot

double thetaBias

[rad] bias added to true theta

double thetaDotBias

[rad/s] bias added to true theta dot

double thetaLSB

[rad] discretization for theta

double thetaDotLSB

[rad/s] discretization for theta dot

ReadFunctor<HingedRigidBodyMsgPayload> hingedRigidBodyMotorSensorInMsg

input message for true rigid body state (theta, theta dot)

Message<HingedRigidBodyMsgPayload> hingedRigidBodyMotorSensorOutMsg

output message for sensed rigid body state

BSKLogger bskLogger

&#8212; BSK Logging

Private Members

std::minstd_rand rGen

&#8212; Random number generator for model

std::normal_distribution<double> rNum

&#8212; Random number distribution for model