Go to Post Gracious Professionalism at its finest - Competing like CRAZY on the field, then working together like professionals off the field to make these events the best they can be for everyone involved. - Stu Bloom [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 09-01-2017, 06:35
ProfessorAlekM ProfessorAlekM is offline
Registered User
FRC #6190
 
Join Date: Jan 2016
Location: Canton, Michigan
Posts: 32
ProfessorAlekM has a little shameless behaviour in the past
Robot will not drive when using UDP in autonomous

Hello!

I've wrote UDP code to communicate with a beaglebone from the roboRIO, however when the I put on autonomous mode and the UDP is used none of the motors work, and when I change back to teleop I still can't control anything.

Here is the code:

Code:
public class Robot extends IterativeRobot {
	//Beaglebone Communications
    DatagramSocket serverSocket;
    byte[] receiveData;
    byte[] sendData;
Code for robot init
Code:
try {
			serverSocket = new DatagramSocket(9876);
		} catch (SocketException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	receiveData = new byte[1024];
        sendData = new byte[1024];
Code:
public void autonomousPeriodic() {
    	
    	//Receive Data
        DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
        try {
			serverSocket.receive(receivePacket);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        String sentence = new String( receivePacket.getData());
        System.out.println("RECEIVED: " + sentence);
        InetAddress IPAddress = receivePacket.getAddress();
        int port = receivePacket.getPort();

        //Return data
        String capitalizedSentence = sentence.toUpperCase();
        sendData = capitalizedSentence.getBytes();
        DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, port);
        try {
			serverSocket.send(sendPacket);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        
        switch (sentence) {
        	case "a":
        		myRobot.tankDrive(0.5, 0.5);
        	break;
        	
        	case "b":
        		myRobot.tankDrive(0,0);
        	break;
        }

        Timer.delay(0.005);

    }
Thanks for any help!
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:14.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi