Plotting X and Y from two variables (X = Var1, Y =Var2)

Posted on
Fri Sep 02, 2016 5:09 am
Gusten offline
Posts: 171
Joined: Dec 30, 2015
Location: Sweden, Gothenburg

Plotting X and Y from two variables (X = Var1, Y =Var2)

Hi
Is there a way to plot both X and Y directly from two different variables. (float)
I know its possible to do from file or from one variable where both X & Y are present in. ?


I have an Automower were i get Longitud and Latitude and i have those in two variables and they updates every 15 sec when the automower is out and Cuts my grass.

So my idé was to have a plot were X = Longitude Y = Latitude and every 15 sec i get an "dot" on the plot, so when i Wake up in the morning i can see if the mower have cut all my lawn.
If this is going to work it should altso bee possible to limit the time of the plot, for example the plots shows only data from 24 hours back.

And of course i will have a map of my garden behind the transperent plot


OR

Is there a easy way to make indigo variables written to a file according to INDIGOplotD standards ?

/Martin

Posted on
Fri Sep 02, 2016 8:08 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Plotting X and Y from two variables (X = Var1, Y =Var2)

I believe so yes. Traveling right now.
Will send you a script later.

Need a ; delimited file
First line #xcolumnName;column name
Next lines
X;y
X;y

Then in edit plot device select the file in 1 or second field. ( Need to select data from file. )
The file needs to be in ~/indigoplotd/data directory

Then select in lines the 2 columns

That's it roughly.

Karl


Sent from my iPhone using Tapatalk

Posted on
Fri Sep 02, 2016 1:30 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Plotting X and Y from two variables (X = Var1, Y =Var2)

here the first screen to setup the plot
Screen Shot 2016-09-02 at 3.23.57 PM.png
Screen Shot 2016-09-02 at 3.23.57 PM.png (131.16 KiB) Viewed 4086 times

you need to change filename
and x/y scales set to 0...50

now how to get the data into a file
you could setup a script that runs every 15 minutes and adds the contents of the variables into a file

run every 15 minutes
import subprocess
v1=indigo.variables["vari1 name"].value
v2=indigo.variables["vari2 name"].value
subprocess.Popen("echo '"+v1+";"+v2+"' >> /users/yourID/documents/indigoplotd/data/myFile",shell=True))

before you add the data you need to add the first line, eg at midnight: run a schedule action. it will reset the file
import subprocess
subprocess.Popen("echo '#x;y' > /users/yourID/documents/indigoplotd/data/myFile",shell=True))

setup the line:
Screen Shot 2016-09-02 at 4.26.21 PM.png
Screen Shot 2016-09-02 at 4.26.21 PM.png (110.86 KiB) Viewed 4074 times


this dataset:
#x;y
1;2
2;2.3
2.5;2.5
2.5;3.5
2.;3.3
1;4
1.3;4.5
4.0;4.5


will create this output:
Screen Shot 2016-09-02 at 10.39.09 PM.png
Screen Shot 2016-09-02 at 10.39.09 PM.png (35.48 KiB) Viewed 4055 times

Karl

Posted on
Fri Sep 02, 2016 9:21 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Plotting X and Y from two variables (X = Var1, Y =Var2)

updated above example.

Posted on
Sat Sep 03, 2016 1:46 am
Gusten offline
Posts: 171
Joined: Dec 30, 2015
Location: Sweden, Gothenburg

Re: Plotting X and Y from two variables (X = Var1, Y =Var2)

H

I get an error when trying the script

Code: Select all
import subprocess

v1=indigo.variables["Automowerlongitude"].value
v2=indigo.variables["Automowerlatitude"].value

subprocess.Popen("echo '"+v1+";"+v2+"' >> /users/smarthem/documents/indigoplotd/data/automower.rtf",shell=True))



Script Error automowerfileupdate.py: EOL while scanning string literal
Script Error around line 6 - "subprocess.Popen("echo '"+v1+";"+v2+"' >> /users/smarthem/documents/indigoplotd/data/automower.rtf,shell=True))"

I tried to see what i did wrong, but cant find it, any idea?

/Martin

Posted on
Sat Sep 03, 2016 6:13 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Plotting X and Y from two variables (X = Var1, Y =Var2)

There is " missing after rtf


Sent from my iPhone using Tapatalk

Posted on
Sat Sep 03, 2016 6:14 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Plotting X and Y from two variables (X = Var1, Y =Var2)

And just one ) at the end


Sent from my iPhone using Tapatalk

Posted on
Sun Sep 04, 2016 11:34 pm
Gusten offline
Posts: 171
Joined: Dec 30, 2015
Location: Sweden, Gothenburg

Re: Plotting X and Y from two variables (X = Var1, Y =Var2)

Its working outstanding :-)

Did a test plot overnight., without any "fancy" background images

See the attached image

Thank you Karl for all help :-)

/Martin
Attachments
GPS Automower-S2.png
GPS Automower-S2.png (68.85 KiB) Viewed 3886 times

Posted on
Mon Sep 05, 2016 5:09 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Plotting X and Y from two variables (X = Var1, Y =Var2)

Gusten wrote:
Its working outstanding :-)

Are you sure? The mower seems quite drunk to me.

Dave

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Sep 05, 2016 7:01 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Plotting X and Y from two variables (X = Var1, Y =Var2)

May I suggest to increase the frequency of dots. if you currently use 15 minutes between dots the mower should cover quit a bit of distance including changing directions (if your property is several km long than thats ok..) :lol:

to better display the coordinates:

if the length of your property is 123m and you would like to to have the coordinates in meters:

import subprocess
v1=str((float(indigo.variables["vari1 name"].value)-12.047)*1000.*123.)
v2=str((float(indigo.variables["vari2 name"].value)-57.573)*1000.*123.)
subprocess.Popen("echo '"+v1+";"+v2+"' >> /users/yourID/documents/indigoplotd/data/myFile",shell=True))

then x and range: 0:12300 ( you have to figure out the proper scale)

or something like this

is there a lake in the middle?

you should add trees etc to the picture!

let me know if you need help to add images to the plot.

Karl

Posted on
Mon Sep 05, 2016 1:07 pm
Gusten offline
Posts: 171
Joined: Dec 30, 2015
Location: Sweden, Gothenburg

Re: Plotting X and Y from two variables (X = Var1, Y =Var2)

The coordinates updates every 20sec but when i looked at the file i can see that the mower docent update so fast, about every 30-40sec, so i will change it.

I can see why you think its drunk :-)

I attached a new image, where you can see a little more whats its done.

(And no, it did not go in the pool :-)

A have a bit of "dialing in" to do with the coordinates to get it symmetrical and to get it correct.


As for attaching an image to the plot, my plan was to use an transparent plot over an image, but maybe you know a better way?

/Martin
Attachments
Screen Shot 2016-09-05 at 20.56.13.png
Screen Shot 2016-09-05 at 20.56.13.png (406.82 KiB) Viewed 3822 times

Posted on
Mon Sep 05, 2016 2:02 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Plotting X and Y from two variables (X = Var1, Y =Var2)

Yes that's fine with transparent image. But you could also play around with transparent background and or transparent lines in the plot.


Sent from my iPhone using Tapatalk

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests

cron