The Combine Forum banner

AgOpenGPS

901K views 4K replies 204 participants last post by  escotch.ca 
#1 · (Edited)
Download it at......
https://github.com/farmerbriantee/AgOpenGPS

Well it seems have had some time on my hands with it snowing so here goes, the introduction of AgOpenGPS.

Have a peak! Its a bit like watching paint dry, but i think the application has promise - considering its free. AB line, up to 5 sections GPS control, fully configurable and it actually works extremely well. Can not fool the section control as it gives very good recognition of unapplied areas.

My simulator only runs at 1 hz so its jerky a bit and slower, but was the only way to make the video. Using a real antenna and at least 5 hz, smooth as butter.

Click in the youtube icon at the bottom of the video and watch in youtube, this window has much lower resolution

 
#2 · (Edited)
Looks great, Brian! How are you storing the coverage data? Are you using a GIS database of some kind? Even in its simple form it's at least as functional as the Raven Smartboom, but with a visual display. Even if you consider the cost of a windows tablet to run it on, it is still cheaper than the old raven unit.

This is a normal win32 C# app, right? I wonder how much work it would take to get it to run under Mono on Linux.

Would a GPS refresh rate of 5 Hz be slightly better or does it not matter in practice?

I was wondering what it would take to calculate where the implement is relative to the tractor during turns and so forth. I did some research into trailer path prediction algorithms, but never put anything concrete together.

Though in practice when using the Raven SmartBoom, which has no such turning compensation, it didn't seem to matter nearly as much as I thought it would.
 
#3 ·
Coverage, using the current fix position from the GPS and for each section am recording where that is. Next fix i'm recording the new position, so now i have 4 points - a quad. So in opengl i start a triangle strip - two triangles make the quad where i just was, and as the section moves forward it keeps adding new fix positions making more. When the section turns off, that group is added to an array of multiple patches. Each section does this. Fix is recorded in UTM WSG84 values - converted from latitude and longitude - so it can easily be converted and put into a shapefile or just saved as a csv. Could program it to simply record the fixes from the antenna location too and you would have all the data, saveable, and in any for you want. The beauty of open source.

The implement to vehicle pulling radius is an algebraic nightmare. I "got around it" by using a delay line of fix positions to emulate the turn radius of a pulled implement that is speed and fix rate calculated. It actually works extremely well. It does make me wonder for a tow between there is no setting in modern GPS for double hitch geometry. Its obvious the pros fudge it too - especially at the distance the fore/aft setting is. The best would be an antenna on the implement and an antenna on the tractor for guidance. It would be stupid accurate and would compensate for drift on hills.

5 hz is buttery smooth and accurate and is all that is required. Have driven down the road at 50 mph and it works flawless. Its not on the property page but i can set the look ahead time, must add to settings yet.

Yes win32 written in C# and Opengl. Haven't come even close to the 2G memory limitation on a 1200 acre field.

Started with 5 sections, but more could easily be added.
 
#4 · (Edited)
As far as linux and other os's, oh man, this app has some very special programming using win stuff that i would have no idea how to do in other languages. Pretty sure the only reason this works is because c# and windows forms are extremely powerful especially for the non pro programmer. Not saying it can't be done, i'm saying i can't. Used to program games in c++, so not completely unfamiliar with it. 1 day of C# is like 3 months of C++ to do the same thing.

For giggles type "agopengps" into google. Until an hour ago, nothing came up.
 
#5 ·
That's really cool. When you get the code in shape for people to look at, I'd love to see it, just to learn about how it's working! So if I understand you right, you're essentially using OpenGL triangles to record the coverage and using OpenGL to calculate the collisions (overlap)? That's a very novel approach!

Seems to me that implement path calculation should be possible with some linear algebra (vector math). I was hoping to find some basic algorithm that could work it out, but I suspect it's more involved, as you are dealing with changes over time that are inter-related. I want to look into this more, but I seem to have too many unfinished projects that take my time and energy. I must be spectrum ADD or something. Nice to see you making so much progress!

I hear you about C# vs C++. Although actually C++ isn't as hard as people sometimes fear. I have to confess I do all my personal projects in Python these days (using PyQt for graphical user interface), which is the fastest language for development I've ever used. Though anytime you have to program a GUI, things get a bit more complicated.
 
#7 ·
In terms of detecting collisions, no i don't calculate a single thing. I asked a bit ago how how sections worked and one person joked well you have the picture, you can just see it. So it got me thinking. What i do is send the triangles to another opengl rendering window that is 400 pixels square that is in behind the main window. So 1 pixel is about 4 inches of section. I then draw a close up image of the area around the section or boom. There is a command in openGL that is gl.ReadPixel that can read a line of pixel data so i take a snapshot of a few lines at the boom up t0 what will be the "lookahead" point and then just look for a black pixel. Its black because triangles as placed make everything green where applied.

So i look for a zero color and turn on the boom if i see one. If all the lines come back as green, its already been applied so turn the section off. Collision is a nightmare because you can have little wedges of unapplied and to calculate those is very difficult.

In the main window the sections that are green are semitransparent. As you go over a second time the green's transparency keeps subtracting so it will look a little darker with every time a triangle gets drawn over the same spot. that way you get contrast of over applied and overlap.

The implement tracking is very complex as the tractor doesn't just make a turn, it can zig and zag and slide and..... Also, the boom will begin to back up at some point if turning too sharp. An implement will do exactly what the tractor does, except it will be delayed. It starts the corner late so if you chop up the path from the last 20 readings and average them, it takes time for the implement to see "the turn". As the tractor keeps turning the averages also start to pile up as changing so the implement now turns too but since its later, the arc is smaller. Tractor straightens out and now the averages start cleaning out so while the tractor goes straight a while the implement will continue to slowly straighten out. Using the fixes based on the section, you can easily "simulate" quite closely the implements turn without a single calculation.

Just like in writing a game, speed is of the essence. So the less calculations the better and if you can get to 90% of reality without any calcs at all its easier to code and is fast.
 
#8 ·
Very good thinking on the coverage map! That's certainly a much simpler solution than I envisioned. And for this purpose it's an elegant solution.

I'm not sure how the big companies do coverage maps. I suspect they are storing periodic point data rather than coverage pixels because I can forget to turn off recording on my tractor and record paths all over my farm without consume a lot of space.

What are you currently using to interface with the implements sectional controls? Are you using an Arduino in the loop somewhere?
 
#9 ·
i will be yes. That is the really easy part. Serial USB to the arduino with the extent of programming of telling 5 pins to turn off and on in sync with the sections. 5 power fets to switch the booms controlled by the duino. Cost, about 40$

For the antenna a Novatel Smart 6, About a thousand - not sure tho. You can get the dual channel ones the plug into a base for full RTK. They have tilt sensors already built in for proper slope tracking and even can connect via bluetooth. Bluetooth SPP is quite simple with Windows as it is just treated as another serial port.

A tablet or hybrid or Brix or like the lattepanda (my personal preference for about $100) running win 10 already installed and a touch monitor.

Seems silly to spend thousands for section control. Hoping this can go into the seeder setup which has autosteer with an outback S2 and RTK by reading the NMEA from the S2 This mapping and section control should make a nice addition for next to nothing. May put a Smart 6 right on the seeding tool as its tow between and a looooooong way away from the antenna. Then you could do ridiculously accurate anything you want.

I think the "big guys" are using shape files and using polylines and polygons. You still need to store an awful lot of data to keep track of all the green spots no matter the technique. I did a 1200 acre simulated field and saving showed only 80 MB of data, 3 sections. Given 32 bit win apps can manage 2GB of memory space at once, i'm thinking you could map half the country in a single field before running out of memory.

Long story short, it really seems possible this will work. A majority of the hard part is done. And i can use my tablet the rest of the year and not sit in a tractor for 11 months.

Its very easy to add another data stream to include seeding or harvesting info, that's where my other project, ag canbus comes into. No reason couldn't also program in variable rate for next to nothing.
 
#11 ·
Its great to see this kind of a project started for ag. I've been peripherally involved (as a beta tester) with a similar project for ocean navigation. That project is OpenCPN | Official OpenCPN Homepage if anyone is interested but the reason for the post is to point out what I think is one of OpenCPN's strongest features. From its earliest stages the lead developer built in a provision for what he calls Plug-ins. I don't understand anything about the programming but the concept is that the plug-ins integrate fully into the underlying software to provide enhanced functionality. Often that new functionality is hardware specific so, for example, there is a plug-in which integrates Garmin radar displays on top of the underlying nav software and a different plug-in for Navico radar because evidently the output from those two systems is somehow fundamentally different. I've been involved with OpenCPN for just over 6 years now and the increased functionality of the core software has been matched by a profusion of plug-ins over that time frame.
 
#12 ·
It snowed almost a foot yesterday and cold days forecast so its looking like gonna have some free time for a while.

Bob, that is very true, and that is an amazing project! going forward i will really keep that in mind. I like the concept it can be done on any operating system. Torriem would love to see it in linux and i totally agree, but i would need to do a complete rewrite of the software in another language - and learn that language. But maybe, this will inspire someone who does know the language and go for it. Qt is the winner there.

One extremely horrible thing about ag, and i've whined incessantly about it, is the complete lack of any, and i mean zero, nothing, examples of other code, techniques, or discussions how about how many of the major techniques of precision ag are accomplished. Do they use lat/longitude or do they use UTM coordinates? No idea. How is data stored? no idea, all are proprietary binary files. How do they accomplish section control? Not a word in any book or exhaustive search on the internet. Canbus and isobus? You can't even talk about or you get sued if you put anything on the internet, and it cost 30,000$ to buy the "standard" first. Every topic it seems is that way. :52:

Navigation and mapping like OpenCPN has tons of code, examples, projects etc and while in no way easy there are many entire sites like combine forum and bigger dedicated to that one topic. Building a drone from scratch? No problem, download all the code for an arduino, order the list of parts, hook it up. Install the ware on your smartphone and voila, a 400$ full functional drone that retails for 4000$. It obviously comes down to the number of people involved, the more there is the more residual hackers in that crowd.

But in ag, its slowly starting. Matt and Torriem are working on exciting development for bin temp and humidity stuff. Exciting! Do i want to recode and figure all that out? No way, but you can have my code, and i can have your code and others can build upon it too.

Anyway, gotta get this packaged up so others can find bugs in the machine and look over the project and throw out ideas. Thanks for listening to my rants!

BTW, just got in the mail from a new Inertial Measurement Unit (IMU) that is a 9 axis gyroscope/accelerometer/magnetometer from Bosch. Adafruit has put it on a board along with an Arm Cortex processor in the chip it can do all the fusion to spit out roll pitch and yaw. Its 45$ and online is all the arduino code, windows code, and full writeup of tutorials. One huge step closer to autosteer. It's this:

https://learn.adafruit.com/adafruit-bno055-absolute-orientation-sensor/overview
 
#13 ·
I found most of the isobus documents online a while back... dark corners of the internet. Like most standards, isobus is exhaustively documented, if you can cough up the money for the book, but like most committee-standards, the documentation is missing a lot of things (I've been told anyway), hence a lot of mostly compatible implementations among the big manufacturers, but with lots of gotchas along the way.

Personally I think isobus has been good, but if I needed to control something on an implement now I think I'd be tempted to just use wifi. A lot higher bandwidth.

You might get in touch with the gentleman who started this thread: Steering a combine via GPS He built his own autosteer some years back. I'm not sure whether he ever released code or not, but I bet he'd be happy to talk to you.

I'm still waiting for sub $1000 RTK GPS receivers to be available. I think a couple are nearly there.

Picking a language to build things in has gotten more complicated in recent years because of mobile devices. If you want to go with the most native solution, you have to use Swift for iOS, or Java for Android. Neither choice allows you to port to another platform. Microsoft recently bought Xamarin's C#-based system that allows building apps that run on Windows, Android, or iOS. I believe there's some money involved to buy that system though.
 
#14 ·
Yes i have looked at their work, also a fellow named Stef from Europe i've been emailing with. So far, no code online. But maybe once mine is up......

If Microsoft bought Xamarin, well that will be interesting. In true MS style will they obsolete it or continue it.
 
#15 · (Edited)
MS is actually pushing Xamarin's stuff pretty hard to mobile developers. They're integrating their tools with Visual Studio and it will probably become their standard mobile toolkit. They recognize MS lost the Phone OS game a long time ago, and this is their only chance to position C# and .NET as a dominant development platform whether you're on mobile Windows tablets or Android or iOS.

So you should probably stick with C#. Really the hard work is in the algorithms and methods you're perfecting. The language is almost irrelevant. Code can be ported/translated later if the need arises. The only recommendation I'd have would be to keep your core logic and algorithms as separate from the UI code as possible. That makes it easier to port to other platforms later (such as Android or iOS). Of course that's easier said than done. I know you're using OpenGL for coverage and overlap detection, and that's fine since OpenGL is somewhat portable on its own.

Yes getting some code out there for others to chew on would be very helpful! I've already learned a lot just from you describing how you're doing things.

As far as bin monitoring goes, that's high on my list of things I want to do and if and when I get something put together I will definitely share like you're doing.
 
#16 · (Edited)
Good or bad, here it is.

https://github.com/farmerbriantee/AgOpenGPS

To download, click on the green "Clone or Download" and select "Download ZIP". It will be in your download folder (windows).

Installation isn't required, just unzip and run it right from the directory. It will create a fields directory in your MyDocuments and the setting file is created in AppData\Low\AgOpenGPS\

It will say COM99 doesn't exist and you should change in settings. Hit ok and it will run. Note, it won't do anything till you feed it an NMEA signal containing RMC. Almost any antenna/GPS receiver will work, just pick the right com port and baud rate. set the Hz to however fast the update is.

Source code is in the Source directory, obviously. Enjoy.
 
#19 ·
I've downloaded a copy to play with here. Interestingly, it seems to run under Wine on Linux. Even without installing the official .NET runtime. I am going to set up a dummy gps feed to give it and see how that works. I'll post and let you know.

I tried it under Mono, but it's not working, but I didn't have time to investigate why.
 
#22 ·
All this talk about programming in c# inspired me to sign up for a Microsoft course on the subject. Whether I ever get that far but I used to play around with Basic in school and liked doing so. My autistic son is computer savvy and thought what a great bonding experience if him and I could learn the language and make a few games or such. As well, I can understand what you guys are talking about. Besides if enough of us can open source a bunch of ag software and maybe we can tailor stuff to better suit our needs and not have to sell our first born for overpriced stuff.
 
#24 ·
Besides if enough of us can open source a bunch of ag software and maybe we can tailor stuff to better suit our needs and not have to sell our first born for overpriced stuff.
Without offending anybody I guess this is cool but what is the ultimate goal? Trimble, JD, and name your company charge fees for unlock codes which sucks because I believe they are excessive. Ipads and tablets are less then $1000 US whereas JD and trimble displays are $5000 + before unlocks. I get the money savings, but If I already have this overpriced stuff I probably wouldn't switch to this kind of setup. ( Not that the BrianTee would care anyway.)

Is the idea for updating older or customized equipment with new technology for fraction of the price? Or maybe a guy is running new equipment valued at $200k-800k and wants to save a little and stick it to the man. I'll pick on JD... If you buy a JD tractor with EH valve and pull an airseeder/planter with section control, blockage, etc. it would be wicked to have an Android tablet run all of it as you could save an easy $15k doing so... When this can control and monitor a Bourgault Aircart then sign me up as I despise their system.

I have a hard time thinking outside the box, but if the goal is to make this open software better then the existing setups out there and not just for money savings then I will question no more as I do not have enough creativity to make them better other then to streamline their menus and help functions.

ISOBUS is like the United Nations. Sounds good in theory, but nobody plays by the same rules and it ends up being a cluster*&&^
 
#23 ·
Sounds good, Snapper22. Another language that might be appealing is Python. In some ways it's quicker to get going on than C#, since there's no compiler you have to run each time you make a change, and it has an interactive mode for playing with small snippets of code. Google for Python tutorial if you are interesting in that. There are lots of good tutorials out there.
 
#27 ·
Brian, I got things working better in Wine. I had to ditch my 64-bit wine and go with straight 32-bit, and installed the official dotnet45 runtime. I had to do a registry tweak to get my pass-through serial ports to enumerate in windows, but they do now. Unfortunately, my fake serial device doesn't work (Wine/win32 says it's not a valid serial port) with AgOpenGPS, though I can get it to work with other software like putty... But the real serial port works. I'll try it on my laptop in a tractor when I get a chance.

I'm not sure if this is quite what I think it is, but there's a C# library and some software for Arduino to control the Arduino from inside of C#via the serial link. Arduino Playground - Csharp .
 
#29 ·
Yes I have, its the next step. While there are lots of ways to do this, the auto connect is really nice. Darn serial ports, it can be very frustrating. Always a problem, especially to go Bluetooth SPP.

The other challenge is tablets generally only have a one usb. Either everything goes thru the arduino including the nmea or a powered hub that may or may not work. The other problem is many tablets won't charge while using USB. The road is bumpy yet.
 
#32 ·
Arduino is neat because you are programming things that interact with the real world. Buttons, lights, sensors, motors. It's extremely rewarding. And it gives a good sense of the underlying technology behind our modern farm machines. After you spend some time with an Arduinoo board doing a project, you'll understand what your tractor computer means when it says a sensor is having a problem and is shorted to the high (or low) source. Arduino does require you to learn some basic electronic principles like ohms law, but the amount of circuitry required to do some pretty advanced things is minimal. It's a forgiving system but if you do make a mistake, well it's a good thing you can buy arduinos for under $20 a pop! I have a drawer full of burned out boards from when I was learning and was trying to interface with some 12V controls (linear actuator). Forgot which side of my breadboard was the 5v side and which was the 12V side. Poof, magic smoke[1] released.

[1] It's a well-known fact that computers and electronic devices run on magic smoke. We know this because if you ever let the smoke out of something, it will not work any longer.
 
#34 ·
This looks really good Brian. Thanks for sharing. It's a good reminder that I should shake the rust off my hardware/software skills and get back up to speed on this stuff. I will definitely be looking at your source code in the near future. If I have any questions or insight I will let you know.

As for the question why, here's my thoughts. There are tons of posts on this forum from people who have made mods to their combines or other equipment. This is really no different. Just people using what they know to make things work better.
 
#36 ·
Brian, a quick thought on something you might want to implement eventually:

As well as a master on switch, switches for each section to either turn them off, force them on, or auto. (make sense?) Software switches are fine, though having hardware switches via arduino made possible would good eventually. Turning off a section would be reflected in the coverage map of course. I find while spraying I sometimes need to do that.

I had another thought but forgot it for now... hope I can remember it later.
 
#37 ·
WOW...for a "farmer" to do something like this is amazing. I'm in the process of getting an android tablet (probably Samsung) and I'm definitely going to give it a go. If I go back through my university text books I'm sure I could add something somehow but actually writing code could be a bit of a stretch.

The more I think about it, a control loop for a Boomspray rate control would not be that difficult, it's just when you start switching sections on and off that you start throwing a bit of a spanner in the works.

Keep up the good work. If you want any feedback or suggestions dont be afraid to ask but I'm not a whole lot of use at coding.
 
#40 ·
The more I think about it, a control loop for a Boomspray rate control would not be that difficult, it's just when you start switching sections on and off that you start throwing a bit of a spanner in the works.
Yes a basic rate controller would be a fun thing to develop. When you think about it, there's not much to a sprayer. It's mainly just plumbing, electronic valves, and rate controller. The principle by which the rate controller works is a technique called "proportional/integral/differential control", also called PID. PID is something that most of us do in our brains without thinking. For example, your brain does it when you're driving a car, steering, or accelerating to a certain speed and maintaining that speed with your foot.

It's easy to implement in code, but very hard to tune! I spent many weeks trying to make rate controller work with a servo on a small 1/2" butterfly valve work. I almost got it working.

There are ways of dealing with sections coming on and off. When a section turns off, the computer could right away shut the valve a certain amount, then let the PID loop seek to the new equilibrium position. Or just let the PID loop find it by itself. On my old flexicoil, when I stop a section, my rate does jump up quite a bit for a couple of seconds while the controller adjusts.
 
#38 ·
Somethi g like this awesome just for slug pelleting with four wheeler or broadcasting seed etc.

Excuse my ignorance but to hook in an external gps...i take it that it goes in usb port...then this app does the set up and controlling of that external device...

If i wanted a on off switch external can that be done or must use tablet screen?

Ant...
 
#39 ·
Somethi g like this awesome just for slug pelleting with switchesfour wheeler or broadcasting seed etc.

Excuse my ignorance but to hook in an external gps...i take it that it goes in usb port...then this app does the set up and controlling of that external device...

If i wanted a on off switch external can that be done or must use tablet screen?

Ant...
The software needs to see an nmea0183 stream coming from a GPS antenna/receiver via a serial port to the tablet. Almost every unit has that output. A USB to RS232 cable adaptor is all that is required. About 20$. Set both to speak the same speed with at minimum an RMC sentence.

https://www.amazon.ca/Plugable-Adapter-Prolific-PL2303HX-Chipset/dp/B00425S1H8

For this software to control anything it needs another port to control something like an arduino to either read manual switches or control booms to turn them on off. Yet to happen, but is the easy part of this project.

Perhaps I should write up an NMEA and serial port tutorial.

This software is in alpha development. Should make a lot of progress this winter. Also, making sure it runs in both Linux and windows. Android, not sure yet on Crossover and Wine/Mono development there, but even that looks promising.
 
#41 ·
If anyone wants information on getting RS232 GPS out of a GreenStar receiver, I can tell you how. Deere sells a $300 cable to do it, but it's not hard to splice into some wires up on the receiver and just use a cheap serial cable. And on the new GreenStar receivers, you can actually get serial from the back of the monitor I've been told.
 
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top