Myo bracelet; How go from quaternion to forearm direction unit vector?
I am doing a project with a myo bracelet. The bracelet uses quaternions to track it's orientation. What I want is a vector that points in my forearms direction without orienation, i.e. I only want a unit vector that represents my forearm. Is this possible and does anyone know how to do this?
I have tried to perform quaternion multiplication by P' = QPQ^-1, by following the instructions on this site Maths - Transforming Vectors with Quaternions` but I don't get this to work. I suspect that this is because the quaternion output from the Myo bracelet is not one single rotation but a continuously changing orientation/rotation as I move my arm/the bracelet.
Basically the data that I get from the Myo is on the form of [X,Y,Z,W] and this is changing as I move my arm. I would highly appreciate if anybody could be kind to help me out a bit
Cheers,
// hjalle
quaternions myo
add a comment |
I am doing a project with a myo bracelet. The bracelet uses quaternions to track it's orientation. What I want is a vector that points in my forearms direction without orienation, i.e. I only want a unit vector that represents my forearm. Is this possible and does anyone know how to do this?
I have tried to perform quaternion multiplication by P' = QPQ^-1, by following the instructions on this site Maths - Transforming Vectors with Quaternions` but I don't get this to work. I suspect that this is because the quaternion output from the Myo bracelet is not one single rotation but a continuously changing orientation/rotation as I move my arm/the bracelet.
Basically the data that I get from the Myo is on the form of [X,Y,Z,W] and this is changing as I move my arm. I would highly appreciate if anybody could be kind to help me out a bit
Cheers,
// hjalle
quaternions myo
add a comment |
I am doing a project with a myo bracelet. The bracelet uses quaternions to track it's orientation. What I want is a vector that points in my forearms direction without orienation, i.e. I only want a unit vector that represents my forearm. Is this possible and does anyone know how to do this?
I have tried to perform quaternion multiplication by P' = QPQ^-1, by following the instructions on this site Maths - Transforming Vectors with Quaternions` but I don't get this to work. I suspect that this is because the quaternion output from the Myo bracelet is not one single rotation but a continuously changing orientation/rotation as I move my arm/the bracelet.
Basically the data that I get from the Myo is on the form of [X,Y,Z,W] and this is changing as I move my arm. I would highly appreciate if anybody could be kind to help me out a bit
Cheers,
// hjalle
quaternions myo
I am doing a project with a myo bracelet. The bracelet uses quaternions to track it's orientation. What I want is a vector that points in my forearms direction without orienation, i.e. I only want a unit vector that represents my forearm. Is this possible and does anyone know how to do this?
I have tried to perform quaternion multiplication by P' = QPQ^-1, by following the instructions on this site Maths - Transforming Vectors with Quaternions` but I don't get this to work. I suspect that this is because the quaternion output from the Myo bracelet is not one single rotation but a continuously changing orientation/rotation as I move my arm/the bracelet.
Basically the data that I get from the Myo is on the form of [X,Y,Z,W] and this is changing as I move my arm. I would highly appreciate if anybody could be kind to help me out a bit
Cheers,
// hjalle
quaternions myo
quaternions myo
edited Nov 23 '18 at 14:32
molleweide
asked Nov 23 '18 at 9:06
molleweidemolleweide
145
145
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
It sounds like you're trying to get the Euler angles from the quaternion, so this reference might be a better starting point. The hello-myo example from the Myo SDK documentation (part of the SDK download here) uses the following code:
// Calculate Euler angles (roll, pitch, and yaw) from the unit quaternion.
float roll = atan2(2.0f * (quat.w() * quat.x() + quat.y() * quat.z()), 1.0f - 2.0f * (quat.x() * quat.x() + quat.y() * quat.y()));
float pitch = asin(max(-1.0f, min(1.0f, 2.0f * (quat.w() * quat.y() - quat.z() * quat.x()))));
float yaw = atan2(2.0f * (quat.w() * quat.z() + quat.x() * quat.y()), 1.0f - 2.0f * (quat.y() * quat.y() + quat.z() * quat.z()));
Unrelated to the above and not sure if it'll be helpful, but if you're trying to locate the arm in the real world you'll always need a known reference or starting orientation, then compare all of the following measurements to that. With Myo this is typically done by having the wearer put their arm in a known position and hitting a calibration button. Sometimes there are more clever ways of doing this but it depends on the application. Once you have the reference you would subtract it from the future measurement to get the real orientation, essentially: orientationReal = orientationMeasured - orientationReference You'll typically want to do this calculation in quaternion format first (see Gimbal lock) but depending on your application maybe euler angles would be OK.
Dude thanks a lot, I have never realized that only using PITCH and YAW would give me the unit vector. Jesus christ I have been thinking about this for so long. Thank you so much Scott!
– molleweide
Nov 24 '18 at 8:11
Glad I could help! If you feel I've answered the question please mark the answer as accepted. Cheers!
– Scott Greenberg
Nov 25 '18 at 15:00
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53443536%2fmyo-bracelet-how-go-from-quaternion-to-forearm-direction-unit-vector%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It sounds like you're trying to get the Euler angles from the quaternion, so this reference might be a better starting point. The hello-myo example from the Myo SDK documentation (part of the SDK download here) uses the following code:
// Calculate Euler angles (roll, pitch, and yaw) from the unit quaternion.
float roll = atan2(2.0f * (quat.w() * quat.x() + quat.y() * quat.z()), 1.0f - 2.0f * (quat.x() * quat.x() + quat.y() * quat.y()));
float pitch = asin(max(-1.0f, min(1.0f, 2.0f * (quat.w() * quat.y() - quat.z() * quat.x()))));
float yaw = atan2(2.0f * (quat.w() * quat.z() + quat.x() * quat.y()), 1.0f - 2.0f * (quat.y() * quat.y() + quat.z() * quat.z()));
Unrelated to the above and not sure if it'll be helpful, but if you're trying to locate the arm in the real world you'll always need a known reference or starting orientation, then compare all of the following measurements to that. With Myo this is typically done by having the wearer put their arm in a known position and hitting a calibration button. Sometimes there are more clever ways of doing this but it depends on the application. Once you have the reference you would subtract it from the future measurement to get the real orientation, essentially: orientationReal = orientationMeasured - orientationReference You'll typically want to do this calculation in quaternion format first (see Gimbal lock) but depending on your application maybe euler angles would be OK.
Dude thanks a lot, I have never realized that only using PITCH and YAW would give me the unit vector. Jesus christ I have been thinking about this for so long. Thank you so much Scott!
– molleweide
Nov 24 '18 at 8:11
Glad I could help! If you feel I've answered the question please mark the answer as accepted. Cheers!
– Scott Greenberg
Nov 25 '18 at 15:00
add a comment |
It sounds like you're trying to get the Euler angles from the quaternion, so this reference might be a better starting point. The hello-myo example from the Myo SDK documentation (part of the SDK download here) uses the following code:
// Calculate Euler angles (roll, pitch, and yaw) from the unit quaternion.
float roll = atan2(2.0f * (quat.w() * quat.x() + quat.y() * quat.z()), 1.0f - 2.0f * (quat.x() * quat.x() + quat.y() * quat.y()));
float pitch = asin(max(-1.0f, min(1.0f, 2.0f * (quat.w() * quat.y() - quat.z() * quat.x()))));
float yaw = atan2(2.0f * (quat.w() * quat.z() + quat.x() * quat.y()), 1.0f - 2.0f * (quat.y() * quat.y() + quat.z() * quat.z()));
Unrelated to the above and not sure if it'll be helpful, but if you're trying to locate the arm in the real world you'll always need a known reference or starting orientation, then compare all of the following measurements to that. With Myo this is typically done by having the wearer put their arm in a known position and hitting a calibration button. Sometimes there are more clever ways of doing this but it depends on the application. Once you have the reference you would subtract it from the future measurement to get the real orientation, essentially: orientationReal = orientationMeasured - orientationReference You'll typically want to do this calculation in quaternion format first (see Gimbal lock) but depending on your application maybe euler angles would be OK.
Dude thanks a lot, I have never realized that only using PITCH and YAW would give me the unit vector. Jesus christ I have been thinking about this for so long. Thank you so much Scott!
– molleweide
Nov 24 '18 at 8:11
Glad I could help! If you feel I've answered the question please mark the answer as accepted. Cheers!
– Scott Greenberg
Nov 25 '18 at 15:00
add a comment |
It sounds like you're trying to get the Euler angles from the quaternion, so this reference might be a better starting point. The hello-myo example from the Myo SDK documentation (part of the SDK download here) uses the following code:
// Calculate Euler angles (roll, pitch, and yaw) from the unit quaternion.
float roll = atan2(2.0f * (quat.w() * quat.x() + quat.y() * quat.z()), 1.0f - 2.0f * (quat.x() * quat.x() + quat.y() * quat.y()));
float pitch = asin(max(-1.0f, min(1.0f, 2.0f * (quat.w() * quat.y() - quat.z() * quat.x()))));
float yaw = atan2(2.0f * (quat.w() * quat.z() + quat.x() * quat.y()), 1.0f - 2.0f * (quat.y() * quat.y() + quat.z() * quat.z()));
Unrelated to the above and not sure if it'll be helpful, but if you're trying to locate the arm in the real world you'll always need a known reference or starting orientation, then compare all of the following measurements to that. With Myo this is typically done by having the wearer put their arm in a known position and hitting a calibration button. Sometimes there are more clever ways of doing this but it depends on the application. Once you have the reference you would subtract it from the future measurement to get the real orientation, essentially: orientationReal = orientationMeasured - orientationReference You'll typically want to do this calculation in quaternion format first (see Gimbal lock) but depending on your application maybe euler angles would be OK.
It sounds like you're trying to get the Euler angles from the quaternion, so this reference might be a better starting point. The hello-myo example from the Myo SDK documentation (part of the SDK download here) uses the following code:
// Calculate Euler angles (roll, pitch, and yaw) from the unit quaternion.
float roll = atan2(2.0f * (quat.w() * quat.x() + quat.y() * quat.z()), 1.0f - 2.0f * (quat.x() * quat.x() + quat.y() * quat.y()));
float pitch = asin(max(-1.0f, min(1.0f, 2.0f * (quat.w() * quat.y() - quat.z() * quat.x()))));
float yaw = atan2(2.0f * (quat.w() * quat.z() + quat.x() * quat.y()), 1.0f - 2.0f * (quat.y() * quat.y() + quat.z() * quat.z()));
Unrelated to the above and not sure if it'll be helpful, but if you're trying to locate the arm in the real world you'll always need a known reference or starting orientation, then compare all of the following measurements to that. With Myo this is typically done by having the wearer put their arm in a known position and hitting a calibration button. Sometimes there are more clever ways of doing this but it depends on the application. Once you have the reference you would subtract it from the future measurement to get the real orientation, essentially: orientationReal = orientationMeasured - orientationReference You'll typically want to do this calculation in quaternion format first (see Gimbal lock) but depending on your application maybe euler angles would be OK.
edited Nov 25 '18 at 14:58
answered Nov 23 '18 at 16:02
Scott GreenbergScott Greenberg
464
464
Dude thanks a lot, I have never realized that only using PITCH and YAW would give me the unit vector. Jesus christ I have been thinking about this for so long. Thank you so much Scott!
– molleweide
Nov 24 '18 at 8:11
Glad I could help! If you feel I've answered the question please mark the answer as accepted. Cheers!
– Scott Greenberg
Nov 25 '18 at 15:00
add a comment |
Dude thanks a lot, I have never realized that only using PITCH and YAW would give me the unit vector. Jesus christ I have been thinking about this for so long. Thank you so much Scott!
– molleweide
Nov 24 '18 at 8:11
Glad I could help! If you feel I've answered the question please mark the answer as accepted. Cheers!
– Scott Greenberg
Nov 25 '18 at 15:00
Dude thanks a lot, I have never realized that only using PITCH and YAW would give me the unit vector. Jesus christ I have been thinking about this for so long. Thank you so much Scott!
– molleweide
Nov 24 '18 at 8:11
Dude thanks a lot, I have never realized that only using PITCH and YAW would give me the unit vector. Jesus christ I have been thinking about this for so long. Thank you so much Scott!
– molleweide
Nov 24 '18 at 8:11
Glad I could help! If you feel I've answered the question please mark the answer as accepted. Cheers!
– Scott Greenberg
Nov 25 '18 at 15:00
Glad I could help! If you feel I've answered the question please mark the answer as accepted. Cheers!
– Scott Greenberg
Nov 25 '18 at 15:00
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53443536%2fmyo-bracelet-how-go-from-quaternion-to-forearm-direction-unit-vector%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown