setHubPort not working?

Supporting Max/MSP versions 6 and up
jdecoux
Labview Developer
Posts: 15
Joined: Mon Nov 13, 2017 10:20 am
Contact:

Re: setHubPort not working?

Postby jdecoux » Wed Mar 07, 2018 3:31 pm

As Patrick said, you should be using the timestamp parameter to calculate the time between measurements. The timestamp is in milliseconds.

Also, to ensure your sensor is set up correctly every time you run the program, I recommend making use of the attach message to automatically set your parameters once the device is attached, as depicted in the attached image.
Attachments
Attach_Handling.png
Attach_Handling.png (23.81 KiB) Viewed 1102 times

IanBloomfield
Phidgetly
Posts: 24
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Postby IanBloomfield » Wed Mar 07, 2018 6:48 pm

ok, have set in the attach loop

with the timestamp - I would need the interval between two timestamp events rather than the total timestamp?

IanBloomfield
Phidgetly
Posts: 24
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Postby IanBloomfield » Wed Mar 07, 2018 7:30 pm

excellent - have worked out the timestamp

according to this - I am getting a data event 250ms. I surely must be able to make this faster?

does the computations lag the events or am I missing something?

IanBloomfield
Phidgetly
Posts: 24
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Postby IanBloomfield » Wed Mar 07, 2018 7:32 pm

here is my screenshot
Attachments
timestamp.jpg

IanBloomfield
Phidgetly
Posts: 24
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Postby IanBloomfield » Wed Mar 07, 2018 7:43 pm

Smokes - fixed this

had space between words

should read - setDataInterval 20

it is phenomenal now the number speed

IanBloomfield
Phidgetly
Posts: 24
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Postby IanBloomfield » Thu Mar 08, 2018 5:39 pm

not sure if this is a good way

have incorporated a way of calibrating the gyros using switches and bangs then automatically feed this result back to my gyros.

I have the complimentary filter in place but was still getting significant drift from the gyro - mainly from pitch it never returned to 0 would be usually 5-10 degrees out and this would accumulate each rotation.

so I put a split and if / or / else type thing - seems complicated but essentially my thought was if the gyro was not actively moving it would take reading from accels and transfer this as the input as a way of resetting the gyro numbers?

or is there a better way?
I can't get my head round programming quaternions and kalman filters.
also I haven't used the magnetometer as I'm not worried about yaw movements as its not common for what I want.

but I will switch the formulae for roll and pitch as really I 180 degrees of roll and on 90 of pitch. I know that's not aeronautically standard notation but is the reality of hand movements.

Ian

If you are able to look at my patch now would be great - but only if I'm not being too frustrating -

I'm actually really enjoying the challenge and loving the "programming"

User avatar
Patrick
Lead Developer
Posts: 2988
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: setHubPort not working?

Postby Patrick » Mon Mar 12, 2018 12:11 pm

If your gyro is rotating in multiple axes at once, and your want to accumulate rates over time to track orientation, then you MUST do the required math (quaternions or rotation matrices) - there really isn't any choice, because rotation in one axis can affect degree of rotation in another axis.

IanBloomfield
Phidgetly
Posts: 24
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Postby IanBloomfield » Tue Mar 13, 2018 3:42 am

What I don't understand with quaternions is what value do I take from the raw gyro for the angles for quaternions?

I've read lots of forums etc about it.

I have the atan2 formula for the accelerometer calculation - but I use this as my correction for they gyro when its not moving.

I can't work out rotation matrices from the gyro data.

I have a pretty complete program at present.

It gives me out the angles and results I need, Have tested it extensively and everything performs as expected. I'm not requiring super uptodate exact position sensing, just the idea of extent of movement. But would love to get my head round the maths.

I'll keep looking - do you know of good guides for gyros and quaternions?

User avatar
Patrick
Lead Developer
Posts: 2988
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: setHubPort not working?

Postby Patrick » Tue Mar 13, 2018 9:42 am

We have a C# example which uses rotation matrices to calculate orientation. I'm not really experienced with Quaternions, but I do know they are preferable to rotation matrices. At some point, I'd like to have some app notes on IMUs, including kalman filters, etc. but just don't know when we'll get to it.

-Patrick

IanBloomfield
Phidgetly
Posts: 24
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Postby IanBloomfield » Thu Mar 15, 2018 3:40 pm

Do you think it would work with the jit.axisquat obj? If I plug gyro data into it with an expr $f1*timestamp to create a degree rotation? That obj is supposed to convert 3axis rotation into a quaternion? My numbers at present work completely fine accept if I rotate the pitch >60degrees then try to roll. It can't register the roll. But pitch works completely normally


Return to “Max/MSP”

Who is online

Users browsing this forum: No registered users and 2 guests