Skip to first unread message

ioannis xenopoulos

unread,
Feb 2, 2017, 7:10:07 AM2/2/17
to MIT App Inventor Forum
Hello
I've done an app to appinventor2 and I need to export a GPS track to (xxx.waypoint) file in rder to use it in the mission planner simulator. I can export for the moment the GPS track in the form: "Lat,Long,Alt" in a (xxx.csv) file. Is it possible to extract directly from the appinventor the .waypoint file? What are in this case, the symbols for the <TAB> and the <END of row> needed? Sorry if I'm asking something ingenuous, but I'm new here!!
If it is impossible, how I can convert the .csv files produced to .waypoints? I would need this conversion to be done automatically, without our intervention.
Thank you in advance
John

SteveJG

unread,
Feb 2, 2017, 9:24:12 AM2/2/17
to mitappinv...@googlegroups.com
Here is a description of a *.gpx GPS track (  https://en.wikipedia.org/wiki/GPS_Exchange_Format )  .  I assume you are attempting to build a track in this format..there are other formats unique to devices or software).   As the article indicates, a gpx file is a special type of xml file.  GPX files are an XML format for working with geolocation waypoints, similar to a kml file.    This link might show you how to handle a gpx file... at least to read one  see the post by ABG  https://groups.google.com/forum/#!searchin/mitappinventortest/gpx%7Csort:relevance/mitappinventortest/3WjvNHcBDa4/fbLpZVYjDAAJ . This should give you a great start.

You are going to attempt to construct a gpx compatible file so the AI2 LocationSensor blocks provide most of the input will need.   You need to create the gpx file using blocks and save the gpx as a text file.  Fortunately, a gpx file is just a TEXT file in disguise.  It can be saved using the File control  (  http://ai2.appinventor.mit.edu/reference/components/storage.html#File  ).     There is no tutorial showing how to do exactly what you might want to do.

Sorry, AI2 cannot directly convert csv to a gpx or waypoints without the developer providing the blocks.  You have to build the required file using AI2 code blocks.

You need to know what the symbols are for <TAB> and the <END of row>  are?  They are part of the  xml format.  You did not provide an example of a working track file for us to compare so we really do not know in the context of your question. Read about xml (exchange markup language) here perhaps https://www.google.com/search?q=xml+file&oq=xml+file&aqs=chrome..69i57.2303j0j7&sourceid=chrome&ie=UTF-8  .

When you get your conversion, please do share it here in the forum; others would certainly be interested.   Others in the forum have had questions about GPS traks...here are the threads...(edit:  threads are here:  https://groups.google.com/forum/#!searchin/mitappinventortest/gpx$20%7Csort:relevance   )the information in these forum discussions might be useful to you in converting the AI2 GPS data into the format you want.


To help you on your way, be aware there is a tool called GPSBabel (https://www.gpsbabel.org/ ) that converts GPS data so that it can be used in various formats.  It might convert a csv into a trak format you can use.  This is not useful for creating a gpx in your situation however if it works with csv files (I do not know), it can be used to test a csv that you generate into your required waypoint file. It can convert kml, html and text files so it probably can help design your AI2 conversion routine.

Regards,
Steve
Message has been deleted

Abraham Getzler

unread,
Feb 2, 2017, 12:25:40 PM2/2/17
to MIT App Inventor Forum
 What are in this case, the symbols for the <TAB> and the <END of row> needed?

\n = end of row
two blanks can serve as a TAB.

 See this thread for help on the timestamp formatting for UTC ...

ABG

ioannis xenopoulos

unread,
Feb 3, 2017, 3:32:21 AM2/3/17
to MIT App Inventor Forum
Thank you Steve and Abraham for your kind responses! I will try your suggestions immediately! If the results are as expected I will share it to the forum.
Thanks again!

ioannis xenopoulos

unread,
Feb 3, 2017, 6:53:20 AM2/3/17
to MIT App Inventor Forum
Dear Steve
a part of the blocks I have used in my application to create the waypoint file is the following in the attachment:
 
Abraham, after inserting:
\n = end of row
two blanks as a TAB,
it seems that the sitution has been greatly improved and the .waypoint file looks like this:

"QGC WPL 110"
"0  1  0  25  0  0  0  0  24.91303  41.14017  3.5  1"
"1  0  0  16  0  0  0  0  24.91303  41.14017  8  1"
"2  0  0  22  0  0  0  0  24.88764  41.132456  8  1"
"3  0  0  21  0  0  0  0  24.88764  41.132456  1  1"
"4  0  0  208  0  0  0  0  24.88764  41.132456  1  1"
"5  0  0  16  0  0  0  0  24.88764  41.132456  8  1"
"6  0  0  181  0  0  0  0  24.91303  41.14017  8  1"
"7  0  0  208  0  0  0  0  24.91303  41.14017  8  1"

e.t.c.
It is very close to what I am trying to do. The remaining problems are:
1) The modification does not insert a TAB between values but just two spaces as I can see using the NOTEPAD++
2) I must try to remove the quotes in the start and the end of each row in order the file format to comply exactly with the mission planner reqirements.
blocks(1).png

SteveJG

unread,
Feb 3, 2017, 10:00:08 AM2/3/17
to MIT App Inventor Forum
What you are dealing with Ioannis is not a *.gpx waypoint; it appears what you are trying to replicate is this:

QGC WPL <VERSION>
<INDEX> <CURRENT WP> <COORD FRAME> <COMMAND> <PARAM1> <PARAM2> <PARAM3> <PARAM4> <PARAM5/X/LONGITUDE> <PARAM6/Y/LATITUDE> <PARAM7/Z/ALTITUDE> <AUTOCONTINUE>

QGC WPL 110
0	1	0	16	0.149999999999999994	0	0	0	8.54800000000000004	47.3759999999999977	550	1
1	0	0	16	0.149999999999999994	0	0	0	8.54800000000000004	47.3759999999999977	550	1
2	0	0	16	0.149999999999999994	0	0	0	8.54800000000000004	47.3759999999999977	550	1


and it is called a 

Waypoint File Format

Although not part of MAVLink, this is the recommended waypoint file format (currently used by QGroundControl and other implementations). Please note that the spaces between the numbers/fields are actually <tab> (Use “\t” in most programming languages)

So this appears to be a text file.  The tab probably should be five (5) spaces (what a 'standard' tab is most word processors)  and to get your file to look formatted your longitude and latitude should be formatted with the Format blocks so that you get 18 decimal places.  Also that the altitude is formatted too and it appears PARAMA1 at least needs to be formatted. based on the example at    http://qgroundcontrol.org/mavlink/waypoint_protocol#waypoint_file_format


Are you programming a drone using this format?


Regards,
Steve











Abraham Getzler

unread,
Feb 3, 2017, 12:29:35 PM2/3/17
to MIT App Inventor Forum
TAB is decimal 9 in the ASCII table.
See attached for the blocks for a TAB() function that will return one tab character, using a trick of the Web component and HTML.
Let me know if it works for you?
You're the first to need it.

ABG

CRLF.aia
TAB.png

ioannis xenopoulos

unread,
Feb 3, 2017, 1:30:15 PM2/3/17
to MIT App Inventor Forum
Dear Steve
thank you again for your interest!
Indeed, I am dealing with a file:Waypoint File Format, but this file is the desired output file. Using the blocks, I have attached in my previous message, I tryed to produce directly the Waypoint File Format file. Using the AI2, as you sure know, I can extract .csv files. Thats why I asked initially how I can convert them in .wpt files ((.csv to .wpt). Anyway I tryed again, inserting five (5) spaces to represent a TAB, but it seems that the NOTEPAD++ does not recognize it as a TAB as you can see in the results below: (I don't now if the mission planner will not recognise it too ....)
"QGC WPL 110"
"0     1     0     23     0     0     0     0     24.91303     41.14017     3.5     1"

"1     0     0     16     0     0     0     0     24.91303     41.14017     8     1"
"2     0     0     22     0     0     0     0     24.88764     41.132456     8     1"
"3     0     0     21     0     0     0     0     24.88764     41.132456     1     1"
"4     0     0     208     0     0     0     0     24.88764     41.132456     1     1"
I attach a printscreen of the NOTEPAD++ output to see exactly what is the output format. You can see the spaces as small orange dots.
Yes I intent to use this file in programming a drone.
Best regards
RESULTS FROM NOTEPAD++.doc

ioannis xenopoulos

unread,
Feb 3, 2017, 1:37:55 PM2/3/17
to MIT App Inventor Forum
Thank you Abraham, very much.
I will try it and let you know.
Best regards

ioannis xenopoulos

unread,
Feb 5, 2017, 1:06:34 PM2/5/17
to MIT App Inventor Forum
Dear Abraham
incredible! but it worked!!!! As you can see in the attachment, the file is almost in the form needed in the "waypoint file format" (currently used by QGroundControl)!
What is remaining now is to remove the "quotes" and it will be exactly the same. I dont know yet how easily it can be achieved but I will try ...
thank you again and Steve for your kind responses.
John
TAB_AT_LAST.doc

Taifun

unread,
Feb 5, 2017, 1:58:32 PM2/5/17
to MIT App Inventor Forum
What is remaining now is to remove the "quotes" and it will be exactly the same
use the replace all block...
Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

Abraham Getzler

unread,
Feb 5, 2017, 4:37:33 PM2/5/17
to MIT App Inventor Forum
Thanks for letting us know!
ABG

ioannis xenopoulos

unread,
Feb 6, 2017, 5:33:01 AM2/6/17
to MIT App Inventor Forum
Thank you dear Taifun, it worked immediately! Attached are the blocks used and the final result!
Thank you all again for your valuable help.
Regards
John
FinalResult.doc
blocks(2).png
Reply all
Reply to author
Forward
Message has been deleted
0 new messages