Skip to content

Commit

Permalink
First working commit ready to be released
Browse files Browse the repository at this point in the history
  • Loading branch information
KlemenDEV committed Aug 20, 2015
1 parent d8843ff commit 18744b6
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 20 deletions.
5 changes: 3 additions & 2 deletions src/com/sourcegasm/riftvision/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ public static void main(String[] args) throws IOException {
joystickSensors.startReceiving();
mainController.droneController = droneController;
mainController.oculusSensors = oculusSensors;
mainController.joyStickSensors = joystickSensors;

RenderRiftWindow frame = new RenderRiftWindow(mainController);

//frame.showFrame();
frame.showFrame();

new RenderManager(droneController, frame);
}
}
112 changes: 97 additions & 15 deletions src/com/sourcegasm/riftvision/control/MainController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sourcegasm.riftvision.control;

import com.sourcegasm.riftvision.helper.ControlModes;
import com.sourcegasm.riftvision.sensors.JoyStickSensors;
import com.sourcegasm.riftvision.sensors.OculusSensors;

import java.io.IOException;
Expand All @@ -9,7 +10,10 @@
* Created by klemen on 19.8.2015. ^selfish
*/
public class MainController {

public OculusSensors oculusSensors;
public JoyStickSensors joyStickSensors;

private Thread thread;
public DroneController droneController;
private HeightController heightController = new HeightController();
Expand All @@ -19,25 +23,13 @@ public class MainController {

public void startController() {

/*heightController = new HeightController();
yawController.setZero(droneController, oculusSensors);*/

heightController = new HeightController();
yawController.setZero(droneController, oculusSensors);
contiune = true;
thread = new Thread(new Runnable() {
@Override
public void run() {
while (contiune) {
oculusOnlyControllerLiteration();
}
}
});
thread.start();

/*switch (controlMode) {
switch (controlMode) {
case OculusOnly:

contiune = true;
thread = new Thread(new Runnable() {
@Override
public void run() {
Expand All @@ -49,13 +41,103 @@ public void run() {
thread.start();

break;

case OculusYaw:

contiune = true;
thread = new Thread(new Runnable() {
@Override
public void run() {
while (contiune) {
oculusYawControllerLiteration();
}
}
});
thread.start();

break;

case OculusYawPitch:

contiune = true;
thread = new Thread(new Runnable() {
@Override
public void run() {
while (contiune) {
oculusYawPitchControllerLiteration();
}
}
});
thread.start();

break;

case JoystickOnly:

contiune = true;
thread = new Thread(new Runnable() {
@Override
public void run() {
while (contiune) {
joysitckOnlyControllerLiteration();
}
}
});
thread.start();

break;
}*/
}
}

private void joysitckOnlyControllerLiteration() {

try {
droneController.getDrone().move((float)joyStickSensors.getRawRool(), (float)joyStickSensors.getRawPitch(), (float)joyStickSensors.getRawHeight(), (float)joyStickSensors.getRawYaw());
} catch (IOException e) {
e.printStackTrace();
}

try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}

}

private void oculusYawControllerLiteration() {

double yaw = yawController.getYawMove(droneController, oculusSensors);
try {
droneController.getDrone().move((float)joyStickSensors.getRawRool(), (float)joyStickSensors.getRawPitch(), (float)joyStickSensors.getRawHeight(), (float)yaw);
} catch (IOException e) {
e.printStackTrace();
}

try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

private void oculusYawPitchControllerLiteration() {

float pitch = (float) (ExpoController.getExpo(oculusSensors.getSmoothedPitch()) / 90.0);
double yaw = yawController.getYawMove(droneController, oculusSensors);
try {
droneController.getDrone().move((float)joyStickSensors.getRawRool(), (float)pitch, (float)joyStickSensors.getRawHeight(), (float)yaw);
} catch (IOException e) {
e.printStackTrace();
}

try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

private void oculusOnlyControllerLiteration() {

float roll = (float) (ExpoController.getExpo(oculusSensors.getSmoothedRool()) / 90.0);
Expand Down
8 changes: 6 additions & 2 deletions src/com/sourcegasm/riftvision/render/RenderManager.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package com.sourcegasm.riftvision.render;

import java.awt.image.BufferedImage;
import java.awt.image.RescaleOp;

import com.codeminders.ardrone.util.BufferedImageVideoListener;
import com.sourcegasm.riftvision.control.DroneController;

public class RenderManager {
public RenderManager(DroneController controller, final RenderRiftWindow frame) {
/*controller.getDrone().addImageListener(new BufferedImageVideoListener() {
controller.getDrone().addImageListener(new BufferedImageVideoListener() {
@Override
public void imageReceived(BufferedImage image) {
RescaleOp rescaleOp = new RescaleOp(1.2f, 15, null);
rescaleOp.filter(image, image);
frame.updateFrame(image, controller.getNavData());
}
});*/
});
}

}
6 changes: 5 additions & 1 deletion src/com/sourcegasm/riftvision/sensors/JoyStickSensors.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void run() {
rawPitch = (float) (ExpoController.getJoyStickExpo(Integer.parseInt(mami_array[3].trim())));
rawRoll = (float) (ExpoController.getJoyStickExpo(Integer.parseInt(mami_array[2].trim())));
rawYaw = (float) (ExpoController.getJoyStickExpo((Integer.parseInt(mami_array[0].trim()))));
rawHeight = (float) (ExpoController.getJoyStickExpo((Integer.parseInt(mami_array[1].trim()))));
rawHeight = (float) ((Integer.parseInt(mami_array[1].trim()))) / -300.0f;
}

}
Expand Down Expand Up @@ -133,5 +133,9 @@ public double getRawPitch() {
public double getRawYaw() {
return rawYaw;
}

public double getRawHeight(){
return rawHeight;
}

}

0 comments on commit 18744b6

Please sign in to comment.