Pull Request AHRS IO proc into dev #15
Conversation
This is the preliminary communication code for the Xsens MTi. Right now it can connect to and read a single message from the motion tracker. It then does its best to the print out the message in hex. It still needs some massageing to make it easier to read and usable with all messages. Also, I want to eventually send messages also. I am currently investigaiting different formats the tracker can output/understand. Also also, I added a basic checksum calculator called checksum.cpp. It seems to currently work correctly and I plan on using it to calculate the checksum values for the message I send.
The fix is in checksum.cpp, it has to do with HexCharStruct. Using this seemed to fix my issues with converting from char to hex (int but not really). Next I should try and use this struct in serial.cpp and see if it fixes the issue. I also worked on structuring a message, should it be in a vector? Should it just be a char buffer with spaces in between? Should I instead look into String format instead of binary format on the MT's side? Not really sure...
… xsensCom Hopefully I did this merge correctly...
Added a function that takes in an abritrarily long vector of chars and calculates the checksum for that message. This hopefully allows for the autimatic calculation of checksum and message construction in order to send messages to the MT.
Using the struct in checksum.cpp serial.cpp is now able to print out the chars correctly for humans (except for leading 0s). The next step is to send a message to the MT and also generalize reading output, right now it requires "knowing" the number of bytes it will be reading, I guess this should be already know because of how you program it. The messages I will be constructing will be GoToConfig, SetOutputConfiguration, and GoToMeasurement. I also would like to investigate the String output mode on the device because it seems like it might make the whole char converting uneeded. I also need to work on a translator that can translate the hex code into the actual values we want to read...
I believe I have gotten the conversion working. I am able to translate the Euler Angles. What I need to do now is develop a better way of captureing full messages from the MT. I have a plan for that, I'm going to capute a large amount of bytes, look for where a message starts, and then go to the correct index to get the data we want. Yeah...
I think I did this correctly... we will see...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Matt,
Great job getting all this working. You do have a couple of issues. I have outlined the line issues in some line comments but you have some major overarching issues as well. The smallest of these is that there is a mixture of spaces and tabs. You can probably fix this by using the auto format feature in visual studio on your IO processor files. If you don't know how to do this, look it up because I forget too. Also, if you don't know what I mean by spaces and tabs. Google spaces vs tabs and I am sure you will figure it out :).
Next, you have some really old code in this branch. You have some of the new code, which I don't get, but the sensor thread stuff is code I wrote ages ago and eventually became the IO processor code. You also don't have the build scripts or updated cmake lists files.
Lastly, you have some serial comms code just sitting outside the root project folder. Not sure what this is doing here or if it is used at all, but it shouldn't be located there even if it is used.
For the second two errors, I am gonna see if we can talk on discord because they may take some time to solve.
Best regards and happy editing,
Greg
@@ -1,4 +1,7 @@ | |||
.vs/* | |||
# These can be removed when xsensCom branch is merged/removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get rid of this change, you shouldn't be changing the gitignore file at all
#include "IOProcessor.hpp" | ||
#include "DataSyncThread.hpp" | ||
#include "Attribute.hpp" | ||
#include <windows.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C++ library includes (the ones with <>) should be above the other ones with a space in between for consistency's sake
@@ -0,0 +1,26 @@ | |||
#ifndef AHRS_OUTPUT_IO_PROCESSOR_HPP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a block comment at the top explaining what AHRS is, what the hardware does, and a link to the product page or something.
int iterations = 10; | ||
bool configured = false; | ||
HANDLE hSerial; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get rid of this extra space
void loop(); | ||
bool loopCondition(); | ||
int configAHRS(); // Initialize the AHRS for the first time | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space
@@ -0,0 +1,51 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really old code that I wrote a long time ago, not sure why it is in here. Get rid of it.
@@ -0,0 +1,8 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't be changing the virtual output processor.
@@ -0,0 +1,66 @@ | |||
#include <iostream> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this serialPortComms folder here? If it is a library then it is in the wrong place
I'm closing this pull request since it is going to be moved to a newer branch. |
I don't know if I did the IO processor files correctly. I did my best to do the same thing that was in the other IO procs.
I also had to do some tricky stuff with initializing the connection and closing the connection. As it is currently setup, it should only run the setup function once and should close the connection after the last iteration.