Module: motorVoltageInterface

Executive Summary

Interface module to convert an array of motor input voltages to an array of motor torques.

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

motorVoltageInMsg

ArrayMotorVoltageMsgPayload

Message that contains motor voltage input states

motorTorqueOutMsg

ArrayMotorTorqueMsgPayload

Output message for motor torques

Detailed Model Description

This module is a simulation environment module which simulates the analog voltage interface of a motor cluster. The input is an array of voltages \(V_i\). The motor torque \(u_{s_i}\) is evaluated using a linear mapping

\[u_{s_i}=V_i\gamma_iSF_i+b_i\]

where \(\gamma\) is a constant value gain. SF is the scale factor error (i.e. a constant 1% gain error SF = 1.01). \(b\) is the bias term (i.e. a constant 1 Nm error on torque \(b\) = 1.) The output of the module is an array of motor torques.

Model Functions

The functions of the voltage to torque model are:

  • Voltage to Torque: Converts given voltage to a torque command.

Model Assumptions and Limitations

This code makes assumptions which are common to IMU modeling.

  • No noise: There is no random noise input when making the voltage to torque conversion.

  • All motors are the same: All motors utilize the same gain, scale factor, and bias. No motor can be singled out to have higher scale factor or bias, etc.

User Guide

This section contains conceptual overviews of the code and clear examples for the prospective user.

Module Setup

The interface module is created in python using:

1testModule = motorVoltageInterface.MotorVoltageInterface()
2testModule.ModelTag = "motorVoltageInterface"

If you have \(N\) motors being modeled, the module parameters are set as N-dimensional lists of values. The only parameter that must be set is the voltage to torque conversion gain \(\gamma\) called voltage2TorqueGain. The scale factor \(SF\) is called scaleFactor and defaults to 1. The bias \(b_i\) is called bias and defaults to zero.

A sample setup is done using:

1testModule.voltage2TorqueGain =[ 1.32, 0.99, 1.31] # [Nm/V] conversion gain
2testModule.scaleFactor =[ 1.01, 1.00, 1.02] # [unitless] scale factor
3testModule.bias =[0.01, 0.02, 0.04] # [Nm] bias

class MotorVoltageInterface : public SysModel
#include <motorVoltageInterface.h>

RW voltage interface class.

Public Functions

MotorVoltageInterface()

This is the constructor for the motor voltgage interface. It sets default variable values and initializes the various parts of the model

~MotorVoltageInterface()

Destructor. Nothing here.

void computeMotorTorque()

This method evaluates the motor torque output states.

Returns:

void

void Reset(uint64_t CurrentSimNanos)

Reset the module to original configuration values.

Returns:

void

void UpdateState(uint64_t CurrentSimNanos)

This method calls all of the run-time operations for the motor voltage interface module.

Parameters:

CurrentSimNanos – The clock time associated with the model call

Returns:

void

void readInputMessages()

This method reads the motor voltage input messages

void writeOutputMessages(uint64_t Clock)

This method writes the Motor torque output state message.

Parameters:

CurrentClock – The clock time associated with the model call

Returns:

void

void setGains(Eigen::VectorXd gains)

&#8212; Takes in an array of gains to set for rws and sets them, leaving blanks up to MAX_EFF_COUNT

This method sets the list of motor voltage to torque gains.

Returns:

void

void setScaleFactors(Eigen::VectorXd scaleFactors)

&#8212; Takes in an array of scale factors to set for rws and sets them, leaving blanks up to MAX_EFF_COUNT

This method sets (per motor) voltage to torque scale factors (linear proportional error)

Returns:

void

void setBiases(Eigen::VectorXd biases)

&#8212; Takes in an array of biases to set for rws and sets them, leaving blanks up to MAX_EFF_COUNT

This method sets the list of voltage to torque biases (per rw)

Returns:

void

Public Members

ReadFunctor<ArrayMotorVoltageMsgPayload> motorVoltageInMsg

&#8212; Message that contains motor voltage input states

Message<ArrayMotorTorqueMsgPayload> motorTorqueOutMsg

&#8212; Output Message for motor torques

Eigen::VectorXd voltage2TorqueGain

Nm/V gain to convert voltage to motor torque.

Eigen::VectorXd scaleFactor

scale the output - like a constant gain error

Eigen::VectorXd bias

Nm A bias to add to the torque output.

BSKLogger bskLogger

&#8212; BSK Logging

Private Members

ArrayMotorTorqueMsgPayload outputTorqueBuffer

[Nm] copy of module output buffer

uint64_t prevTime

&#8212; Previous simulation time observed

ArrayMotorVoltageMsgPayload inputVoltageBuffer

[V] One-time allocation for time savings