Using Forward Star structure and algorithm in autonomous robots
#1
Posted 26 March 2011 - 04:15 AM
#2
Posted 26 March 2011 - 04:33 AM
#3
Posted 26 March 2011 - 09:21 AM
As anyone thought of using the Forward Star data structure and algorithm (to find the shortest path) for autonomous robots ?
I have implemented a VB version many years ago (1995) and I could rewrite it for C# to use in autonomous robots ... Everything in .Net MF ... any interest in such an algorithm ? very very efficient data structure (minimalistic, one node per node and one link per link, no wasted structure) and it is a very very fast algorithm.
Example of usage : in a defined environment resembling a network of connecting nodes, allow a robot to find the fastest way to get there (emergency, security (using cameras on a quadcopter), etc). You can recalculate new paths when encountering closed paths ... could probably be used to repath power just like in Terminator movie lol
Mike discovering quadcopters and netduino !
p.s.: I'll also work on a Kalman Filter using a complete set of sensor data as well as user commands. Everything in .Net MF
I'd be interested in the code as well.
#4
Posted 26 March 2011 - 01:14 PM
I'd be interested in the code as well.
I just started to learn .Net (I know so many languages ... and yeah, I know, late learning) so give me time.
My project is to build a complete quadcopter from scratch and include in it the Kalman filter (KF). Once done, I'll work on it being autonomous ... and add the Forward Star (FS) data structure and the label setting shortest path algorithm.
If someone already has an autonomous quadcopter (or anything autonomous that would need such a fonctionnality) and would like to add the FS data structure, please contact me and I'll rewrite it sooner. If only newbies like me, then I'll take the time to learn first
If I wait long enough, we probably could have it in VB.Net on .Net MF lol (I'm a VB fanatic, so easy to program) but I'll try it in C# ...
Mike surprised about your fast reply !
#5
Posted 26 March 2011 - 05:10 PM
I just started to learn .Net (I know so many languages ... and yeah, I know, late learning) so give me time.
If I wait long enough, we probably could have it in VB.Net on .Net MF lol (I'm a VB fanatic, so easy to program) but I'll try it in C# ...
One word of advice, since you're just starting out with .NET - make sure you develop the code in a .NETMF (Netduino) project and not a regular .NET project. NETMF is a subset of the full framework and I'm continually running into things that I can do in one but not the other.
VB.NET and C#.NET are much more closely related than VB is to VB.NET. I found the transition from VB to VB.NET to be hard work mostly because of the effort required to learn the framework. The syntactic differences between all three are not particularly significant.
- Adam
#6
Posted 27 March 2011 - 01:48 AM
- make sure you develop the code in a .NETMF (Netduino) project and not a regular .NET project.
Don't worry, I also program for the windows phone 7 in silverlight (vb and c#) and I always get confused LOL
I tested my old vb program and it works like a charm ... 1995 code ! wow !
I tried to convert using Artinsoft Visual Basic Upgrade Companion (free for msdn member) but only the c# translation worked ... so I'm ok for the netduino I have to test the class a bit before posting the code
Keep you posted ... now is time to get out and play pool !
#7
Posted 28 March 2011 - 09:50 PM
- The code was transfered to VB.Net like a charm
- Now trying to translate to C# (Full .Net first, then .Net MF ... but with the N+ since there is file access)
Question : how do we write/read files in C# ?
Here is the code using the Microsoft.VisualBasic assembly that I want to remove the dependency ... to write the Nodes and Links to files and loading them from files
filenum = FileSystem.FreeFile();
FileSystem.FileOpen(filenum, s, OpenMode.Input, OpenAccess.Read, OpenShare.LockWrite, -1);
FileSystem.Input(filenum, ref k);
FileSystem.FileClose(filenum);
int filenum = FileSystem.FreeFile();
FileSystem.FileOpen(filenum, s, OpenMode.Output, OpenAccess.Write, OpenShare.LockReadWrite, -1);
// Write the number of nodes and links.
FileSystem.WriteLine(filenum, bGraphicalInfoAttached, iNumNodes, iNumLinks);
FileSystem.WriteLine(filenum, Nodes[i].Name, Nodes[i].FirstLink, 0, 0);
And I have to verify why I am using this ...
s = Strings.Left(s, s.Length - 2);
And this ...
Conversion.ErrorToString()
I Think I can replace the last one with a catch (Exception e) in a try catch and using e.Message ... I am right ?
Keep you posted.
#8
Posted 29 March 2011 - 01:44 AM
There are a lot of ways to do file I/O depending on what you need to do. Here's some code that I'm using to read/write to the SD card on the Netduino:
using System.IO; public byte[] Read(string fileName) { byte[] buffer; using (FileStream file = File.OpenRead(fileName)) { buffer = new byte[file.Length]; int bytesToRead = (int)file.Length; int bytesRead = 0; while (bytesToRead > 0) if (file.Read(buffer, bytesRead, bytesToRead) == 0) break; file.Close(); } return (buffer); } public void Write(string fileName, byte[] data) { using (FileStream file = File.Open(fileName, FileMode.Append)) { file.Write(data, 0, data.Length); file.Flush(); file.Close(); } }
The only word of warning would be that the read buffer in the above code could overflow on a platform with limited memory such as the Netduino. The code really needs to check the file size before allocating the buffer and then chunk the data if necessary.
Conversion.ErrorToString()
I Think I can replace the last one with a catch (Exception e) in a try catch and using e.Message ... I am right ?
Yes, you're right, use a try...catch and parse the exception like this:
try { // something... } catch (IOException ex) { // Catch a specific type of exception Debug.Print(ex.ToString()); } catch (Exception ex) { // Catch any exception Debug.Print(ex.ToString()); } finally { // clean up here, if necsessary }
Hope that helps.
- Adam
#9
Posted 29 March 2011 - 03:06 AM
The only word of warning would be that the read buffer in the above code could overflow on a platform with limited memory such as the Netduino. The code really needs to check the file size before allocating the buffer and then chunk the data if necessary.
Thanks ! I'll check that in april ... work load too heavy but wow ! Thanks !
And I am right in assuming that the FLASH memory access is automatic ? or do we need to do some special access to read/write to it ?
Mike away from the computer for the next few days ...
#10
Posted 29 March 2011 - 03:43 AM
And I am right in assuming that the FLASH memory access is automatic ? or do we need to do some special access to read/write to it ?
Yes, that's right (assuming your SD Card is compatible). Just prefix the path with \SD like this:
File.OpenRead(@"\SD\myfile.txt");
#11
Posted 02 April 2011 - 08:25 PM
#12
Posted 05 April 2011 - 02:14 AM
Thinking of modifying the saving to file functionality to write xml file instead of an old coma seperated values (didn't find a way to read it and store it in variables yet ...).
I prefer XML files ... anyone argue ?
Anyone know of a XML Spy equivalent on the open source community ?
Haven't used it myself, so I have no idea if it will suit your needs but there's the free version of the Serna XML editor at http://www.syntext.c...cts/serna-free/
#13
Posted 05 April 2011 - 02:24 AM
My Prefered tool for XML / XSD (Schema definition) is XML Spy but it is not given ... I'll buy (when budget permits) the professionnal version ... I used to do a lot of XSD and XML with it, very efficient.Haven't used it myself, so I have no idea if it will suit your needs but there's the free version of the Serna XML editor at http://www.syntext.c...cts/serna-free/
#14
Posted 06 April 2011 - 09:17 PM
#15
Posted 08 April 2011 - 01:40 AM
Attached Files
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users