|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Need help with lego NXT lejos xbox controlling
I'm attempting to use an Xbox One wired controller on my MacBook Pro laptop, Im using Java with Eclipse that has lejos and LWJGL installed on it in order to control an NXT via my controller, like how we control our robots. I have a gamepad driver installed, it's called "XOne Controller" (link)https://github.com/FranticRain/Xone-OSX Also i have a little program to test the data from the joysticks and buttons of the controller
Code:
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Controller;
import org.lwjgl.input.Controllers;
public class Start extends Virtual_JoyStick
{
public static Controller control;
public static boolean Start;
public static void main(String[] args)
{
try
{
Controllers.create();
}
catch(LWJGLException e)
{
e.printStackTrace();
}
Controllers.poll();
for(int i=0;i<Controllers.getControllerCount();i++)
{
control=Controllers.getController(i);
System.out.print(control.getName());
}
control=Controllers.getController(0);
for(int i=0; i < control.getAxisCount(); i++)
{
System.out.print(i+ ": "+ control.getAxisName(i));
//System.out.print("c");
control.setDeadZone(i, (float) 0.30);
}
for(int i=0; i < control.getButtonCount(); i++)
{
System.out.print(i+ ": "+ control.getButtonName(i));
}
while(true)
{
control.poll();
//Start=control.isButtonPressed(7);
/**System.out.print(control.getAxisValue(0));
System.out.print(" ");
System.out.print(control.getAxisValue(1));
System.out.print(" ");
System.out.print(control.getAxisValue(2));
System.out.print(" ");
System.out.print(control.getAxisValue(3));
System.out.print(" ");
System.out.print(control.getAxisValue(4));
System.out.print(" ");
System.out.print(control.getAxisValue(5));
System.out.println(); */
Virtual_JoyStick joy = new Virtual_JoyStick();
joy.repaint();
}
}
}
|
|
#2
|
||||
|
||||
|
Re: Need help with lego NXT lejos xbox controlling
Quote:
Code:
axisZero = control.getAxisValue(0); EDIT: what do the last 2 lines of the while loop do? it seems like that might not be something you want to do for every iteration of the loop, but I could be wrong. EDIT (again): I see that the constructor called in the lines I referenced above is the constructor for the parent class. Is the start class the class that you are using to run the program in the JVM, or is it a class that you intend to use to create start objects? I assumed the former since you omitted a constructor but included a main() method, but it occurred to me that you might have intended the latter. Last edited by PAR_WIG1350 : 25-05-2015 at 17:52. |
|
#3
|
|||
|
|||
|
Re: Need help with lego NXT lejos xbox controlling
The easiest way to set up communication between the computer and the robot is to use the communication classes included in the leJOS PC library.
The computer side project (the one that reads from the controller) should be set up according to these instructions. Then you can use DataOutputStream (on the computer) and DataInputStream (on the robot) to send numbers over bluetooth. I would recommend using USB for testing as it is more reliable and faster to connect and the APIs are nearly identical. These instructions might help with setting up communications. I also have some more complicated communication code that you can look at if you want. This provides a way for bidirectional communication that is sort of similar to I2C. There are a few intermittent threading bugs, but it might give you some idea of how to connect the computer and the robot. Computer Code Robot Code Feel free to ask any other questions you have about the specifics of getting your leJOS working. |
|
#4
|
||||
|
||||
|
Re: Need help with lego NXT lejos xbox controlling
This might help. I have a little bit of experience using LeJos with an NXT with Bluetooth and Joystick control so I may be of some assistance.
Last edited by Jalerre : 25-05-2015 at 18:13. |
|
#5
|
||||
|
||||
|
Re: Need help with lego NXT lejos xbox controlling
Ikr, i've search the web for like 3 weeks al the links are clicked on and i still couldnt find anything
|
|
#6
|
||||
|
||||
|
Re: Need help with lego NXT lejos xbox controlling
I need some help i keep getting this error and i can't figure out why
Code:
Native Library bluecove not available Failed to open connection to the NXT Last edited by TheModMaster8 : 27-05-2015 at 23:46. |
|
#7
|
||||
|
||||
|
Re: Need help with lego NXT lejos xbox controlling
Hopefully the last time i need help. everything runs fine but when it connects this is the error i get
Code:
Loading: net.java.games.input.OSXEnvironmentPlugin Using joystick: Xbox One Controller Found NXT: Tim fork 0016530A7EAE Connected to NXT: Tim fork@0016530A7EAE Connection to NXT timed out. Any clue as to what is going on ? |
|
#8
|
|||
|
|||
|
Re: Need help with lego NXT lejos xbox controlling
Quote:
You have to start the program on the robot before starting the program on the computer. I might add the ability to cleanly connect, disconnect and reconnect (like the FRC system), but it doesn't have that capability at the moment. |
|
#9
|
||||
|
||||
|
Quote:
Code:
Loading: net.java.games.input.OSXEnvironmentPlugin Using joystick: Xbox One Controller dyld: lazy symbol binding failed: Symbol not found: _IOBluetoothLocalDeviceReadSupportedFeatures Referenced from: /private/var/folders/_2/xj9xgcd50xd820c_rjmpltwc0000gn/T/bluecove_BradenShepard_0/libbluecove.jnilib Expected in: /System/Library/Frameworks/IOBluetooth.framework/Versions/A/IOBluetooth dyld: Symbol not found: _IOBluetoothLocalDeviceReadSupportedFeatures Referenced from: /private/var/folders/_2/xj9xgcd50xd820c_rjmpltwc0000gn/T/bluecove_BradenShepard_0/libbluecove.jnilib Expected in: /System/Library/Frameworks/IOBluetooth.framework/Versions/A/IOBluetooth |
|
#10
|
|||
|
|||
|
Re: Need help with lego NXT lejos xbox controlling
Quote:
It looks like this is a bug in BlueCove (the bluetooth library) caused by some changes in Mac OS 10.8 and newer. What are your OS and BlueCove versions? I don't much experience with Mac OS, so Googling might help more than I can. |
|
#11
|
||||
|
||||
|
Re: Need help with lego NXT lejos xbox controlling
Quote:
and im using lejos version: leJOS_NXJ_0.9.1beta-3 2 i can't find the versoin of bluecove. Solved it, the usb that is i needed to switch this little line of code Code:
public Robot() {
// RConsole.open();
// pilot.steer(90, false);
// pilot.steer(140, false);
// pilot.steer(180, false);
// pilot.steer(0, false);
final NXTConnection connection = Bluetooth.waitForConnection();
communication = new CommunicationSlave(connection.openInputStream(), connection.openOutputStream(), new CommunicationHandler() {
Code:
public Robot() {
// RConsole.open();
// pilot.steer(90, false);
// pilot.steer(140, false);
// pilot.steer(180, false);
// pilot.steer(0, false);
final NXTConnection connection = USB.waitForConnection();
communication = new CommunicationSlave(connection.openInputStream(), connection.openOutputStream(), new CommunicationHandler() {
Last edited by TheModMaster8 : 29-05-2015 at 17:14. |
|
#12
|
||||
|
||||
|
Re: Need help with lego NXT lejos xbox controlling
Quote:
ex. int i = 0 if(control.getAxisValue(1) > 0.35){ i = i +5; Motor.BC.setSpeed(i) } else i=0; how would i add this to the code? |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|