Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions simulator/src/main/java/msp/simulator/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public static void main(String[] args) {
Dashboard.setInitialRotAcceleration(new Vector3D(0,0,0));
Dashboard.setTorqueDisturbances(true);

Dashboard.setCommandTorqueProvider(TorqueProviderEnum.MEMCACHED);
Dashboard.setMemCachedConnection(true, "127.0.0.1:11211");
//Dashboard.setCommandTorqueProvider(TorqueProviderEnum.MEMCACHED);
//Dashboard.setMemCachedConnection(false, "127.0.0.1:11211");

Dashboard.setVtsConnection(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,22 @@ public void writeStep(Satellite satellite) {
double torqueX = ang_accel.getX()/satellite.getAssembly().getBody().getInertiaMatrix()[0][0];
double torqueY = ang_accel.getY()/satellite.getAssembly().getBody().getInertiaMatrix()[1][1];
double torqueZ = ang_accel.getZ()/satellite.getAssembly().getBody().getInertiaMatrix()[2][2];

Vector3D torque = new Vector3D(torqueX,torqueY,torqueZ);
if (torque.getNorm() != 0) {
torque = torque.normalize();
}
buff
.append(days)
.append(" ") /* Column Separator */
.append(seconds)
.append(" ")
.append(torqueX)
.append(torque.getX())
.append(" ")
.append(torque.getY())
.append(" ")
.append(torqueY)
.append(torque.getZ())
.append(" ")
.append(torqueZ)
.append(0)
;
this.writerAEM_torque.append(buff+LS);
this.writerAEM_torque.flush();
Expand All @@ -295,6 +300,10 @@ public void writeStep(Satellite satellite) {

/** Writing to the angular velocity file */
Vector3D vel = satellite.getStates().getCurrentState().getAttitude().getSpin();
vel.normalize();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the operation is used as if it works in-place, but all the other uses of it treat it as if it returns the computed value. Maybe remove this line as it's redundant with the check on the next couple of lines.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I forgot to delete that line

if (vel.getNorm() != 0) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this check if it's equal to 1 instead?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No the purpose of this is to check for divide by zero errors, this is correct

vel = vel.normalize();
}
buff
.append(days)
.append(" ") /* Column Separator */
Expand All @@ -305,6 +314,8 @@ public void writeStep(Satellite satellite) {
.append(vel.getY())
.append(" ")
.append(vel.getZ())
.append(" ")
.append(0)
;
this.writerAEM_angVel.append(buff+LS);
this.writerAEM_angVel.flush();
Expand All @@ -313,6 +324,9 @@ public void writeStep(Satellite satellite) {

/** Writing to the angular momentum file */
Vector3D mom = satellite.getAssembly().getAngularMomentum();
if(mom.getNorm()!= 0) {
mom = mom.normalize();
}
buff
.append(days)
.append(" ") /* Column Separator */
Expand All @@ -323,6 +337,8 @@ public void writeStep(Satellite satellite) {
.append(mom.getY())
.append(" ")
.append(mom.getZ())
.append(" ")
.append(0)
;
this.writerAEM_angMomentum.append(buff+LS);
this.writerAEM_angMomentum.flush();
Expand All @@ -331,6 +347,7 @@ public void writeStep(Satellite satellite) {

/* Writing the current mag field to the log file. */
Vector3D mag_field = satellite.getSensors().getMagnetometer().retrievePerfectField().getFieldVector();
mag_field = mag_field.normalize();
buff
.append(days)
.append(" ") /* Column Separator */
Expand All @@ -341,6 +358,8 @@ public void writeStep(Satellite satellite) {
.append(mag_field.getY())
.append(" ")
.append(mag_field.getZ())
.append(" ")
.append(0)
;
this.writerAEM_mag.append(buff.toString()+ LS);
this.writerAEM_mag.flush();
Expand Down