setHubPort not working?

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

Re: setHubPort not working?

Post by jdecoux »

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 45954 times
IanBloomfield
Phidgetly
Posts: 29
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Post by IanBloomfield »

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: 29
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Post by IanBloomfield »

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: 29
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Post by IanBloomfield »

here is my screenshot
Attachments
timestamp.jpg
IanBloomfield
Phidgetly
Posts: 29
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Post by IanBloomfield »

Smokes - fixed this

had space between words

should read - setDataInterval 20

it is phenomenal now the number speed
IanBloomfield
Phidgetly
Posts: 29
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Post by IanBloomfield »

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: 3399
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: setHubPort not working?

Post by Patrick »

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: 29
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Post by IanBloomfield »

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: 3399
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: setHubPort not working?

Post by Patrick »

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: 29
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Post by IanBloomfield »

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
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests