Skip to content

Commit

Permalink
changing the storage type to be more compatible with json encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Jul 25, 2024
1 parent f0c79d2 commit b30018f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.apache.commons.math3.geometry.euclidean.threed.RotationConvention;
import org.apache.commons.math3.geometry.euclidean.threed.RotationOrder;

import com.google.gson.annotations.Expose;
import com.neuronrobotics.sdk.common.Log;

// TODO: Auto-generated Javadoc
Expand All @@ -22,7 +23,16 @@ public class RotationNR {

/** The rotation matrix. */
// double[][] rotationMatrix = ;
private Rotation storage = new Rotation(1, 0, 0, 0, false);

@Expose (serialize = true, deserialize = true)
double w=1;
@Expose (serialize = true, deserialize = true)
double x=0;
@Expose (serialize = true, deserialize = true)
double y=0;
@Expose (serialize = true, deserialize = true)
double z=0;
//private Rotation storage = new Rotation(1, 0, 0, 0, false);
private static RotationOrder order = RotationOrder.ZYX;
private static RotationConvention convention = RotationConvention.VECTOR_OPERATOR;

Expand All @@ -42,7 +52,7 @@ public RotationNR() {
* instance
*/
public RotationNR(Rotation store) {
storage = store;
setStorage(store);
}

/**
Expand Down Expand Up @@ -387,7 +397,7 @@ private double getAngle(int index){
* @return the rotation matrix2 quaturnion w
*/
public double getRotationMatrix2QuaturnionW() {
return getStorage().getQ0();
return w;
}

/**
Expand All @@ -396,7 +406,7 @@ public double getRotationMatrix2QuaturnionW() {
* @return the rotation matrix2 quaturnion x
*/
public double getRotationMatrix2QuaturnionX() {
return -getStorage().getQ1();
return -x;
}

/**
Expand All @@ -405,7 +415,7 @@ public double getRotationMatrix2QuaturnionX() {
* @return the rotation matrix2 quaturnion y
*/
public double getRotationMatrix2QuaturnionY() {
return -getStorage().getQ2();
return -y;
}

/**
Expand All @@ -414,7 +424,7 @@ public double getRotationMatrix2QuaturnionY() {
* @return the rotation matrix2 quaturnion z
*/
public double getRotationMatrix2QuaturnionZ() {
return -getStorage().getQ3();
return -z;
}

public static RotationOrder getOrder() {
Expand All @@ -434,11 +444,14 @@ public static void setConvention(RotationConvention convention) {
}

public Rotation getStorage() {
return storage;
return new Rotation(w,x,y,z,false);
}

public void setStorage(Rotation storage) {
this.storage = storage;
w=storage.getQ0();
x=storage.getQ1();
y=storage.getQ2();
z=storage.getQ3();
}

public void set(double[][] poseRot) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;

import com.google.gson.annotations.Expose;
import com.neuronrobotics.sdk.common.Log;
import Jama.Matrix;

Expand All @@ -13,15 +15,20 @@
public class TransformNR {
private ArrayList<ITransformNRChangeListener> listeners=null;
/** The x. */
@Expose (serialize = true, deserialize = true)
private double x;

/** The y. */
@Expose (serialize = true, deserialize = true)
private double y;

/** The z. */
@Expose (serialize = true, deserialize = true)
private double z;

/** The rotation. */

@Expose (serialize = true, deserialize = true)
private RotationNR rotation;


Expand Down

0 comments on commit b30018f

Please sign in to comment.