Browse Source

robot netbeans

efe
Efe Aydın 5 years ago
parent
commit
2a8d847872
3 changed files with 72 additions and 76 deletions
  1. +10
    -6
      Ev3/main.py
  2. +4
    -4
      master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.form
  3. +58
    -66
      master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java

+ 10
- 6
Ev3/main.py View File

@ -65,7 +65,7 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
if recieved == 's':
stop()
elif recieved == 'm':
move(500)
move(200)
elif recieved == 'i':
data = {
"battery_voltage":power.measured_volts,
@ -80,12 +80,16 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
cam.run_timed(time_sp=100, speed_sp=-750)
elif recieved == 'f':
stop()
motor1.run_timed(time_sp=500, speed_sp=500)
motor2.run_timed(time_sp=500, speed_sp=500)
motor1.run_forever(speed_sp=400)
motor2.run_forever(speed_sp=400)
elif recieved == 'b':
stop()
motor1.run_timed(time_sp=500, speed_sp=-500)
motor2.run_timed(time_sp=500, speed_sp=-500)
motor1.run_forever(speed_sp=-400)
motor2.run_forever(speed_sp=-400)
elif recieved == 'l':
motor1.run_forever(speed_sp=400)
elif recieved == 'r':
motor2.run_forever(speed_sp=400)
except BrokenPipeError:
print("[INFO]: Client disconnected")
@ -93,4 +97,4 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
break
except KeyboardInterrupt:
stop()
s.close()
s.close()

+ 4
- 4
master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.form View File

@ -364,9 +364,9 @@
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="left_button" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="64" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="70" max="-2" attributes="0"/>
<Component id="right_button" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="398" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="393" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
@ -404,12 +404,12 @@
<Component id="ai_checkbox" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="121" max="-2" attributes="0"/>
<Component id="forward_button" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="right_button" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="left_button" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="7" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="13" max="-2" attributes="0"/>
<Component id="back_button" min="-2" max="-2" attributes="0"/>
</Group>
</Group>


+ 58
- 66
master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java View File

@ -383,9 +383,9 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
.addGap(453, 453, 453))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(left_button)
.addGap(64, 64, 64)
.addGap(70, 70, 70)
.addComponent(right_button)
.addGap(398, 398, 398))))
.addGap(393, 393, 393))))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -415,11 +415,11 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
.addComponent(ai_checkbox)
.addGap(121, 121, 121)
.addComponent(forward_button)
.addGap(10, 10, 10)
.addGap(4, 4, 4)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(right_button)
.addComponent(left_button))
.addGap(7, 7, 7)
.addGap(13, 13, 13)
.addComponent(back_button)))
.addContainerGap(30, Short.MAX_VALUE))
);
@ -668,77 +668,69 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
}//GEN-LAST:event_cam_sliderStateChanged
private void forward_buttonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_forward_buttonMousePressed
moverThread = new Thread(() -> {
try {
while (true) {
out.writeUTF("f");
Thread.sleep(500);
}
} catch(Exception ex){
System.out.println(ex.toString());
}
});
moverThread.start();
try {
out.writeUTF("f");
} catch(Exception ex){
System.out.println(ex.toString());
}
}//GEN-LAST:event_forward_buttonMousePressed
private void forward_buttonMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_forward_buttonMouseReleased
moverThread.stop();
try {
out.writeUTF("s");
} catch(Exception ex){
System.out.println(ex.toString());
}
}//GEN-LAST:event_forward_buttonMouseReleased
private void right_buttonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_right_buttonMousePressed
moverThread = new Thread(() -> {
try {
while (true) {
out.writeUTF("r");
Thread.sleep(500);
}
} catch(Exception ex){
System.out.println(ex.toString());
}
});
moverThread.start();
}//GEN-LAST:event_right_buttonMousePressed
private void right_buttonMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_right_buttonMouseReleased
moverThread.stop();
}//GEN-LAST:event_right_buttonMouseReleased
private void back_buttonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_back_buttonMousePressed
moverThread = new Thread(() -> {
try {
while (true) {
out.writeUTF("b");
Thread.sleep(500);
}
} catch(Exception ex){
System.out.println(ex.toString());
}
});
moverThread.start();
try {
out.writeUTF("b");
} catch(Exception ex){
System.out.println(ex.toString());
}
}//GEN-LAST:event_back_buttonMousePressed
private void back_buttonMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_back_buttonMouseReleased
moverThread.stop();
try {
out.writeUTF("s");
} catch(Exception ex){
System.out.println(ex.toString());
}
}//GEN-LAST:event_back_buttonMouseReleased
private void left_buttonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_left_buttonMousePressed
moverThread = new Thread(() -> {
try {
while (true) {
out.writeUTF("l");
Thread.sleep(500);
}
} catch(Exception ex){
System.out.println(ex.toString());
}
});
moverThread.start();
try {
out.writeUTF("r");
} catch(Exception ex){
System.out.println(ex.toString());
}
}//GEN-LAST:event_left_buttonMousePressed
private void left_buttonMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_left_buttonMouseReleased
moverThread.stop();
try {
out.writeUTF("s");
} catch(Exception ex){
System.out.println(ex.toString());
}
}//GEN-LAST:event_left_buttonMouseReleased
private void right_buttonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_right_buttonMousePressed
try {
out.writeUTF("l");
} catch(Exception ex){
System.out.println(ex.toString());
}
}//GEN-LAST:event_right_buttonMousePressed
private void right_buttonMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_right_buttonMouseReleased
try {
out.writeUTF("s");
} catch(Exception ex){
System.out.println(ex.toString());
}
}//GEN-LAST:event_right_buttonMouseReleased
/**
* @param args the command line arguments
*/
@ -880,7 +872,7 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
graph.setStroke(new BasicStroke(10));
graph.setFont(new Font("Arial Black", Font.BOLD, 20));
for (int i = 0; i < detection_scores.length(); i++) {
if (detection_scores.getDouble(i) < 0.4) {
if (detection_scores.getDouble(i) < 0.3) {
continue;
}
@ -1025,13 +1017,13 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
if(running!=null){
try{
server.close();
client.close();
running.stop();
}catch(IOException ex){
System.out.println("IO Exception occured");
}catch(Exception ex){
System.out.println(ex.toString());
}
client.close();
running.stop();
}catch(IOException ex){
System.out.println("IO Exception occured");
}catch(Exception ex){
System.out.println(ex.toString());
}
}
switch (jTabbedPane1.getSelectedIndex()) {
case 0:


Loading…
Cancel
Save