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

output velocity and angular velocity in a ModelTask's link export #31

Merged
merged 2 commits into from
Jan 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tasks/ModelTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,20 +243,36 @@ void ModelTask::updateLinks(base::Time const& time)
}

math::Pose source2world = math::Pose::Zero;
math::Vector3 sourceInWorld_linear_vel = math::Vector3::Zero;
math::Vector3 source_angular_vel;
if (it->second.source_link_ptr)
{
source2world = it->second.source_link_ptr->GetWorldPose();
sourceInWorld_linear_vel = it->second.source_link_ptr->GetWorldLinearVel();
source_angular_vel = it->second.source_link_ptr->GetRelativeAngularVel();
}

math::Pose target2world = math::Pose::Zero;
if (it->second.target_link_ptr)
target2world = it->second.target_link_ptr->GetWorldPose();

math::Pose source2target( math::Pose(source2world - target2world) );
math::Vector3 sourceInTarget_linear_vel (target2world.rot.RotateVectorReverse(sourceInWorld_linear_vel));
Copy link
Contributor

Choose a reason for hiding this comment

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

It should not consider the velocities of the targetInWorld as well?
(I know that the target frame is usually a fixed point, but is this always the case?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know that the target frame is usually a fixed point, but is this always the case?

I elected to generate the velocity of the source frame within the target frame considered-as a fixed frame at time t. Part for simplicity reasons, part because it's a possible convention, part because then one can use it with sourceFrame==targetFrame to get both velocities expressed in the body frame.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright.

I just have doubt about the use of sourceFrame==targetFrame.
It means that we interpret the velocities as absolute (velocities of the sourceFrame related to a inertial frame, not the targetFrame) and represent them in targetFrame (for linear case) and sourceFrame (angular case).

The relative velocities of the sourceFrame related to the targetFrame should be zero if they are the same.


RigidBodyState rbs;
rbs.sourceFrame = it->second.source_frame;
rbs.targetFrame = it->second.target_frame;
rbs.position = base::Vector3d(
source2target.pos.x,source2target.pos.y,source2target.pos.z);
rbs.cov_position = _cov_position;
rbs.orientation = base::Quaterniond(
source2target.rot.w,source2target.rot.x,source2target.rot.y,source2target.rot.z );
rbs.cov_orientation = _cov_orientation;
rbs.velocity = base::Vector3d(
sourceInTarget_linear_vel.x,sourceInTarget_linear_vel.y,sourceInTarget_linear_vel.z);
rbs.cov_velocity = _cov_velocity;
rbs.angular_velocity = base::Vector3d(
source_angular_vel.x,source_angular_vel.y,source_angular_vel.z);
rbs.time = time;
it->second.port->write(rbs);
it->second.last_update = time;
Expand Down