Skip to content
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
merged 6 commits into from
May 2, 2021

Conversation

nunoguedelha
Copy link
Collaborator

Implements #39 .
Implements #40 .

- Created the main library mwbs_lib.slx as an entry point in the Library Browser.
- Set a single `slblock.m` for the main library (covers library and sublibraries).
- Convert robotVisualizer subsystem into a sublibrary of mwbs_lib.slx.
- Make RobotDynamicsWithContacts library a sublibrary of mwbs_lib.slx.
- Split robotVisualizer init in two: one for the user inputs, another for the library
  init from those inputs.
- Prefixed the sublibraries of mwbs_lib.slx.
- Create the RobotSensors library.
- Add the block IMUsensor.
- Get the IMU frame from iCub URDF model.
- Integrate the IMU block in the main test model.
@nunoguedelha nunoguedelha self-assigned this Apr 28, 2021
@nunoguedelha nunoguedelha changed the title Feature/add visualizers n sensors libraries Add visualizers (Robot Visualizer) and sensors libraries (IMUsensor) Apr 28, 2021
@nunoguedelha nunoguedelha added the enhancement New feature or request label Apr 28, 2021
- the linear acceleration was missing the "bias" acceleration (JdotNu).
- twist angular and linear components were swapped.
@nunoguedelha nunoguedelha marked this pull request as ready for review April 30, 2021 02:07
- Reordered the measurements in the concatenated output `imuOut`.
- Improved the function documentation.
Copy link
Contributor

@traversaro traversaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on the formulas implemented for IMU and accelerometer simulations.


% Gyroscope measurements
w_imuVel = Jimu*nu;
w_omega = w_imuVel(4:6);
Copy link
Contributor

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 .

Copy link
Collaborator Author

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.

Copy link
Contributor

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

Copy link
Collaborator Author

@nunoguedelha nunoguedelha Apr 30, 2021

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.

Copy link
Collaborator Author

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 to MIXED_REPRESENTATION.

Running the following in MATLAB command line getFrameVelocityRepresentation():

>> kinDyn = iDynTree.KinDynComputations()
>> kinDyn.getFrameVelocityRepresentation
ans =
  int64
   2

returns the default value: 2 => MIXED_REPRESENTATION. We get the same value while running RobotVisualizer.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 through KinDynComputations::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 .

Copy link
Contributor

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.

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.

Copy link
Collaborator Author

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!

lib/+mwbs/+RobotSensors/+IMUsensor/IMUsensorProc.m Outdated Show resolved Hide resolved
- Properly projected the measurements on the sensor frame.
- Fixed proper acceleration measurement.
- Introduced GRAVITY_VECTOR as `IMUsensorProc()` MATLAB System parameter.
@nunoguedelha
Copy link
Collaborator Author

All fixes done.

@nunoguedelha nunoguedelha requested a review from traversaro May 1, 2021 16:28
@nunoguedelha
Copy link
Collaborator Author

For some reason, the GRAVITY_VECTOR parameter had disappeared from the IMUsensorProc() MATLAB System mask config. Restored it. merging now.

@nunoguedelha nunoguedelha merged commit f270827 into master May 2, 2021
@nunoguedelha
Copy link
Collaborator Author

@traversaro , side note: I forgot to merge this into devel. Submitting a PR in a few minutes, which will be followed by a fast-forward merge into devel.

@nunoguedelha nunoguedelha deleted the feature/add-visualizers-N-sensors-libraries branch May 6, 2021 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants