diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5241a72 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.class \ No newline at end of file diff --git a/CopterController/TCPexample/Client.class b/CopterController/TCPexample/Client.class deleted file mode 100644 index 21fd188..0000000 Binary files a/CopterController/TCPexample/Client.class and /dev/null differ diff --git a/CopterController/TCPexample/Server.class b/CopterController/TCPexample/Server.class deleted file mode 100644 index f3ef10a..0000000 Binary files a/CopterController/TCPexample/Server.class and /dev/null differ diff --git a/GroundStation/v1/GroundStation.class b/GroundStation/v1/GroundStation.class deleted file mode 100644 index eee6072..0000000 Binary files a/GroundStation/v1/GroundStation.class and /dev/null differ diff --git a/GroundStation/v1/SmartScroller$1.class b/GroundStation/v1/SmartScroller$1.class deleted file mode 100644 index dfed3b3..0000000 Binary files a/GroundStation/v1/SmartScroller$1.class and /dev/null differ diff --git a/GroundStation/v1/SmartScroller.class b/GroundStation/v1/SmartScroller.class deleted file mode 100644 index 95926ce..0000000 Binary files a/GroundStation/v1/SmartScroller.class and /dev/null differ diff --git a/GroundStation/v2/ConnectionPanel.java b/GroundStation/v2/ConnectionPanel.java index 0b04c8f..b5c643b 100644 --- a/GroundStation/v2/ConnectionPanel.java +++ b/GroundStation/v2/ConnectionPanel.java @@ -137,6 +137,10 @@ class ConnectionPanel extends JPanel implements ActionListener { for( int i = 0; i < contentOut.controlValues.length; i++ ) out.print( "C" + i + "_" + contentOut.controlValues[i] + " " ); } + if( contentOut.orientation ) { + for( int i = 0; i < contentOut.orientValues.length; i++ ) + out.print( "O" + i + "_" + contentOut.orientValues[i] + " " ); + } out.println(); } @@ -148,18 +152,43 @@ class ConnectionPanel extends JPanel implements ActionListener { if( in.ready() ) { String messageIn = in.readLine(); Scanner temp = new Scanner( messageIn ); + boolean motorsEnabled = false; + + contentIn.motorTesting = false; + contentIn.controls = false; + contentIn.orientation = false; + while( temp.hasNext() ) { String next = temp.next(); - if( next.indexOf( "H" ) == 0 ) System.out.print( "\nH" ); - System.out.print( next ); - if( next.indexOf( "M" ) > 0 ) { - Scanner motorScan = new Scanner( next ); - + if( next.indexOf( "H" ) == 0 ) { + System.out.print( "\nH " ); + } + else if( next.indexOf( "E" ) == 0 ) { + motorsEnabled = true; + System.out.print( "E " ); + } + else if( next.indexOf( "M" ) == 0 ) { + contentIn.motorTesting = true; + //int motorNum = Integer.parseInt( next.substring( 1 ) ); + //int motorVal = Integer.parseInt( next.substring( 3, next.length() ) ); + //contentIn.motorValues[ motorNum ] = motorVal; + System.out.print( "M " ); + } + else if( next.indexOf( "C" ) == 0 ) { + contentIn.controls = true; + //int controlNum = Integer.parseInt( next.substring( 1 ) ); + //int controlVal = Integer.parseInt( next.substring( 3, next.length() ) ); + //contentIn.controlValues[ controlNum ] = controlVal; + System.out.print( "C " ); + } + else if( next.indexOf( "O" ) == 0 ) { + contentIn.orientation = true; + System.out.print( "O " ); } } + contentIn.setMotorsEnabled( motorsEnabled ); + contentIn.fireActionPerformed( new ActionEvent(contentIn, ActionEvent.ACTION_PERFORMED, "" ) ); } - contentIn.orientation = true; - contentIn.fireActionPerformed( new ActionEvent(contentIn, ActionEvent.ACTION_PERFORMED, "" ) ); } catch( IOException ex ) {} } diff --git a/GroundStation/v2/Display3d.java b/GroundStation/v2/Display3d.java index e9f6dc9..8104dd3 100644 --- a/GroundStation/v2/Display3d.java +++ b/GroundStation/v2/Display3d.java @@ -10,7 +10,7 @@ class Display3d extends JPanel implements ActionListener, ChangeListener { private JSlider slider; private MessageContent source = new MessageContent(); - private Font normalFont = new Font( "Normal", Font.PLAIN, 15 ); + private Font normalFont = new Font( "Normal", Font.BOLD, 15 ); /** * no-args constructor @@ -60,12 +60,23 @@ class Display3d extends JPanel implements ActionListener, ChangeListener { g.setColor( Color.GREEN ); //g.drawLine( centerX, centerY, X, Y ); - g.setColor( Color.BLACK ); + g.setColor( Color.LIGHT_GRAY ); g.setFont( normalFont ); - g.drawString( "w = " + source.orientValues[ 0 ], 10, 35 ); - g.drawString( "x = " + source.orientValues[ 1 ], 10, 60 ); - g.drawString( "y = " + source.orientValues[ 2 ], 10, 85 ); - g.drawString( "z = " + source.orientValues[ 3 ], 10, 110 ); + + double w = source.orientValues[ 0 ]; + double x = source.orientValues[ 1 ]; + double y = source.orientValues[ 2 ]; + double z = source.orientValues[ 3 ]; + + g.drawString( "w = " + w, 11, 35 ); + g.drawString( "x = " + x, 15, 50 ); + g.drawString( "y = " + y, 15, 65 ); + g.drawString( "z = " + z, 15, 80 ); + + double[] gravity = { 2 * ( x*z - w*y ), 2 * ( w*x + y*z ), w*w - x*x - y*y + z*z }; + + g.drawString( "Pitch: " + Math.toRadians( Math.atan( x / Math.sqrt( y*y + z*z ) ) ), 15, 100 ); + g.drawString( "Roll: " + Math.toRadians( Math.atan( y / Math.sqrt( x*x + z*z ) ) ), 15, 115 ); } else { g.setColor( Color.RED ); diff --git a/GroundStation/v2/DisplayController.java b/GroundStation/v2/DisplayController.java new file mode 100644 index 0000000..a22d088 --- /dev/null +++ b/GroundStation/v2/DisplayController.java @@ -0,0 +1,26 @@ +import javax.swing.*; +import java.awt.event.*; + +class DisplayController.java extends JPanel implements ActionListener { + + private MessageContent source = new MessageContent(); + + public DisplayController() { + setBackground( Color.DARK_GRAY ); + setPerferredSize( new Dimension( 0, 100 ) ); + } + + public void paintComponent( Graphics g ) { + super.paintComponent( g ); + + g.setColor( Color.LIGHT_GRAY ); + + } + + /** + * + */ + public void actionPerformed( ActionEvent evt ) { + redraw(); + } +} \ No newline at end of file diff --git a/GroundStation/v2/EStopWindow.java b/GroundStation/v2/EStopWindow.java index 3dbf817..5b78cfe 100644 --- a/GroundStation/v2/EStopWindow.java +++ b/GroundStation/v2/EStopWindow.java @@ -20,7 +20,7 @@ class EStopWindow extends JFrame implements ActionListener { /** * */ - public EStopWindow() { + public EStopWindow( boolean visible) { super("Emergency Stop"); setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); setAlwaysOnTop( true ); @@ -33,7 +33,14 @@ class EStopWindow extends JFrame implements ActionListener { setEnabled( true ); pack(); - setVisible( true ); + setVisible( visible ); + } + + /** + * + */ + public EStopWindow() { + this( true ); } /** diff --git a/GroundStation/v2/GroundStation.java b/GroundStation/v2/GroundStation.java index 7d60718..5447c60 100644 --- a/GroundStation/v2/GroundStation.java +++ b/GroundStation/v2/GroundStation.java @@ -11,7 +11,7 @@ class GroundStation implements ActionListener { /** main window to hold everything */ private JFrame mainWindow; /** window to hold emergency stop button */ - private EStopWindow eStopWindow; + private EStopWindow eStopWindow = new EStopWindow( false ); /** connection options section of window */ private ConnectionPanel connectPanel; @@ -52,6 +52,8 @@ class GroundStation implements ActionListener { mainWindow.pack(); mainWindow.setVisible( true ); + + sendContent.orientation = true; } public void disableMotors() {