Skip to content

Commit

Permalink
Merge pull request #55 from AO-StreetArt/udpApi
Browse files Browse the repository at this point in the history
Additional Rotation Methods
  • Loading branch information
AO-StreetArt committed Mar 27, 2018
2 parents f0a41a1 + 2cc62d0 commit 4faadb5
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 26 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Start by forking the repository, cloning your repository, and changing to the ma

Then, change to the 'scripts/deps' folder and run:

`docker pull aostreetart/clyman`
`docker pull aostreetart/crazyivan`
`docker-compose up`

Now, you can execute the tests and other validations from the main folder of the repository:
Expand Down
10 changes: 5 additions & 5 deletions scripts/py/testUdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0]

updated_test_transform = [2.0, 0.0, 0.0, 2.0,
0.0, 1.0806046, -1.682942, -0.6023374,
0.0, 1.682942, 1.0806046, 2.7635466,
updated_test_transform = [2.0, 0.0, 0.0, 1.0,
0.0, 2.0, 0.0, 1.0,
0.0, 0.0, 2.0, 1.0,
0.0, 0.0, 0.0, 1.0]

# Object data represented through each piece of the flow
Expand All @@ -68,7 +68,7 @@
"owner": "basicTestOwner",
"scene": "basicFlowName",
"translation": [0.0, 0.0, 0.0],
"euler_rotation": [0.0, 1.0, 0.0, 0.0],
"euler_rotation": [0.0, 0.0, 0.0],
"scale": [1.0, 1.0, 1.0],
"assets": ["basicTestAsset"]
}
Expand All @@ -81,7 +81,7 @@
"owner": "Alex",
"scene": "basicFlowName",
"translation": [1.0, 1.0, 1.0],
"euler_rotation": [1.0, 1.0, 0.0, 0.0],
"euler_rotation": [0.0, 0.0, 0.0],
"scale": [2.0, 2.0, 2.0],
"assets": ["anotherAsset"]
}
Expand Down
27 changes: 25 additions & 2 deletions src/main/java/adrestia/model/obj3/ObjectDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class ObjectDocument {
private double[] translation = new double[0];
@JsonProperty("euler_rotation")
private double[] rotationEuler = new double[0];
@JsonProperty("quaternion_rotation")
private double[] rotationQuaternion = new double[0];
private double[] scale = new double[0];
private String[] assets = new String[0];
private double[] transform = new double[0];
Expand All @@ -58,13 +60,15 @@ public ObjectDocument() {
* @param owner The owner of the Object
* @param translation The current translation of the Object
* @param rotationEuler The current rotation of the Object
* @param rotationQuaternion The current rotation of the Object
* @param scale The scale of the Object
* @param assets The asset list of the Object
* @param transform The transform of the object
*/
public ObjectDocument(String key, String name, String type, String subtype, String owner,
String scene, double[] translation, double[] rotationEuler, double[] scale,
String[] assets, double[] transform) {
String scene, double[] translation, double[] rotationEuler,
double[] rotationQuaternion, double[] scale, String[] assets,
double[] transform) {
super();
this.key = key;
this.name = name;
Expand All @@ -74,6 +78,7 @@ public ObjectDocument(String key, String name, String type, String subtype, Stri
this.scene = scene;
this.translation = translation;
this.rotationEuler = rotationEuler;
this.rotationQuaternion = rotationQuaternion;
this.scale = scale;
this.assets = assets;
this.transform = transform;
Expand Down Expand Up @@ -151,6 +156,15 @@ public double[] getRotationEuler() {
return this.rotationEuler;
}

/**
* Returns value of rotationQuaternion.
* @return The current quaternion rotation of the object
*/
@JsonGetter("quaternion_rotation")
public double[] getRotationQuaternion() {
return this.rotationQuaternion;
}

/**
* Returns value of scale.
* @return The current scale of the object
Expand Down Expand Up @@ -249,6 +263,15 @@ public void setRotationEuler(double[] rotationEuler) {
this.rotationEuler = rotationEuler;
}

/**
* Sets new value of rotationQuaternion.
* @param rotationQuaternion The current rotation of the object
*/
@JsonSetter("quaternion_rotation")
public void setRotationQuaternion(double[] rotationQuaternion) {
this.rotationQuaternion = rotationQuaternion;
}

/**
* Sets new value of scale.
* @param scale The current scale of the object
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/adrestia/model/obj3/ObjectList.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,14 @@ public String generateTransformOverwrite() {
.concat(Double.toString(this.documents[i].getRotationEuler()[1]))
.concat(", ")
.concat(Double.toString(this.documents[i].getRotationEuler()[2]))
.concat("], \"quaternion_rotation\": [")
.concat(Double.toString(this.documents[i].getRotationQuaternion()[0]))
.concat(", ")
.concat(Double.toString(this.documents[i].getRotationEuler()[3]))
.concat(Double.toString(this.documents[i].getRotationQuaternion()[1]))
.concat(", ")
.concat(Double.toString(this.documents[i].getRotationQuaternion()[2]))
.concat(", ")
.concat(Double.toString(this.documents[i].getRotationQuaternion()[3]))
.concat("], \"scale\": [")
.concat(Double.toString(this.documents[i].getScale()[0]))
.concat(", ")
Expand Down
8 changes: 5 additions & 3 deletions src/test/java/adrestia/integration/ObjectDaoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ public void testObjectCrud() throws Exception {
try {
// Create test
double[] translation = {0.0, 0.0, 0.0};
double[] rotationEuler = {0.0, 1.0, 0.0, 0.0};
double[] rotationEuler = {0.0, 0.0, 0.0};
double[] rotationQuaternion = {0.0, 1.0, 0.0, 0.0};
double[] scale = {1.0, 1.0, 1.0};
String[] assets = {"TestAsset1", "TestAsset2"};
ObjectDocument testDocument = new ObjectDocument("TestKey", "TestName",
"TestType", "TestSubtype", "TestOwner", "TestScene",
translation, rotationEuler, scale, assets, null);
translation, rotationEuler, rotationQuaternion, scale, assets, null);
ObjectList crtResp = objData.create(testDocument);
testLogger.println("Create Test Response: ");
testLogger.println(crtResp);
Expand Down Expand Up @@ -100,11 +101,12 @@ public void testObjectCrud() throws Exception {
// Overwrite Test
double[] ovrTranslation = {1.0, 1.0, 1.0};
double[] ovrRotationEuler = {0.0, 1.0, 0.0, 0.0};
double[] ovrRotationQuaternion = {0.0, 1.0, 0.0, 0.0};
double[] ovrScale = {1.0, 1.0, 1.0};
String[] ovrAssets = {"TestAsset1", "TestAsset2"};
ObjectDocument overwriteTestDoc = new ObjectDocument(clymanKey, "TestName",
"TestType", "TestSubtype", "TestOwner", "TestScene",
ovrTranslation, ovrRotationEuler, ovrScale, ovrAssets, null);
ovrTranslation, ovrRotationEuler, ovrRotationQuaternion, ovrScale, ovrAssets, null);
ObjectList ovrResp = objData.overwrite(overwriteTestDoc);
testLogger.println("Overwrite Test Response: ");
testLogger.println(ovrResp.getErrorCode());
Expand Down
27 changes: 16 additions & 11 deletions src/test/java/adrestia/system/ObjectServerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ public void testObjectCrudApi() throws Exception {
// Build a new Object
testLogger.println("Create Test");
double[] translation = {0.0, 0.0, 0.0};
double[] rotationEuler = {0.0, 1.0, 0.0, 0.0};
double[] rotationEuler = {0.0, 0.0, 0.0};
double[] rotationQuaternion = {0.0, 1.0, 0.0, 0.0};
double[] scale = {1.0, 1.0, 1.0};
String[] assets = {"TestAsset1", "TestAsset2"};
ObjectDocument obj = new ObjectDocument("TestKey", "AeselTestObject11",
"TestType", "TestSubtype", "TestOwner", "AeselTestScene11",
translation, rotationEuler, scale, assets, null);
translation, rotationEuler, rotationQuaternion, scale, assets, null);

// Post the Object to the endpoint
ResponseEntity<Map> createResponse = this.testTemplate.postForEntity(
Expand Down Expand Up @@ -101,12 +102,13 @@ public void testObjectCrudApi() throws Exception {
// Update Test
testLogger.println("Update Test");
double[] translation2 = {1.0, 1.0, 1.0};
double[] rotationEuler2 = {1.0, 1.0, 1.0, 45.0};
double[] rotationEuler2 = {0.0, 0.0, 0.0};
double[] rotationQuaternion2 = {1.67, 1.0, 1.0, 1.0};
double[] scale2 = {2.0, 2.0, 2.0};
String[] assets2 = {"TestAsset3", "TestAsset4"};
ObjectDocument obj2 = new ObjectDocument("TestKey", "AeselTestObject11",
"TestType2", "TestSubtype2", "TestOwner2", "AeselTestScene11",
translation2, rotationEuler2, scale2, assets2, null);
translation2, rotationEuler2, rotationQuaternion2, scale2, assets2, null);
// Post the Scene to the endpoint
ResponseEntity<Map> updateResponse = this.testTemplate.postForEntity(
"http://localhost:" + this.port + testObjectUrl, obj2, Map.class);
Expand All @@ -131,13 +133,14 @@ public void testObjectCrudApi() throws Exception {
// Overwrite Test
testLogger.println("Create Test");
double[] ovrTranslation = {1.0, 1.0, 1.0};
double[] ovrRotationEuler = {0.0, 1.0, 0.0, 0.0};
double[] ovrRotationEuler = {0.0, 0.0, 0.0};
double[] ovrRotationQuaternion = {0.0, 1.0, 0.0, 0.0};
double[] ovrScale = {1.0, 1.0, 1.0};
String[] ovrAssets = {"TestAsset1", "TestAsset2"};
String clymanKey = crtRespBody.get("key").toString();
ObjectDocument ovrObj = new ObjectDocument(clymanKey, "AeselTestObject11",
"TestType", "TestSubtype", "TestOwner", "AeselTestScene11",
ovrTranslation, ovrRotationEuler, ovrScale, ovrAssets, null);
ovrTranslation, ovrRotationEuler, ovrRotationQuaternion, ovrScale, ovrAssets, null);
ResponseEntity<Map> ovrResponse = this.testTemplate.postForEntity(
"http://localhost:" + this.port + "/v1/object/" + clymanKey, ovrObj, Map.class);
testLogger.println(ovrResponse.getStatusCode());
Expand Down Expand Up @@ -173,20 +176,21 @@ private void populateQueryData() {
final String testObjectUrl = "/v1/scene/MyFirstQueryScene/object/obj1";
final String testObjectUrl2 = "/v1/scene/MyFirstQueryScene/object/obj2";
double[] translation = {0.0, 0.0, 0.0};
double[] rotationEuler = {0.0, 1.0, 0.0, 0.0};
double[] rotationEuler = {0.0, 0.0, 0.0};
double[] rotationQuaternion = {0.0, 1.0, 0.0, 0.0};
double[] scale = {1.0, 1.0, 1.0};
String[] assets = {"TestAsset1", "TestAsset2"};
ObjectDocument obj = new ObjectDocument("TestKey", "obj1",
"TestType", "TestSubtype", "TestOwner", "MyFirstQueryScene",
translation, rotationEuler, scale, assets, null);
translation, rotationEuler, rotationQuaternion, scale, assets, null);
// Post the Scene to the endpoint
ResponseEntity<Map> createResponse = this.testTemplate.postForEntity(
"http://localhost:" + this.port + testObjectUrl, obj, Map.class);
// Read the response
Assert.assertTrue(createResponse.getStatusCode().is2xxSuccessful());
ObjectDocument obj2 = new ObjectDocument("TestKey", "obj2",
"TestType2", "TestSubtype2", "TestOwner2", "MyFirstQueryScene",
translation, rotationEuler, scale, assets, null);
translation, rotationEuler, rotationQuaternion, scale, assets, null);
// Post the Scene to the endpoint
ResponseEntity<Map> createResponse2 = this.testTemplate.postForEntity(
"http://localhost:" + this.port + testObjectUrl2, obj2, Map.class);
Expand Down Expand Up @@ -239,12 +243,13 @@ public void testObjectLockApi() throws Exception {
try {
testLogger.println("Populating Data for Lock Tests");
double[] translation = {0.0, 0.0, 0.0};
double[] rotationEuler = {0.0, 1.0, 0.0, 0.0};
double[] rotationEuler = {0.0, 0.0, 0.0};
double[] rotationQuaternion = {0.0, 1.0, 0.0, 0.0};
double[] scale = {1.0, 1.0, 1.0};
String[] assets = {"TestAsset1", "TestAsset2"};
ObjectDocument obj = new ObjectDocument("TestKey", "obj1",
"TestType", "TestSubtype", "TestOwner", "MyLockScene",
translation, rotationEuler, scale, assets, null);
translation, rotationEuler, rotationQuaternion, scale, assets, null);
// Post the object to the endpoint
ResponseEntity<Map> createResponse = this.testTemplate.postForEntity(
"http://localhost:" + this.port + testObjectUrl, obj, Map.class);
Expand Down
10 changes: 6 additions & 4 deletions src/test/java/adrestia/unit/ObjTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ public void testObjectDocument() throws Exception {
try {
// Full Constructor Test
double[] translation = {0.0, 0.0, 0.0};
double[] rotationEuler = {0.0, 0.0, 0.0, 0.0};
double[] rotationEuler = {0.0, 0.0, 0.0};
double[] rotationQuaternion = {0.0, 1.0, 0.0, 0.0};
double[] scale = {0.0, 0.0, 0.0};
String[] assets = {"TestAsset1", "TestAsset2"};
double[] transform = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
ObjectDocument testDocument = new ObjectDocument("TestKey", "TestName",
"TestType", "TestSubtype", "TestOwner", "TestScene",
translation, rotationEuler, scale, assets, transform);
translation, rotationEuler, rotationQuaternion, scale, assets, transform);
// Test the get methods
Assert.assertTrue(testDocument.getKey().equals("TestKey"));
Assert.assertTrue(testDocument.getName().equals("TestName"));
Expand Down Expand Up @@ -103,12 +104,13 @@ public void testObjectList() throws Exception {
try {
// Full Constructor Test
double[] translation = {0.0, 0.0, 0.0};
double[] rotationEuler = {0.0, 0.0, 0.0, 0.0};
double[] rotationEuler = {0.0, 0.0, 0.0};
double[] rotationQuaternion = {0.0, 1.0, 0.0, 0.0};
double[] scale = {0.0, 0.0, 0.0};
String[] assets = {"TestAsset1", "TestAsset2"};
ObjectDocument testDocument = new ObjectDocument("TestKey", "TestName",
"TestType", "TestSubtype", "TestOwner", "TestScene",
translation, rotationEuler, scale, assets, null);
translation, rotationEuler, rotationQuaternion, scale, assets, null);

ObjectDocument[] docList = {testDocument};
ObjectList objList = new ObjectList(1, 1, docList, 100, "ErrMsg", "TransactionID");
Expand Down

0 comments on commit 4faadb5

Please sign in to comment.