Logging either on the fly or post-deployment of the A.Bot
JonPeyton
Posts: 10
I'm wanting to try and log the maneuvers that I put my Activity Bot through.
Having finished the corresponding tutorial I guess I need to use the drive_getTicks function but I am unsure how to implement this in a way that will retrieve data created while the bot is "un-tethered" so to speak from the USB.
This may not be possible or this maybe an oversight of the obvious by me, please forgive either way....
thank you!
JP
Having finished the corresponding tutorial I guess I need to use the drive_getTicks function but I am unsure how to implement this in a way that will retrieve data created while the bot is "un-tethered" so to speak from the USB.
This may not be possible or this maybe an oversight of the obvious by me, please forgive either way....
thank you!
JP
Comments
forums.parallax.com/discussion/comment/1332769/#Comment_1332769
One problem is that when I wrote this, the libraries included the function "itoa()". That function converted an integer into text, but was removed from the newer directories.
By saving the text representation to the SD card and separating values by "," or CR, the numbers can easily be imported into other programs.
The sprint() or sprinti() function would have to be substituted for itoa() where ever it is called. The parameters for the itoa and sprint functions are different.
atoi parameters are integer to convert, character string to hold converted digits, number base of the integer.
int n = sprinti(buffer, "%d", x); // convert number to string, n is returned and is the length of the string, buffer is a character array long enough to hold the integer digits, x is the integer, %d is the formatting which converts the decimal (base 10) representation of x. sprinti only works with integers and saves significant code space.
hope this helps
Tom
Here also is an EEPROM example that stores navigation values between each maneuver.
Let's say that right now, your code drives the Activity Bot to a certain place, then logs the number of ticks to the terminal. Simple. That program might look like this if you're using the Simple libraries (as Andy showed above)
If you want to use PropWare, you don't have to change much
From here, I'm going to add a line at the top that seems rather useless.... but you'll understand in a bit.
And now you can modify this to save to an SD card by adding a few lines to the top (to initialize your SD card) and then change a single word at the bottom:
Now, you might think "wow! that's a lot of code at the top now!" And in this small example, it is a lot of lines. However, realize that after the line "Printer logger = filePrinter", there were no code changes. The entire rest of your program does not need to change. How cool is that?! Now you can quickly and easily switch between logging to the terminal and an SD card!
Thank you both so very much!
I cant wait to get home from work and try out the solutions you presented me with!
JP
I haven't used Prop ware (or much C++) yet but I'm not afraid
Thank you for this , I find myself in a lot of head scratching situations at my desk, the more tools I have to free myself the better!
Ill let you know how it goes David.
JP
All 3 approaches (eventually) worked fine.The only reason for the delay was my inexperience with some of the terminology involved in swapping the functions out and being sure to declare and initialize everything properly.properly. I've a lot to learn clearly Tom!
Andy I loaded the code straight away into EEPROM and ran it.The bot did the maneuvers, but where I became lost was I realized that this was something I would view through the terminal so therefore I needed to be attached to the USB right? (I built a stand for my bot that allows me to run code that spins the wheels while still on the desk) this is how I ran it the second time.Did I misunderstand? Is there a way to play out the maneuvers un-tethered and store the data in the on-board memory then come back and have it displayed in the terminal? I'm sorry for my nievete and thank you for your patience! Regardless its still a clean and entirely readable way to log the moves perhaps before actually performing them
David looking at Propware everything seems to make sense (within the limited understanding I have as a whole about this stuff).I did the Propware for Windows.Its in C:\Propware.{BTW I'm Win 8.1 pro 32g RAM i7 4790K}
I installed and configured everything correctly I believe.Perhaps I copied the code wrong as I kept getting this when I tried to load it:
propWare.cpp:9:9: error: 'SD' does not name a type
propWare.cpp:10:25: error: 'driver' was not declared in this scope
propWare.cpp:13:24: error: 'printer' was not declared in this scope
I just copied the code straight from the reply you sent yesterday.
Please advise if you think I'm not setup correctly as I very much would like to add Propware to my arsenal!
Thanks fellas,
and now off to work (boo!)
JonPeyton
Okay, your comments make me realize that I have not provided any kind of guidance for users which would help them decide between the "Windows" and "SimpleIDE" instructions that I provide. I've created an issue for this and will update the docs over the weekend.
In the meantime, I'll simply tell you that you're going to want to use the "SimpleIDE" instructions. You can skip step 1 of those instructions since you already have that available under C:\PropWare.
The other instructions are all intended for someone that wants to use PropWare's build system which is an alternative to SimpleIDE. I only recommend PropWare's build system if you are already familiar with the command line or you would prefer to use another IDE such as CLion or Eclipse.
Although I've been able to build PropWare projects from the command line, building from SimpleIDE has not been as successful. I've followed the SimpleIDE instructions for PropWare, downloading the "libraries & header files" (I copied those into /Learn/Simple Libraries/), and get the same results as Jon. So, looks like there's either a missing step or some configuration problem (BTW: I reset my environment to export $PropWarePath to point towards the newly downloaded PropWare directory, which I place in /Learn/Simple Libraries/). Not sure if that would affect SimpleIDE builds but did it as an extra measure :-)
dgately
This did overflow when compiled with LMM, so be sure you're using CMM for your memory model.
Use Load EEPROM & Run with the example below. Then, turn off power, unplug, and take it somewhere to navigate. Turn on power, if the P26 light turns on, let it do its navigation. If P27 turns on, press/release RST within 2 seconds, then P26 should turn on in another second. With P26 on, let do its navigation.
When the navigation has completed (and logged), turn off power and bring to computer and plug in. Click Program and select Open Terminal. If the Enable/Disable button displays Enable, click it. If it displays Disable, leave it. Then, turn bot power on. If the light is P27, it'll show the logged data. If the light is P26, you'll have 2 seconds to press/release RST to make P27 come on and display the data.
Thanks!
dgately
@JonPeyton and Andy:
I've written up an EEPROM class for PropWare that uses the same interfaces (ScanCapable and PrintCapable) as the serial (UART) and SD card (FileWriter) classes. This will allow you to easily switch between terminal, eeprom, and SD card
eeprom.h
PropWareEeprom_Demo.cpp
-- Edit --
Documentation finished; Source code updated. I'll post a link to the source on GitHub once merged with the develop branch