Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class center {
- public static void main(String[] args) {
- System.out.println("--- Hard Iron ---------------------------------------------------------");
- printSensorxyz(sensor.getSensor_x(), sensor.getSensor_y(), sensor.getSensor_z());
- printOffsetxyz(hardiron.getOffset_x(100, 0), hardiron.getOffset_y(100, 0), hardiron.getOffset_z(100, 0));
- printHardCorrectedxyz(
- hardiron.getHardCorrected_x(sensor.getSensor_x(), hardiron.getOffset_x(100, 0)),
- hardiron.getHardCorrected_y(sensor.getSensor_y(), hardiron.getOffset_y(100, 0)),
- hardiron.getHardCorrected_z(sensor.getSensor_z(), hardiron.getOffset_z(100, 0)));
- System.out.println("\n" + "--- Soft Iron ---------------------------------------------------------");
- printSensorxyz(sensor.getSensor_x(), sensor.getSensor_y(), sensor.getSensor_z());
- printOffsetxyz(hardiron.getOffset_x(100, 0), hardiron.getOffset_y(100, 0), hardiron.getOffset_z(100, 0));
- printAvgDeltaxyz(softiron.getAvg_delta_x(100, 0), softiron.getAvg_delta_y(100, 0), softiron.getAvg_delta_z(100, 0));
- printAvg(softiron.getAvg_delta(softiron.getAvg_delta_x(100, 0), softiron.getAvg_delta_y(100, 0), softiron.getAvg_delta_z(100, 0)));
- printScalexyz(
- softiron.getScale_x(softiron.getAvg_delta(softiron.getAvg_delta_x(100, 0), softiron.getAvg_delta_y(100, 0), softiron.getAvg_delta_z(100, 0)), softiron.getAvg_delta_x(100, 0)),
- softiron.getScale_y(softiron.getAvg_delta(softiron.getAvg_delta_x(100, 0), softiron.getAvg_delta_y(100, 0), softiron.getAvg_delta_z(100, 0)), softiron.getAvg_delta_y(100, 0)),
- softiron.getScale_z(softiron.getAvg_delta(softiron.getAvg_delta_x(100, 0), softiron.getAvg_delta_y(100, 0), softiron.getAvg_delta_z(100, 0)), softiron.getAvg_delta_z(100, 0)));
- printSoftCorrectedxyz(
- softiron.getSoftCorrected_x(sensor.getSensor_x(), hardiron.getOffset_x(100, 0), softiron.getScale_x(softiron.getAvg_delta(softiron.getAvg_delta_x(100, 0), softiron.getAvg_delta_y(100, 0), softiron.getAvg_delta_z(100, 0)), softiron.getAvg_delta_x(100, 0))),
- softiron.getSoftCorrected_y(sensor.getSensor_y(), hardiron.getOffset_y(100, 0), softiron.getScale_y(softiron.getAvg_delta(softiron.getAvg_delta_x(100, 0), softiron.getAvg_delta_y(100, 0), softiron.getAvg_delta_z(100, 0)), softiron.getAvg_delta_y(100, 0))),
- softiron.getSoftCorrected_z(sensor.getSensor_z(), hardiron.getOffset_z(100, 0), softiron.getScale_z(softiron.getAvg_delta(softiron.getAvg_delta_x(100, 0), softiron.getAvg_delta_y(100, 0), softiron.getAvg_delta_z(100, 0)), softiron.getAvg_delta_z(100, 0))));
- }
- private static void printSensorxyz(double sensor_x, double sensor_y, double sensor_z) {
- System.out.println("Sensor Info: [" + sensor_x + ", " + sensor_y + ", " + sensor_z + "]");
- }
- private static void printOffsetxyz(double offset_x, double offset_y, double offset_z) {
- System.out.println("Offset: [" + offset_x + ", " + offset_y + ", " + offset_z + "]");
- }
- private static void printHardCorrectedxyz(double hardCorrected_x, double hardCorrected_y, double hardCorrected_z) {
- System.out.println("Corrected: [" + hardCorrected_x + ", " + hardCorrected_y + ", " + hardCorrected_z + "]");
- }
- private static void printAvgDeltaxyz(double avg_delta_x, double avg_delta_y, double avg_delta_z) {
- System.out.println("Avarage_xyz: [" + avg_delta_x + ", " + avg_delta_y + ", " + avg_delta_z + "]");
- }
- private static void printAvg(double avg_delta) {
- System.out.println("Avarage_xyz: [" + avg_delta + "]");
- }
- private static void printScalexyz(double scale_x, double scale_y, double scale_z) {
- System.out.println("Scale_xyz: [" + scale_x + ", " + scale_y + ", " + scale_z + "]");
- }
- private static void printSoftCorrectedxyz(double softCorrected_x, double softCorrected_y, double softCorrected_z) {
- System.out.println("Corrected: [" + softCorrected_x + ", " + softCorrected_y + ", " + softCorrected_z + "]");
- }
- }
- //center ^^^
- import java.util.*;
- public class sensor extends center {
- static Random rnd = new Random();
- static double sensor_x = rnd.nextDouble()*1000;
- static double sensor_y = rnd.nextDouble()*1000;
- static double sensor_z = rnd.nextDouble()*1000;
- public sensor(double sensor_x, double sensor_y, double sensor_z) {
- this.sensor_x = sensor_x;
- this.sensor_y = sensor_y;
- this.sensor_z = sensor_z;
- }
- public static double getSensor_x() {
- return sensor_x;
- }
- public void setSensor_x(double sensor_x) {
- this.sensor_x = sensor_x;
- }
- public static double getSensor_y() {
- return sensor_y;
- }
- public void setSensor_y(double sensor_y) {
- this.sensor_y = sensor_y;
- }
- public static double getSensor_z() {
- return sensor_z;
- }
- public void setSensor_z(double sensor_z) {
- this.sensor_z = sensor_z;
- }
- }
- //sensor ^^^
- public class hardiron {
- static double offset_x;
- static double offset_y;
- static double offset_z;
- static double hardCorrected_x;
- static double hardCorrected_y;
- static double hardCorrected_z;
- public hardiron(double offset_x, double offset_y, double offset_z) {
- this.offset_x = offset_x;
- this.offset_y = offset_y;
- this.offset_z = offset_z;
- }
- public hardiron() {}
- public static double getOffset_x(double max_x, double min_x) {
- double offset_x = (max_x + min_x) / 2;
- return offset_x;
- }
- public static double getOffset_y(double max_y, double min_y) {
- double offset_y = (max_y + min_y) / 2;
- return offset_y;
- }
- public static double getOffset_z(double max_z, double min_z) {
- double offset_z = (max_z + min_z) / 2;
- return offset_z;
- }
- public static double getHardCorrected_x(double sensor_x, double offset_x) {
- hardCorrected_x = sensor_x - offset_x;
- return hardCorrected_x;
- }
- public static double getHardCorrected_y(double sensor_y, double offset_y) {
- hardCorrected_y = sensor_y - offset_y;
- return hardCorrected_y;
- }
- public static double getHardCorrected_z(double sensor_z, double offset_z) {
- hardCorrected_z = sensor_z - offset_z;
- return hardCorrected_z;
- }
- }
- //hardiron ^^^
- public class softiron {
- static double offset_x;
- static double offset_y;
- static double offset_z;
- static double avg_delta_x;
- static double avg_delta_y;
- static double avg_delta_z;
- static double avg_delta;
- static double scale_x;
- static double scale_y;
- static double scale_z;
- static double softCorrected_x;
- static double softCorrected_y;
- static double softCorrected_z;
- public softiron(double avg_delta_x, double avg_delta_y, double avg_delta_z,
- double scale_x, double scale_y, double scale_z,
- double offset_x, double offset_y, double offset_z) {
- this.avg_delta_x = avg_delta_x;
- this.avg_delta_y = avg_delta_y;
- this.avg_delta_z = avg_delta_z;
- this.scale_x = scale_x;
- this.scale_y = scale_y;
- this.scale_z = scale_z;
- this.offset_x = offset_x;
- this.offset_y = offset_y;
- this.offset_z = offset_z;
- }
- public softiron() {}
- public static double getOffset_x(double max_x, double min_x) {
- double offset_x = (max_x + min_x) / 2;
- return offset_x;
- }
- public static double getOffset_y(double max_y, double min_y) {
- double offset_y = (max_y + min_y) / 2;
- return offset_y;
- }
- public static double getOffset_z(double max_z, double min_z) {
- double offset_z = (max_z + min_z) / 2;
- return offset_z;
- }
- public static double getAvg_delta_x(double max_x, double min_x) {
- double avg_delta_x = (max_x - min_x) / 2;
- return avg_delta_x;
- }
- public static double getAvg_delta_y(double max_y, double min_y) {
- double avg_delta_y = (max_y - min_y) / 2;
- return avg_delta_y;
- }
- public static double getAvg_delta_z(double max_z, double min_z) {
- double avg_delta_z = (max_z - min_z) / 2;
- return avg_delta_z;
- }
- public static double getAvg_delta(double avg_delta_x, double avg_delta_y, double avg_delta_z) {
- double avg_delta = (avg_delta_x + avg_delta_y + avg_delta_z) / 3;
- return avg_delta;
- }
- public static double getScale_x(double avg_delta, double avg_delta_x) {
- double scale_x = avg_delta / avg_delta_x;
- return scale_x;
- }
- public static double getScale_y(double avg_delta, double avg_delta_y) {
- double scale_y = avg_delta / avg_delta_y;
- return scale_y;
- }
- public static double getScale_z(double avg_delta, double avg_delta_z) {
- double scale_z = avg_delta / avg_delta_z;
- return scale_z;
- }
- public static double getSoftCorrected_x(double sensor_x, double offset_x, double scale_x) {
- double softCorrected_x = (sensor_x - offset_x) * scale_x;
- return softCorrected_x;
- }
- public static double getSoftCorrected_y(double sensor_y, double offset_y, double scale_y) {
- double softCorrected_y = (sensor_y - offset_y) * scale_y;
- return softCorrected_y;
- }
- public static double getSoftCorrected_z(double sensor_z, double offset_z, double scale_z) {
- double softCorrected_z = (sensor_z - offset_z) * scale_z;
- return softCorrected_z;
- }
- }
- //softiron ^^^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement