Inertial Issue

I am using the Visual Studio Code

I am using an inertial sensor in my code, but the transform function doesn’t work.

If you don’t know what that is, it basically should transform from quartinion or matrix to x,y,z.

This is what my transform code looks like:

dti.transform(accurateOrientationX, accurateOrientationY, accurateOrientationZ);

NOTE: dti is the inertial sensor name

But when I build it, I got a build error 2 with this:

**src/inertial.cpp:21:7: error: no member named 'transform' in 'vex::inertial'**
  dti.transform(accurateOrientationX, accurateOrientationY, accurateOrientationZ);
  ~~~ ^
1 error generated.

make: *** [vex/mkrules.mk:13: build/src/inertial.o] Error 1

Build Failed: Make process closed with exit code: 2

Does anybody know how to fix this?

transform is not a member function of the inertial class.

transform is a member function for the following classes

inertial::matrix
inertial::quaternion
inertial::attititude

its use is pretty advanced, what are you trying to achieve ?

7 Likes

oh ok.
I am trying to use it to implement turning. It’s a work in progress. Still working out the little stuff here and there.

Thank you very much. I tried to transform the wrong thing it looks like.

This is my new code for it:

void positionUpdate(){

  vex::inertial::quaternion inertialOrientation = dti.orientation();
  inertialOrientation.transform(accurateOrientationX, accurateOrientationY, accurateOrientationZ);

}

No build errors (yay)

Thank you @jpearman!

Pretty sure you are overcomplicating this. You should simply be able to do:

void positionUpdate() {
  double current_heading_deg = dti.rotation(degrees);
  // Left as an exercise...
}
1 Like

As Mentor_355U said, does seem a little over complicated, but if you succeed let us know how things worked out. I originally added the quaternion class with graphics in mind, transforming vectors for visualizing how the inertial sensor was oriented, however, the raw data that comes from the inertial sensor to the V5 brain is in quaternion format where we convert to a roll, pitch and yaw attitude (heading and rotation are derived from yaw), so it could be used as an alternative to heading.

3 Likes

And, to be clear, if OP would like to use the Inertial sensor for one of the other degrees of freedom (e.g. pitch and roll, for example) the dti.pitch(degrees); and dti.roll(degrees); functions seem simpler than dealing with the quaternion…

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.