Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.
/ libepn Public archive

A Java library for easily working with positions and rotations in 3D space

License

Notifications You must be signed in to change notification settings

ewpratten/libepn

Repository files navigation

LibEPN Logo

Documentation Build library

LibEPN (Easy Pose Notation) is a Java library designed to provide an easy-to-use interface for 3D position and orientation. The library is heavily dependant on Quaternions, and makes use of the following dependencies:

I use this library in various personal and school projects relating to pose estimation, robotics, and computer vision.

Using in your project

Step 1. Add the RetryLife maven server to your build.gradle file:

repositories {
    maven { 
        name 'retrylife-release'
        url 'https://release.maven.retrylife.ca/' 
    }
}

Step 2. Add this library as a dependency:

dependencies {
    implementation 'ca.retrylife:easy-pose-notation:1.+'
    implementation 'ca.retrylife:easy-pose-notation:1.+:sources'
    implementation 'ca.retrylife:easy-pose-notation:1.+:javadoc'
}

Coordinates

The following should be noted when working with coordinates:

  • alpha, beta, and gamma refer respectively to the Z, X and Y axes of rotation.
  • The coordinate system assumes that:
    • If you are at (x: 0, y: 1, z: 0) facing (0,0,0), the Y axis will be coming "towards" you, X will be increasing to your left, and Z will be increasing towards the sky.
  • All angles will increase to the left around any axis assuming you are in line with the axis, looking at (0,0,0)
  • All coordinate and angle systems follow that of Google's device orientation specification, and the world frame coordinate system used by MIT's Drake.

Orientation graphic

Basic usage

The following is a basic usage example. See the JavaDoc for full API reference.

// Create a pose at (10,0,0) rotated around the Z axis to the left by 45 degrees
Pose p = new Pose(
    new SimpleMatrix(new double[][]{{10,0,0}}), 
    QuaternionUtil.quaternionFromEulerAngles(Math.toRadians(45), 0, 0)
);

// Print the pose's quaternion
System.out.println(p.getRotation());

// Print the pose's rotation as euler angles
System.out.println(p.getEulerRotation());

// Print the pose's position
System.out.println(p.getPosition());

// Print the pose's "surface normal
System.out.println(p.getNormal());

EPN4FRC

This library also contains a sub-library called EPN4FRC. This is a small binding between LibEPN and WPILib's Pose2d coordinate system for the FIRST Robotics Competition. EPN4FRC in-source documentation can be found here.

Credits

This library was heavily supported by the following sources: