Skip to content

Pull Request for AHRS IO Processor #16

Merged
merged 16 commits into from May 11, 2020
Merged

Pull Request for AHRS IO Processor #16

merged 16 commits into from May 11, 2020

Conversation

mfs16101
Copy link
Collaborator

@mfs16101 mfs16101 commented May 8, 2020

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.

@mfs16101 mfs16101 added the enhancement New feature or request label May 8, 2020
@mfs16101 mfs16101 requested a review from grf14003 May 8, 2020 18:27
@mfs16101 mfs16101 self-assigned this May 8, 2020
Copy link
Owner

@grf14003 grf14003 left a 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)];
}

Copy link
Owner

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!

Copy link
Collaborator Author

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;
Copy link
Owner

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.

Copy link
Collaborator Author

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.

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.
@mfs16101
Copy link
Collaborator Author

mfs16101 commented May 8, 2020

Okay, I'm not sure exactly how to update this pull request with my new commit. It does it automatically. Most of the things you commented on are changed. Except for where you said to make things "constant" what do you mean by that? Like declare them as private variables or as "#define"? I didn't make the COM port change since I am unsure of how exactly that would work and I fear it would break the code completely, I will look further into it. Also, there may be a problem with closing the handle since the loop runs forever. If the handle automatically closes on a process kill then it shouldn't matter.

@mfs16101
Copy link
Collaborator Author

mfs16101 commented May 8, 2020

I just realized I did not rebuild with the python script before pushing, I will do that with my next commit.

@mfs16101
Copy link
Collaborator Author

mfs16101 commented May 8, 2020

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...

@mfs16101
Copy link
Collaborator Author

mfs16101 commented May 8, 2020

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.

This reverts commit 5a9cb08.
I have no idea why exactly but the build errors only got fixed when I
changed the order of the includes in AHRSInputIOProcessor.hpp.
Copy link
Owner

@grf14003 grf14003 left a 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


Copy link
Owner

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.
*/

Copy link
Owner

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)];
Copy link
Owner

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.

Copy link
Collaborator Author

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;
Copy link
Owner

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);
Copy link
Owner

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);
Copy link
Owner

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

mfs16101 and others added 6 commits May 10, 2020 17:08
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.
Copy link
Owner

@grf14003 grf14003 left a 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++)
Copy link
Owner

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--)

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

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...

Copy link
Collaborator Author

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...
@mfs16101 mfs16101 merged commit 64a5fc4 into dev May 11, 2020
Sign in to join this conversation on GitHub.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants