Module: hingedRigidBodyMotor

Executive Summary

Calculates a motor torque given a sensed and reference hinged rigid body state using a simple PD control law.

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

hingedBodyStateSensedInMsg

HingedRigidBodyMsgPayload

sensed rigid body state (theta, theta dot)

hingedBodyStateReferenceInMsg

HingedRigidBodyMsgPayload

reference hinged rigid body state (theta, theta dot)

motorTorqueOutMsg

ArrayMotorTorqueMsgPayload

motor torque on hinged rigid body

Detailed Model Description

This module takes in a reference angle and angle rate, as well as a sensed angle and angle rate, and calculates the motor torque according to:

\[u = -K(\theta_s-\theta_r)-P(\dot{\theta}_s-\dot{\theta}_r)\]

K and P are the constant gains. Both should be set to positive values.

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 = hingedRigidBodyMotor.hingedRigidBodyMotor()
2testModule.ModelTag = "hingedRigidBodyMotor"

A sample setup is done using:

1testModule.K = 1 # proportional gain constant
2testModule.P = 1 # derivative gain constant

If \(K\) and \(P\) are not set, they default to 0.


class HingedRigidBodyMotor : public SysModel
#include <hingedRigidBodyMotor.h>

Calculates a motor torque to drive a hinged panel to a reference angle state. A sensed and reference hinged rigid body angle drives a simple PD control law.

Public Functions

HingedRigidBodyMotor()

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

~HingedRigidBodyMotor()

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. It calculates a motor torque on a hinged rigid body using a simple PD control law.

Returns:

void

Public Members

double K

gain on theta

double P

gain on theta dot

ReadFunctor<HingedRigidBodyMsgPayload> hingedBodyStateSensedInMsg

sensed rigid body state (theta, theta dot)

ReadFunctor<HingedRigidBodyMsgPayload> hingedBodyStateReferenceInMsg

reference hinged rigid body state (theta, theta dot)

Message<ArrayMotorTorqueMsgPayload> motorTorqueOutMsg

motor torque on hinged rigid body

BSKLogger bskLogger

&#8212; BSK Logging