-
Notifications
You must be signed in to change notification settings - Fork 0
Pull Request for AHRS IO Processor #16
Conversation
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.
Matt,
It looks like you didn't see my inline comments from my last review. Make sure to address those (there is about 30 of them) before you update this request again.
Best regards and happy editing,
Greg
for (int i=0; i < 8; i++) | ||
yawArray[i] = szBuff[index + (8-i)]; | ||
} | ||
|
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.
We need more than just the yaw angle. We need all of them!
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.
The other angles don't change if we are only in a 2D plane, but I should be able to get the others also.
|
||
bool AHRSInputIOProcessor::loopCondition() | ||
{ | ||
return iterations > 0; |
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 are still using this iterations variable for some reason.
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.
I have removed the iterations thing, but without it I don't know when to close the handle.
bfs/implementations/breadcrumbs/io_procs/AHRSInputIOProcessor.cpp
Outdated
Show resolved
Hide resolved
bfs/implementations/breadcrumbs/io_procs/AHRSInputIOProcessor.cpp
Outdated
Show resolved
Hide resolved
There is a problem that may be cause by these changes, that being not closing the handle, since the loop will run forever, I would have to close the loop on some sort of exit condition. I am not sure if the handle closes if the process is killed, if so, then I guess it should be fine.
|
I just realized I did not rebuild with the python script before pushing, I will do that with my next commit. |
Welp, now I get a bunch of red lines when I try and build... It might have to do with the Untabify but I don't see why it would. All the other changes were mostly cosmetic, except for changing the couts to cerrs though I don't see how that could have caused build errors either... |
All the errors seem to be from something other than the code itself. Though that might just be me not understanding how the python script works. |
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,
Just a couple more little things to change.
Best regards,
Greg
#ifndef AHRS_INPUT_IO_PROCESSOR_HPP | ||
#define AHRS_INPUT_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.
Too many spaces here, there should be only one
* 7 : Error occured while trying to send SetOutputConfiguration message. | ||
* 8 : Error occured while trying to send GoToMeasurment message. | ||
*/ | ||
|
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 space so this comment is sitting right on top of the corresponding function
{ | ||
for (int i = 0; i < 8; i++) | ||
{ | ||
rollArray[i] = szBuff[index - (i + 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.
This is really confusing. It would be better if index is first of all named something better like dataIndexStart, and second of all holding the value of the first piece of data rather than the first yaw index. That way all the bits will be possitively offset from the index variable rather than this confusing arithmetic.
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.
There will be a bit of confusing arithmetic any way I do it because I'm looping backwards, but hopefully the new version is a bit more clear.
{ | ||
if (szBuff[i] == 0xFA && szBuff[i+1] == 0xFF && szBuff[i+2] == 0x36) | ||
{ | ||
index = i + 22; |
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 comment here for why this is + 22
double doubleRoll = *reinterpret_cast<double* const>(rollArray); | ||
double doublePitch = *reinterpret_cast<double* const>(pitchArray); | ||
double doubleYaw = *reinterpret_cast<double * const>(yawArray); | ||
Attribute attRoll("rolAngle", 8, &doubleRoll); |
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.
These abbreviations should be all caps and reference the manuafacturer and the type of device they came from... maybe "XSIMUROL", etc.
getComms()->sendAttribute(attYaw); | ||
|
||
// I am not sure if it will close autimatically when the process ends, at the moment I guess we just won't close it... | ||
//CloseHandle(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 the commented out code. It will close when the process ends
I added some comments explaining how I am capturing the bytes of the Euler Angles from the message in the buffer. Quick version here, I first capute a 2 times the size of the message into a buffer, I then search for the begining of the message, when I find it, I then jump to the index where the Angles are stored. I then add each group of 8 bytes for each angle backwords into arrays to then be converted. I add them in backwords since the AHRS is big endian and the computer we are converting them to doubles on is little endian. After each angle's 8 bytes are storred in an array, I then cast them into doubles, where they can then be sent. Hopefully that makes sense, feel free to ask me any questions about it.
I fixed the math for getting the bytes for the Angles to make a bit easier to understand. I also clarfied my comments a bit to try and make them clearer with the explanation.
I further clarified my comments and also renamed index to dataStart to make it more clear what it was.
Changed "index" to "dataStart" in diagram to make it more clear.
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.
Matt,
Great job on this, there is just one little comment I left on how to make it slightly more intuitive. Make sure to address that before you merge but otherwise LGTM
Regards,
Greg
// Puts the bytes for each angle in their own array backwards, since they are sent in big endian | ||
if (dataStart != -1) | ||
{ | ||
for (int i = 0; i < 8; i++) |
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.
Instead of a forward for loop, wouldn't a reverese for loop be more intuitive: for (i = 7; i >= 0; i--)
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.
In some ways yes, I could start at the actual start of the data, but there would still be some funky arithmetic going on.
It would be:
dataStart = i + 7;
for (int i = 7; i > -1; i--)
{
rollArray[i] = szBuff[dataStart + i];
pitchArray[i] = szBuff[dataStart + i + 8];
yawArray[i] = szBuff[dataStart + i + 16];
}
Does that actually make it clearer?
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.
It just comes down to individual preference with the equations if they make more sense...
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.
It changes the - and + into just two +'s which is a bit more clearer.
Changed the for loop to loop backwords itself so that the equations for actually getting the bytes only use +'s. They are still basically the same equations, but hopefully they are a little more intuitive...
This is basically a redo of the a previous pull request that had a bunch of old code in it still. It also fixes some comments left on that pull request.