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
51 changes: 51 additions & 0 deletions .github/workflows/gradle_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build APK

on:
push:
branches: [ master, dev, ci-cd ]
pull_request:
branches: [ master, dev ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Configure SSH for private submodules
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
repository: Botts-Innovative-Research/osh-android

- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'

- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
packages: ''

- name: Build APK
run: |
chmod +x ./gradlew
./gradlew build -x test -x osgi -x lintDebug -x javadoc

- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: osh-android-APK
path: sensorhub-android-app/build/outputs/apk/debug/sensorhub-android-app-debug.apk

- name: Create GitHub Release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: app/build/outputs/apk/basic/release/*.apk
generate_release_notes: true
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ public class AndroidOrientationEulerOutput extends AndroidSensorOutput implement
// for euler computation
Quat4d att = new Quat4d();
Vect3d look = new Vect3d();
Vect3d up = new Vect3d();
Vect3d euler = new Vect3d();



private final float[] rotationMatrix = new float[9];
private final float[] orientationAngles = new float[3];


protected AndroidOrientationEulerOutput(AndroidSensorsDriver parentModule, SensorManager aSensorManager, Sensor aSensor)
{
super(parentModule, aSensorManager, aSensor);
Expand Down Expand Up @@ -96,50 +100,28 @@ public void onSensorChanged(SensorEvent e)
{
double sampleTime = getJulianTimeStamp(e.timestamp);

// convert to quaternion + normalize
AndroidOrientationQuatOutput.getQuaternionFromVector(att, e.values);
att.normalize();

// Y direction in phone ref frame ( the top of the screen )
look.x = 0;
look.y = 1;
look.z = 0;

// rotate to ENU
att.rotate(look, look);

double heading = 90. - Math.toDegrees(Math.atan2(look.y, look.x));
if (heading > 180.)
heading -= 360.;
double pitch = 0.0;//Math.toDegrees(Math.atan2(look.y, look.x)) - 90.;
double roll = 0.0;

/*double sqw = q.w*q.w;
double sqx = q.x*q.x;
double sqy = q.y*q.y;
double sqz = q.z*q.z;
System.out.println(q0);
euler.z = Math.atan2(2.0 * (q.x*q.y + q.z*q.W), sqx - sqy - sqz + sqw); // heading
euler.y = Math.atan2(2.0 * (q.y*q.z + q.x*q.w), -sqx - sqy + sqz + sqw); // pitch
euler.x = Math.asin(-2.0 * (q.x*q.z - q.y*q.w)); // roll
euler.scale(180./Math.PI);

double oldx = euler.x; // convert to ENU
euler.x = euler.y;
euler.y = oldx;
euler.z = -euler.z;*/

// build and populate datablock
DataBlock dataBlock = dataStruct.createDataBlock();
dataBlock.setDoubleValue(0, sampleTime);
dataBlock.setFloatValue(1, (float)heading);
dataBlock.setFloatValue(2, (float)pitch);
dataBlock.setFloatValue(3, (float)roll);

// TODO since this sensor is high rate, we could package several records in a single event
// update latest record and send event
latestRecord = dataBlock;
latestRecordTime = System.currentTimeMillis();
eventHandler.publish(new DataEvent(latestRecordTime, this, dataBlock));
if (e.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) {
SensorManager.getRotationMatrixFromVector(rotationMatrix, e.values);

SensorManager.getOrientation(rotationMatrix, orientationAngles);

float azimuth = (float) Math.toDegrees(orientationAngles[0]);
float pitch = (float) Math.toDegrees(orientationAngles[1]);
float roll = (float) Math.toDegrees(orientationAngles[2]);


// build and populate datablock
DataBlock dataBlock = dataStruct.createDataBlock();
dataBlock.setDoubleValue(0, sampleTime);
dataBlock.setFloatValue(1, (float) azimuth);
dataBlock.setFloatValue(2, (float) pitch);
dataBlock.setFloatValue(3, (float) roll);

// TODO since this sensor is high rate, we could package several records in a single event
// update latest record and send event
latestRecord = dataBlock;
latestRecordTime = System.currentTimeMillis();
eventHandler.publish(new DataEvent(latestRecordTime, this, dataBlock));
}
}
}
Loading