[EV3 0.9.0] Adding waypoints from the Robot

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

Moderators: roger, gloomyandy, skoehler

Chrisbes
New User
Posts: 6
Joined: Thu Apr 20, 2017 2:18 am

[EV3 0.9.0] Adding waypoints from the Robot

Postby Chrisbes » Thu Apr 20, 2017 2:26 am

Hi,

I've searched around and not found much but I'm having issues adding waypoints from my robot.
I'm using version 0.9.0 still on my EV3 and I'm using the same method for transferring data over bluetooth as the MapTest and MapCommandTest files.
Now I want to add some sort of point to the map and the first thought was waypoints as for my application, they won't be used.
So I've tried adding one from the program using

Code: Select all

model.addWaypoint(new Waypoint(100,100));
. My model has a Navigator and Pilot.
This works when implemented directly into the mapping file but not when sent over from the robot. Saying that, it does add a waypoint but not one that i've placed.

I'd prefer to use a regular point just drawn on the map but I can't find a way to send one over with the pose information.

Is it even possible to do this with Waypoints?

Cheers

EDIT:
I managed to fix this, I realized that my AddWaypoint method in EventRecieved was overwriting everything I passed to it. So Instead I changed this to go off the robots current pose data. This means that if I call model.addWaypoint on my robot, the EventRecieved method intercepts it and correctly adds to the map.

Chrisbes
New User
Posts: 6
Joined: Thu Apr 20, 2017 2:18 am

Re: [EV3 0.9.0] Adding waypoints from the Robot

Postby Chrisbes » Fri Apr 21, 2017 5:05 am

Might as well just reuse this post:

I'm trying to get the distance measurement from the robot into my client and I have the issue that while a pose update sends a new range reading, I can't seem to grab this from anything in the client.
I can though grab the RangeReadings() method inside of my AddWaypoint listener except it always seems to return -1.

Is there any way I can grab the range reading from the pose update outside of the pose update event received function or is there any other way to do it?

Thanks

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

Re: [EV3 0.9.0] Adding waypoints from the Robot

Postby gloomyandy » Fri Apr 21, 2017 8:05 am

I think you need to explain a little more about what it is you are doing. So how are you obtaining a RangeReading in the listener and what is it you are expecting to be there?

Perhaps you can provide more details of how your setup is constructed. It sounds like you have a PC and EV3 part, but are these standard samples or something you have written? What is it you are trying to do?

I assume you are generating range readings from some form of RangeScanner/RangeFinder? Is there a reason why you can not simply get the readings directly from that?
leJOS news https://lejosnews.wordpress.com/

Chrisbes
New User
Posts: 6
Joined: Thu Apr 20, 2017 2:18 am

Re: [EV3 0.9.0] Adding waypoints from the Robot

Postby Chrisbes » Fri Apr 21, 2017 1:38 pm

gloomyandy wrote:I think you need to explain a little more about what it is you are doing. So how are you obtaining a RangeReading in the listener and what is it you are expecting to be there?

Perhaps you can provide more details of how your setup is constructed. It sounds like you have a PC and EV3 part, but are these standard samples or something you have written? What is it you are trying to do?

I assume you are generating range readings from some form of RangeScanner/RangeFinder? Is there a reason why you can not simply get the readings directly from that?


Yeah not a problem. So my current setup is using an ultrasonic sensor with an EV3 connected to a pc using bluetooth.
Program wise, I'm playing around with the MapTest and the EV3MapCommand programs. I was hoping to grab distance measurements from within the EV3MapCommand program using the NavEvent.ADD_WAYPOINT but I couldn't see any other way of getting that data other than model.GetReadings().getRange(0);, Assuming getRange(0) referred to the first value in a list/collection of values like the ultrasonic sensors sample[0] does. But this was just returning -1.0.

I got round it by finding out the hypotenuse of the feature coordinates given through model.getFeatures();. Hacky but it worked.
I was just wondering if there was any other, easier method to get that range data as on the robot I can just take from the SampleProvider given through the ultrasonic sensor.

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

Re: [EV3 0.9.0] Adding waypoints from the Robot

Postby gloomyandy » Fri Apr 21, 2017 7:16 pm

Sorry I'm not really all that familiar with the maptest and other PC programs. I assume it is on the PC side of things that you want to get hold of the range readings? In theory you should be able to do so. If you look at the source of the EV3NavigationModel class that is the main focus of the code on the EV3:
https://sourceforge.net/p/lejos/ev3/cod ... Model.java
you can see what data can be requested (or is sent) from the EV3. This seems to include the range readings. The associated class on the PC side is here:
https://sourceforge.net/p/lejos/ev3/cod ... Model.java
It does not seem to provide direct access to the readings (they are stored in a protected member variable), So you will either have to modify the class or perhaps subclass it to gain access.
leJOS news https://lejosnews.wordpress.com/

Chrisbes
New User
Posts: 6
Joined: Thu Apr 20, 2017 2:18 am

Re: [EV3 0.9.0] Adding waypoints from the Robot

Postby Chrisbes » Fri Apr 21, 2017 7:31 pm

gloomyandy wrote:Sorry I'm not really all that familiar with the maptest and other PC programs. I assume it is on the PC side of things that you want to get hold of the range readings? In theory you should be able to do so. If you look at the source of the EV3NavigationModel class that is the main focus of the code on the EV3:
https://sourceforge.net/p/lejos/ev3/cod ... Model.java
you can see what data can be requested (or is sent) from the EV3. This seems to include the range readings. The associated class on the PC side is here:
https://sourceforge.net/p/lejos/ev3/cod ... Model.java
It does not seem to provide direct access to the readings (they are stored in a protected member variable), So you will either have to modify the class or perhaps subclass it to gain access.


Yeah, I want to get them on the client. Like I said, I managed to get it a hacky way using the FeatureDetector to get the XY of what would provide a distance reading and calculating the distance off that.

Seems odd that there's no direct access since the FeatureDetector (I think) and model.getReadings().getRange(); logically make sense considering the syntax.
Ah well, It's solved anyway.

Thanks for the help

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

Re: [EV3 0.9.0] Adding waypoints from the Robot

Postby gloomyandy » Fri Apr 21, 2017 7:35 pm

I assume by client you mean the program running on the PC?

As to why they are not available, well you need to remember that this code is not supposed to be some sort of general purpose remote robotics code, it was written to explore using a map and displaying that data on a PC. So I can only assume that Lawrie, did not feel the need for access to the range readings (there is code in te PC navigation model to populate the UI with the readings). Also it is a trivial job to modify the source code to obtain access to them if you need it.
leJOS news https://lejosnews.wordpress.com/

Chrisbes
New User
Posts: 6
Joined: Thu Apr 20, 2017 2:18 am

Re: [EV3 0.9.0] Adding waypoints from the Robot

Postby Chrisbes » Sat Apr 22, 2017 10:21 pm

gloomyandy wrote:I assume by client you mean the program running on the PC?

As to why they are not available, well you need to remember that this code is not supposed to be some sort of general purpose remote robotics code, it was written to explore using a map and displaying that data on a PC. So I can only assume that Lawrie, did not feel the need for access to the range readings (there is code in te PC navigation model to populate the UI with the readings). Also it is a trivial job to modify the source code to obtain access to them if you need it.


Yeah, the program on the pc is what I'm referring to.

I've been looking through all the code that supplies range readings and honestly, I can't get my head around them. I've tried every possible solution to it and I can't get it to return an actual value.. In reality my method of grabbing the X/Y of the feature in front and calculating the longest side makes sense but it just seems a bit long and tedious for what it is. I've tried extending into the EV3NavigationModel as that has range readings but that didn't work.
It seems odd because when a feature is detected there is a default console print out of range. I just can't seem to grab that from anywhere..

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

Re: [EV3 0.9.0] Adding waypoints from the Robot

Postby gloomyandy » Sun Apr 23, 2017 7:27 am

If you want the readings on the PC you need to extend the PCNavigationModel not the EV3NavigationModel. If they are being displayed on the PC then all you need to do is to find the code that is displaying them and work back from that. You can see code that is logging the position of a feature here:
https://sourceforge.net/p/lejos/ev3/cod ... .java#l855

In the same method there is code that looks like it is capturing all of the range readings. However it will only be called if the robot sends the readings in response to a request from the PC, no idea if that is being sent but you have all of the code so it should be easy enough to find out.

Perhaps the more important question is why are you doing this? What is it you are trying to do and why? Is this some sort of bigger project? A college or school assignment? What is the end goal?
leJOS news https://lejosnews.wordpress.com/

Chrisbes
New User
Posts: 6
Joined: Thu Apr 20, 2017 2:18 am

Re: [EV3 0.9.0] Adding waypoints from the Robot

Postby Chrisbes » Sun Apr 23, 2017 8:12 am

gloomyandy wrote:If you want the readings on the PC you need to extend the PCNavigationModel not the EV3NavigationModel. If they are being displayed on the PC then all you need to do is to find the code that is displaying them and work back from that. You can see code that is logging the position of a feature here:
https://sourceforge.net/p/lejos/ev3/cod ... .java#l855

In the same method there is code that looks like it is capturing all of the range readings. However it will only be called if the robot sends the readings in response to a request from the PC, no idea if that is being sent but you have all of the code so it should be easy enough to find out.

Perhaps the more important question is why are you doing this? What is it you are trying to do and why? Is this some sort of bigger project? A college or school assignment? What is the end goal?


Interesting, I wasn't looking into particles because I wasn't looking at MCL. I was looking at the Feature_Detected statment in PCNavigationModel but obviously that didn't work. Thanks!

And no, It's not for anything in particular. I just picked up a kit for cheap and decided to rummage through the sample files.


Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 3 guests