Skip to content

express the accelerations in the body frame #16

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

Merged
merged 1 commit into from
Jan 15, 2019
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
27 changes: 13 additions & 14 deletions tasks/ModelTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void ModelTask::setGazeboModel(WorldPtr _world, ModelPtr _model)
_model_frame.set(_model->GetName());
if (_world_frame.get().empty())
_world_frame.set(GzGet((*_world), Name, ()));
}
}

void ModelTask::InternalJointExport::addJoint(JointPtr joint, std::string name)
{
Expand Down Expand Up @@ -86,7 +86,7 @@ void ModelTask::setupJoints()
}
exported_joints.push_back(main_joint_export);


std::vector<JointExport> requested_exports =
_exported_joints.get();

Expand Down Expand Up @@ -337,7 +337,7 @@ void ModelTask::updateLinks(base::Time const& time)
for(auto& exported_link : link_export_setup)
{
//do not update the link if the last port writing happened
//in less then link_period.
//in less then link_period.
if (!(exported_link.last_update.isNull()))
{
if ((time - exported_link.last_update) <= exported_link.port_period)
Expand All @@ -346,16 +346,16 @@ void ModelTask::updateLinks(base::Time const& time)

Pose3d source2world = Pose3d::Zero;
Vector3d sourceInWorld_linear_vel = Vector3d::Zero;
Vector3d source_angular_vel = Vector3d::Zero;
Vector3d sourceInWorld_linear_acc = Vector3d::Zero;
Vector3d source_angular_acc = Vector3d::Zero;
Vector3d sourceRelative_angular_vel = Vector3d::Zero;
Vector3d sourceRelative_linear_acc = Vector3d::Zero;
Vector3d sourceRelative_angular_acc = Vector3d::Zero;
if (exported_link.source_link_ptr)
{
source2world = GzGetIgn((*(exported_link.source_link_ptr)), WorldPose, ());
sourceInWorld_linear_vel = GzGetIgn((*(exported_link.source_link_ptr)), WorldLinearVel, ());
source_angular_vel = GzGetIgn((*(exported_link.source_link_ptr)), RelativeAngularVel, ());
sourceInWorld_linear_acc = GzGetIgn((*(exported_link.source_link_ptr)), WorldLinearAccel, ());
source_angular_acc = GzGetIgn((*(exported_link.source_link_ptr)), RelativeAngularAccel, ());
sourceInWorld_linear_vel = GzGetIgn((*(exported_link.source_link_ptr)), WorldLinearVel, ());
sourceRelative_angular_vel = GzGetIgn((*(exported_link.source_link_ptr)), RelativeAngularVel, ());
sourceRelative_linear_acc = GzGetIgn((*(exported_link.source_link_ptr)), RelativeLinearAccel, ());
sourceRelative_angular_acc = GzGetIgn((*(exported_link.source_link_ptr)), RelativeAngularAccel, ());
}

Pose3d target2world = Pose3d::Zero;
Expand All @@ -364,7 +364,6 @@ void ModelTask::updateLinks(base::Time const& time)

Pose3d source2target( Pose3d(source2world - target2world) );
Vector3d sourceInTarget_linear_vel (target2world.Rot().RotateVectorReverse(sourceInWorld_linear_vel));
Vector3d sourceInTarget_linear_acc (target2world.Rot().RotateVectorReverse(sourceInWorld_linear_acc));

RigidBodyState rbs;
rbs.sourceFrame = exported_link.source_frame;
Expand All @@ -379,17 +378,17 @@ void ModelTask::updateLinks(base::Time const& time)
sourceInTarget_linear_vel.X(),sourceInTarget_linear_vel.Y(),sourceInTarget_linear_vel.Z());
rbs.cov_velocity = exported_link.cov_velocity;
rbs.angular_velocity = base::Vector3d(
source_angular_vel.X(),source_angular_vel.Y(),source_angular_vel.Z());
sourceRelative_angular_vel.X(),sourceRelative_angular_vel.Y(),sourceRelative_angular_vel.Z());
rbs.cov_angular_velocity = exported_link.cov_angular_velocity;
rbs.time = time;
exported_link.port->write(rbs);

base::samples::RigidBodyAcceleration rba;
rba.cov_acceleration = exported_link.cov_acceleration;
rba.acceleration = base::Vector3d(
sourceInTarget_linear_acc.X(),sourceInTarget_linear_acc.Y(),sourceInTarget_linear_acc.Z());
sourceRelative_linear_acc.X(),sourceRelative_linear_acc.Y(),sourceRelative_linear_acc.Z());
rba.angular_acceleration = base::Vector3d(
source_angular_acc.X(),source_angular_acc.Y(),source_angular_acc.Z());
sourceRelative_angular_acc.X(),sourceRelative_angular_acc.Y(),sourceRelative_angular_acc.Z());
rba.cov_angular_acceleration = exported_link.cov_angular_acceleration;
rba.time = time;
exported_link.rba_port->write(rba);
Expand Down