-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add visualizers (Robot Visualizer) and sensors libraries (IMUsensor) #41
Merged
nunoguedelha
merged 6 commits into
master
from
feature/add-visualizers-N-sensors-libraries
May 2, 2021
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
40b2cab
Convert the robotVisualizer MATLAB System into a library
nunoguedelha 7d9a114
Add RobotSensors library with the IMUsensor block
nunoguedelha d130105
Fixed IMU lin. acc. and ang. vel. "measurements"
nunoguedelha 8d3c9b2
Minor fixes in `IMUsensorProc()`
nunoguedelha 281e0e5
Fixes in `IMUsensorProc()` after PR review
nunoguedelha 05d1f61
Fixed `IMUsensorProc()` MATLAB System parameter GRAVITY_VECTOR.
nunoguedelha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
classdef IMUsensorProc < matlab.System | ||
% IMUsensorProc This block computes the typical outputs of an IMU from the base pose and joints kinematics. | ||
% | ||
% Assuming DoFs is the number of internal degrees of freedom of the robot: | ||
% | ||
% Input: | ||
% - w_H_b: Base pose, 4x4 matrix representing the homogenous transformation between the the | ||
% base frame and the world frame. | ||
% - nu: Base and joints velocities: Vector of size 6 representing the linear and angular | ||
% velocity of the base frame, concatenated with a vector of size DoFs, representing the | ||
% velocity of the joints. | ||
% - nuDot: Base and joints accelerations: Vector of size 6 representing the linear and angular | ||
% acceleration of the base frame, concatenated with a vector of size DoFs, representing the | ||
% acceleration of the joints. | ||
% - Jimu: Jacobian of the IMU frame. | ||
% - JimuDotNu: Bias linear acceleration of the IMU frame with respect to the inertial (world) | ||
% frame. | ||
% | ||
% Output: | ||
% The sensor frame orientation, linear acceleration and angular velocity w.r.t. the inertial | ||
% (world) frame. Linear acceleration and angular velocity are expressed in the world frame. | ||
% - w_rollPitchYaw: roll, pitch, yaw Euler angles in rad. | ||
% - w_linAcc: Proper linear acceleration in m/s^2. | ||
% - w_omega: Angular velocity in rad/s. | ||
% - imuOut: A [12x1] 1-D vector concatenating the previous three outputs and a placeholder for | ||
% other measurements (e.g. magnetometer). | ||
% [roll,pitch,yaw,accx,accy,accz,omegax,omegay,omegaz,0,0,0]'. | ||
% | ||
% Parameters: | ||
% - Frame name: the name of the IMU frame. It should be specified in the URDF model. | ||
|
||
% Public, tunable properties | ||
properties | ||
|
||
end | ||
|
||
properties(DiscreteState) | ||
|
||
end | ||
|
||
% Pre-computed constants | ||
properties(Access = private) | ||
|
||
end | ||
|
||
methods(Access = protected) | ||
function setupImpl(obj) | ||
% Perform one-time calculations, such as computing constants | ||
end | ||
|
||
function [imuOut,w_omega,w_linAcc,w_rollPitchYaw] = stepImpl(obj,Jimu,JimuDotNu,w_H_imu,nu,nudot) | ||
% Implement algorithm. Calculate y as a function of inputs and discrete states. | ||
|
||
% Gyroscope measurements | ||
w_imuVel = Jimu*nu; | ||
w_omega = w_imuVel(4:6); | ||
|
||
% Accelerometer measurements | ||
w_imuAcc = Jimu*nudot + JimuDotNu; | ||
w_linAcc = w_imuAcc(1:3); | ||
nunoguedelha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
% Euler angles estimation | ||
R = mwbs.State.H2Rp(w_H_imu); | ||
w_rollPitchYaw = wbc.rollPitchYawFromRotation(R); | ||
|
||
% composite sensor output | ||
imuOut = [w_rollPitchYaw; w_linAcc; w_omega; zeros(3,1)]; | ||
end | ||
|
||
function resetImpl(~) | ||
% Initialize / reset discrete-state properties | ||
end | ||
end | ||
end |
6 changes: 3 additions & 3 deletions
6
src/robotVisualizer/Visualizer.m → ...lizers/+robotVisualizer/RobotVisualizer.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
lib/+mwbs/+Visualizers/+robotVisualizer/initRobotVisualizer.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
%% configuration for the matlab iDyntree visualizer | ||
|
||
confVisualizer.modelPath = mwbs.getModelPathFromFileNameAndYarpFinder(confVisualizer.fileName); |
Binary file not shown.
File renamed without changes.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing a rotation${}^S R_A$ , where $S$ is sensor frame and $A$ is the world/absolute frame. See equation 4.3 in https://traversaro.github.io/traversaro-phd-thesis/traversaro-phd-thesis.pdf .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes Silvio, you're right. I was going to fix this later on after finishing robotology/whole-body-controllers#122, and after checking those sections in your thesis about the sensor acceleration, just to be sure I wouldn't miss anything. That's why I specified in the issue and block documentation that the quantities where expressed in the world frame. But you're right, better do be accurate right away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you like to merge as it is for me it is ok, probably better to open an issue to eventually fix it, thanks1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll push here. Just quick question @traversaro . The WBT Jacobian block output is actually the jacobian expressed in a mixed frame right? B[A], i.e. the frame with origin of B and orientation of A, where B is the specified body frame and A the inertial frame. Such that
J*nu
gives:$$
\begin{equation}
{}^{F _i[A]}\mathrm{v} _{A,F _i} = {}^{F _i[A]}R _{F _i} J _i \nu
\end{equation}
$$
Where$A$ is the inertial frame and $J_i$ is the Jacobian of body frame $F_i$ expressed in body coordinates as described in Featherstone RBDA textbook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be the case, as in KinDynComputations.cpp,
m_frameVelRepr
is set toMIXED_REPRESENTATION
.Running the following in MATLAB command line getFrameVelocityRepresentation():
returns the default value:
2
=>MIXED_REPRESENTATION
. We get the same value while runningRobotVisualizer.prepareRobot()
which loads the robot model and prepares the robot visualization through the iDynTree bindings. Assuming that the Frame Velocity Representation is not explicitely changed later on throughKinDynComputations::setFrameVelocityRepresentation
method, we can assume that the Jacobian WBT block uses that type of representation. I've opened an issue to cross check that: #42 .There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this formula, what is${}^{F _i[A]}R _{F _i}$ ? Anyway, for iDynTree convention that formula is incomplete because if you pass from the mixed jacobian to the body-fixed jacobian, also the convention used by floating base velocity in the $\nu$ vector changes, so you need to also account for that. See equation 3.70 of https://traversaro.github.io/traversaro-phd-thesis/traversaro-phd-thesis.pdf for the correct formula.
In any case, yes all WB-Toolbox bocks use
MIXED_REPRESENTATION
and i do not think there is any way to change it, so it is safe to assume that the jacobian is the mixed one according to iDynTree convention.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I meant actually${}^{F _i[A]}X _{F _i}$ instead of $R$ . And the Jacobian was already left trivialized. Nevertheless I shouldn't mention Featherstone as he addresses the fixed base casein the sections I was thinking about. Anyway, it's much clearer now for me, after reading again the respective section in your thesis. Thanks!