# Module: formationBarycenter¶

## Executive Summary¶

This module computes the barycenter of a swarm of satellites. The barycenter can either be computed in the regular cartesian way (using a weighted average of the position and velocity vectors) or using the weighted average of the orbital elements. Both output two navigation messages that describe the position and velocity of the barycenter. The output messages contain the same information, although one is a C++ message and the other is a C-wrapped message.

## 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

scNavInMsgs

vector of spacecraft navigation input messages. These are set through addSpacecraftToModel()

vector of spacecraft payload input messages. These are set through addSpacecraftToModel()

transOutMsg

barycenter information C++ output message

transOutMsgC

barycenter information C-wrapped output message

## Detailed Module Description¶

This module computes the barycenter of a swarm of spacecraft. For the cartesian method, a simple center of mass calculation is made for the position and velocity vectors. Let $$\textbf{x}$$ represent either the position or the velocity vectors. The corresponding weighted average is:

$\bar{\textbf{x}} = \dfrac{1}{m_{total}}\sum_{i}m_i\textbf{x}_i,$

where $$m_{total}=\sum_{i}m_i$$.

For the orbital elements averaging, the process is similar. However, the position and velocity vectors of each spacecraft must first be converted to orbital elements. Once that is done, we take the average of each orbital element $$oe$$ as such:

$\bar{oe} = \dfrac{1}{m_{total}}\sum_{i}m_ioe_i$

This formula is only valid for semi-major axis (a), eccentricity (e) and inclination (i). For the other angular orbital elements, a problem with angle wrapping can occur when the angles are close to zero. For example, if two spacecraft of equal mass have a true anomaly of 10 and 350 degrees, the previous averaging formula would suggest that the mean should be 180 degrees, when in fact it should be 0. To solve this problem, a different formula is used for RAAN ($$\Omega$$), AoP ($$\omega$$) and true anomaly (f):

$\bar{\alpha} = \texttt{atan2}\left(\sum_{i}m_i\sin\alpha_i, \sum_{i}m_i\cos\alpha_i\right)$

where $$\bar{\alpha}$$ is the averaged angular orbital element. The set of $$\bar{oe}$$ are then converted back into position and velocity vectors.

As stated before, the module outputs both a C++ and C-wrapped navigation messages. Both contain the same payload.

## Model Assumptions and Limitations¶

This code makes the following assumptions:

• Gravitational parameter is known

This code has the following limitations:

• Equatorial singularities: when using orbital element averaging, near equatorial orbits may have induce a singularity in the ascending node.

## User Guide¶

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

### Module Setup¶

The temperature module is created in python using:

1barycenterModule = formationBarycenter.FormationBarycenter()
2barycenterModule.ModelTag = 'barycenter'


A sample setup is done using:

 1# Configure spacecraft state input messages
3scNavMsgData1.r_BN_N = rN1
4scNavMsgData1.v_BN_N = vN1
5scNavMsg1 = messaging.NavTransMsg().write(scNavMsgData1)
6
8scNavMsgData2.r_BN_N = rN2
9scNavMsgData2.v_BN_N = vN2
10scNavMsg2 = messaging.NavTransMsg().write(scNavMsgData2)
11
12# Configure spacecraft mass input messages
16
20
21# add spacecraft input messages to module


No further setup is needed for the cartesian method. If the user wants to use orbital elements, the following additional code is needed:

1barycenterModule.useOrbitalElements = True
2barycenterModule.mu = mu


class FormationBarycenter : public SysModel
#include <formationBarycenter.h>

This module computes the barycenter of a swarm of satellites, either using cartesian coordinates or orbital elements.

Public Functions

FormationBarycenter()

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

~FormationBarycenter()

Module Destructor

void SelfInit()

This method self initializes the C-wrapped output message.

void Reset(uint64_t CurrentSimNanos)

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

This is the main method that gets called every time the module is updated.

Adds a scNav and scPayload messages name to the vector of names to be subscribed to.

void computeBaricenter()

Does the barycenter calculations

void WriteOutputMessage(uint64_t CurrentClock)

writes the output messages

Public Members

NavTransMsg_C transOutMsgC = {}

C-wrapped translation navigation output msg, zeroed.

bool useOrbitalElements

flag that determines whether to use cartesian or orbital elementd weighted averaging

double mu

gravitational parameter to be used with orbital elements averaging

BSKLogger bskLogger

BSK Logging

Private Members