EV3 to EV3 with bluetooth

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

EV3 to EV3 with bluetooth

Postby mindrenee » Tue Jun 24, 2014 6:31 pm

Hi everyone,

Did anybody got 2 EV3 bricks connected with bluetooth and got them send messages to each other? I want them to send each other their own position on the field. Are there any examples that I can use (with code)? I have no idea where I should start.

Thank you.
mindrenee
New User
 
Posts: 10
Joined: Tue Jun 24, 2014 6:23 pm

Re: EV3 to EV3 with bluetooth

Postby gloomyandy » Tue Jun 24, 2014 7:07 pm

How many EV3s do you want to link together? The most general way to do it is via a Bluetooth PAN (which is what we use to allow an EV3 to talk to a PC via Bluetooth). EV3 to EV3 via Bluetooth is a little tricky at the moment. It can be done but it is not possible without resorting to using Linux tools and modifying one of the EV3 startup scripts. Basically you have to modify one of the EV3s so that instead of being a Bluetooth PAN access point it is a PAN client. The following link has some of the details:
http://bluez.sourceforge.net/contrib/HOWTO-PAN
Once the client has connected you need to run the DHCP client on the network endpoint to obtain a network address. Once that is done the two EV3s are talking via TCP/IP and you can use the standard Java network classes to communicate between them. If none of this makes any sense then possible best not to try it at the moment.

If you only need to hook two EV3s together it may be possible to do so using the Bluetooth serial port interface (used to talk to an NXT), but I'm not sure if EV3 to EV3 is possible using that mechanism or not. Lawrie may be able to help with that...

Probably not the answer you wanted sorry! This is on my list to try and improve but so far there have not been many people with more then one EV3!

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4173
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: EV3 to EV3 with bluetooth

Postby lawrie » Tue Jun 24, 2014 8:31 pm

EV3 to EV3 over Bluetooth serial should work, but the Bluetooth serial code has a lot of diagnostics in it at the moment and has not been tested much. If you look at the RemoteNXT project in the Git repository, NXTConnect and NXTReceive should work EV3 to EV3. Basically the leJOS on the EV3 works the same as leJOS on the NXT for this, so these programs should work EV3 to NXT, NXT to EV3, or EV3 to EV3.
lawrie
leJOS Team Member
 
Posts: 929
Joined: Mon Feb 05, 2007 1:27 pm

Re: EV3 to EV3 with bluetooth

Postby robusto » Mon Aug 18, 2014 1:55 am

lawrie wrote:EV3 to EV3 over Bluetooth serial should work, but the Bluetooth serial code has a lot of diagnostics in it at the moment and has not been tested much. If you look at the RemoteNXT project in the Git repository, NXTConnect and NXTReceive should work EV3 to EV3. Basically the leJOS on the EV3 works the same as leJOS on the NXT for this, so these programs should work EV3 to NXT, NXT to EV3, or EV3 to EV3.


I have tried ev3 to ev3 and ev3 to nxt via bluetooth. The RemoteNxt code will work with the latter not the former.

Can you explain how to start a motor on the remote NXT?

The lejos NXT code- e.g. nxt.A.forward() - does not work because the EV3 RemoteNXT class has no such method.

I suspect it can be done with getNXTCommand().setOutputState() but I am not sure of the details .
And how does RemoteNXTMotorPort work?

As always, please excuse these questions if they show lamentable ignorance.

Rob
robusto
Novice
 
Posts: 28
Joined: Sun May 04, 2014 11:14 am

Re: EV3 to EV3 with bluetooth

Postby lawrie » Wed Aug 20, 2014 7:36 am

Hi Rob,

I think NXTConnect and NXTReceive work EV3 to EV3 as I said, but remote control of sensors and motors will only work if there is a NXT LEGO Communications Protocol (LCP) responder running on the EV3. The NXT menu program runs this but the EV3 menu does not. You can run the LCPRespond program from the RemoteNXT project on the target EV3, but the EV3 LCP responder is very incomplete, so I am not sure what will work.

To access motors on a remote NXT or a remote EV3 running LCPRespond, you need to do something like:

NXTMotor m = new NXTMotor(remoteNXT.getPort("A"));
m.forward();
Delay.msDelay(1000);
m.stop();

NXTMotor is renamed UnregulatedMotor in the latest Git source.

I will add an example that does this to the RemoteNXT project.

This will only support simple unregulated motor methods. Those methods that require the motor regulator (like rotate) are not currently supported.

Note that the LEGO communications protocol for the EV3 is more complex than the NXT version and really requires all the Lego software to be running to support it, so leJOS does not support it. So you won't be able to access the motors and sensors of a remote EV3 running the LEGO software.

I will look into running RemoteRequestEV3 over a Bluetooth serial connection, as that should allow access to remote access to regulated motors. RemoteRequestEV3 is in the latest Git source and is intended to support remote access from Android devices. It currently only works over TCP (WiFi, Bluetooth PAN) connections, but could be made to work over Bluetooth Serial without too much work.

I am afraid that all these options for communications protocols at the network and application levels makes all this rather complex.

Lawrie
lawrie
leJOS Team Member
 
Posts: 929
Joined: Mon Feb 05, 2007 1:27 pm

Re: EV3 to EV3 with bluetooth

Postby robusto » Wed Aug 20, 2014 7:44 am

Thanks Lawrie for your help.

I have two ev3s and 1 nxt and am just trying to find a good solution for a project that will require up to 6 motors.
robusto
Novice
 
Posts: 28
Joined: Sun May 04, 2014 11:14 am

Re: EV3 to EV3 with bluetooth

Postby robusto » Fri Aug 22, 2014 12:58 am

NXTMotor m = new NXTMotor(remoteNXT.getPort("A"));
m.forward();
Delay.msDelay(1000);
m.stop();

Hi Lawrie,

I can't get this code to work. There is a bluetooth connection between the ev3 and the nxt (because I can get the nxt to play a tone) but the motor does not start.

As you mentioned, a number of diagnostics appear with the RemoteNXT call (including confirmation of a connection to the nxt) and the last one is something like "sending headers".(there are a few of these and I can provide more detail if that is important which I doubt).
After that, nothing happens.

[*]Any clue why this is failing? Any tests I can do?
[*]Should I try running the same code from the PC - i.e PC to nxt via bluetooth, and see if that works?
[*]I am really resisting using two ev3s and wifi , but if I do, will I need a second wifi adapter?


Thanks in advance.

Rob
robusto
Novice
 
Posts: 28
Joined: Sun May 04, 2014 11:14 am

Re: EV3 to EV3 with bluetooth

Postby lawrie » Sat Aug 23, 2014 3:03 pm

Try:

m.setPower(100);

I think the power might be preset to zero.
lawrie
leJOS Team Member
 
Posts: 929
Joined: Mon Feb 05, 2007 1:27 pm

Re: EV3 to EV3 with bluetooth

Postby robusto » Mon Aug 25, 2014 11:54 pm

NXTMotor m = new NXTMotor(remoteNXT.getPort("A"));
m.setPower(100);
m.forward();
Delay.msDelay(1000);
m.stop();

Yes, that's the answer.
So with one ev3 and one nxt you can you run up to 7 motors (ev3 or nxt) with a bluetooth connection between the ev3 and the nxt.
robusto
Novice
 
Posts: 28
Joined: Sun May 04, 2014 11:14 am

Re: EV3 to EV3 with bluetooth

Postby azteks » Fri Nov 14, 2014 4:38 pm

Ok so I have to run the LCPRespond program on one of my ev3's but what is the code i need on the other one to get them to connect? In your provide code a remoteNXT is needed but when i try to make one it doesn't work and gives errors. Can someone who has been able to communicate with 2 ev3's please explain how exactly i must accomplish this as i can't figure it out :(
azteks
New User
 
Posts: 4
Joined: Fri Nov 14, 2014 4:32 pm

Re: EV3 to EV3 with bluetooth

Postby gloomyandy » Fri Nov 14, 2014 4:51 pm

Hi,
if you read the posts above, it looks like at the moment you are very limited in talking EV3 to EV3 via Bluetooth. I don't think anyone has really tried this. To be honest at this stage I would simply use WiFi and forget about using Bluetooth unless you are happy hacking around at the Linux level.

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4173
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: EV3 to EV3 with bluetooth

Postby azteks » Fri Nov 14, 2014 6:21 pm

hmm, i thought i might have been possible because of what laurie said. The problem is dat it is for a lot of bricks and that would require us to buy a lot of wifi adapters. Before we do that could you explain me how exactly i should connect via wifi? Why is this so much easier... I also read that you have to have a specific brand and type of adapter, is this true?
azteks
New User
 
Posts: 4
Joined: Fri Nov 14, 2014 4:32 pm

Re: EV3 to EV3 with bluetooth

Postby gloomyandy » Fri Nov 14, 2014 6:35 pm

Perhaps you should take a step back a little and explain what it is you are trying to do. Have you used the leJOS remote API at all? What sort of communication do you want between your EV3s, how many are you going to use etc. A Wifi dongle can be purchased for around £7 from amazon:
http://www.amazon.co.uk/Edimax-EW-7811U ... words=wifi
Once you have that you can use Wifi between EV3s and between your EV3 and a PC. What sort of setup are you currently using to talk to the Ev3?
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4173
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: EV3 to EV3 with bluetooth

Postby azteks » Fri Nov 14, 2014 7:48 pm

Ok I will explain the situation, my university has bought around 30 ev3's to be used in class. In the course they need be used in a multi agent system (so the two robots working together on a task). The problem is that Lejos seems to be the best option to program them (the lego environment is to limited) but we ran in to communication problems. We also have nxt robots so we could pair 1 ev3 with 1 nxt (we do not have enough to give everybody 2 nxt robots). We already have bluetooth adapters so we thought this would be the best way to do it. To talk to the ev3's we use eclipse with the lejos ev3 plugin (this means both windows and mac pc's ). I think this explains the situation, as for the api I have looked at it quite a lot and it was quite easy to get it working on one brick. The problem is letting a computer communicate with two bricks or a computer with one brick and that brick with the other brick. It shouldn't be so hard but my computer doesn't want to connect with both bricks at the same time and thus eclipse can not find them both (this might be a windows problem). That is why i tried connecting the bricks but with no succes. Because letting the bricks communicate via bluetooth was quite hard until now it thought to play it safe and ask about it before i encounter a lot of problems again. I had not looked at wifi communication yet ( as we had no adapters) but now i have i think it should not be so hard as you can just add both ev3's as remote ev3's when they are connected to your network? The question i have here is would it be a problem is all of these 30 bricks would be on 1 network (together with a lot of laptops), would it still be possible to connect only to the two each group has (I think so when you just seek the right mac/ip adresses but just to be safe). BTW thank you for helping me :)
azteks
New User
 
Posts: 4
Joined: Fri Nov 14, 2014 4:32 pm

Re: EV3 to EV3 with bluetooth

Postby gloomyandy » Fri Nov 14, 2014 9:25 pm

Hi,
interesting problems, although there is a cost to using WiFi it would be my first choice for communication:
* By far the most developed mechanism for use with leJOS.
* Industry standard, will let your students use standard protocols TCP/IP and environment.
* Relatively easy to configure, simply connect each EV3 to your access point, with Bluetooth you will need to pair each computer
* Automatic address assignment via DHCP, with Bluetooth you would probably have to allocate and configure addresses to each computer.
Given that you have a number of NXTs you may also want to consider using them as secondary devices, it is possible to talk using Bluetooth between an EV3 and NXT.

I would strongly recommend that you get a couple of WiFi dongles and try things out for yourself. To answer your question, yes to address a particular EV3 when connected via WiFi you simply use the IP address that has been allocated to it, if you require fixed names/addresses for each EV3 this can usually be configured as part of your DHCP configuration.
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4173
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Next

Return to EV3 Software

Who is online

Users browsing this forum: No registered users and 5 guests

more stuff