-
Notifications
You must be signed in to change notification settings - Fork 277
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
Set link velocity from set_model_state
plugin
#2440
Set link velocity from set_model_state
plugin
#2440
Conversation
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
…onents Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
@@ -0,0 +1,48 @@ | |||
/* | |||
* Copyright (C) 2019 Open Source Robotics Foundation |
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.
* Copyright (C) 2019 Open Source Robotics Foundation | |
* Copyright (C) 2024 Open Source Robotics Foundation |
*/ | ||
#ifndef GZ_SIM_COMPONENTS_WORLDANGULARVELOCITYRESET_HH_ | ||
#define GZ_SIM_COMPONENTS_WORLDANGULARELOCITYRESET_HH_ | ||
#include <vector> |
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.
remove, this is not used in this header
@@ -0,0 +1,48 @@ | |||
/* | |||
* Copyright (C) 2019 Open Source Robotics Foundation |
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.
* Copyright (C) 2019 Open Source Robotics Foundation | |
* Copyright (C) 2024 Open Source Robotics Foundation |
*/ | ||
#ifndef GZ_SIM_COMPONENTS_WORLDLINEARVELOCITYRESET_HH_ | ||
#define GZ_SIM_COMPONENTS_WORLDLINEARVELOCITYRESET_HH_ | ||
#include <vector> |
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.
remove, this is not used in this header
src/systems/physics/Physics.cc
Outdated
@@ -2591,7 +2593,7 @@ void PhysicsPrivate::UpdatePhysics(EntityComponentManager &_ecm) | |||
return true; | |||
}); | |||
|
|||
// Update link linear velocity | |||
// Update link linear velocity |
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.
// Update link linear velocity | |
// Update link linear velocity |
src/systems/physics/Physics.cc
Outdated
return true; | ||
|
||
auto rootLinkPtr = freeGroup->RootLink(); | ||
if(rootLinkPtr != linkPtrPhys){ |
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(rootLinkPtr != linkPtrPhys){ | |
if(rootLinkPtr != linkPtrPhys) | |
{ |
src/systems/physics/Physics.cc
Outdated
gzwarn << "Attempting to set angular velocity for link ["<< _entity | ||
<<"] which is not root link of the FreeGroup." | ||
<<"Velocity won't be set."<< std::endl; |
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.
gzwarn << "Attempting to set angular velocity for link ["<< _entity | |
<<"] which is not root link of the FreeGroup." | |
<<"Velocity won't be set."<< std::endl; | |
gzwarn << "Attempting to set angular velocity for link [ " << _entity | |
<< " ] which is not root link of the FreeGroup." | |
<< "Velocity won't be set." << std::endl; |
src/systems/physics/Physics.cc
Outdated
gzdbg << "Attempting to set link angular velocity, but the " | ||
<< "physics engine doesn't support velocity commands. " | ||
<< "Velocity won't be set." | ||
<< std::endl; |
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.
gzdbg << "Attempting to set link angular velocity, but the " | |
<< "physics engine doesn't support velocity commands. " | |
<< "Velocity won't be set." | |
<< std::endl; | |
gzdbg << "Attempting to set link angular velocity, but the " | |
<< "physics engine doesn't support velocity commands. " | |
<< "Velocity won't be set." | |
<< std::endl; |
|
||
|
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.
remove
} | ||
} | ||
|
||
} |
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.
wierd indentation
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
Hi Alejandro, I have made the required changes, can you please review them again. |
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
src/systems/physics/Physics.cc
Outdated
worldAngularVelFeature->SetWorldAngularVelocity( | ||
math::eigen3::convert(worldAngularVel)); | ||
this->angularVelocityResetFlag = true; | ||
} |
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 see that this is your logic for ensuring that the VelocityReset components are only acted on a single time, but I recommend following the method used for the JointVelocityReset
component, which is to delete the component after it has been acted on:
gz-sim/src/systems/physics/Physics.cc
Lines 3703 to 3714 in 0066023
std::vector<Entity> entitiesVelocityReset; _ecm.Each<components::JointVelocityReset>( [&](const Entity &_entity, components::JointVelocityReset *) -> bool { entitiesVelocityReset.push_back(_entity); return true; }); for (const auto entity : entitiesVelocityReset) { _ecm.RemoveComponent<components::JointVelocityReset>(entity); }
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.
for consistency with the other component header files, we could name them simply AngularVelocityReset.hh
and LinearVelocityReset.hh
. The other header files also define components without the World
prefix that refer to velocity in a body-fixed frame. We can leave a TODO
comment for now if we don't want to implement that yet
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
examples/worlds/set_model_state.sdf
Outdated
<iyz>0</iyz> | ||
<izz>5</izz> | ||
</inertia> | ||
<mass>120.0</mass> |
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 updated #2359 to use auto-inertials in the example world in 7cab1bb
I think we should use a box with 3 different dimensions rather than a cube in order to visualize the Dzhanibekov effect. I think the dimensions from the boxes benchmark test (0.1, 0.4, 0.9) and initial angular velocity with largest component in Y (0.1, 5.0, 0.1) would work well. With the updated dimensions, we could use auto-inertials as well.
examples/worlds/set_model_state.sdf
Outdated
<model_state> | ||
<link_state name="box_link"> | ||
<linear_velocity>0.1 -0.1 0.1</linear_velocity> | ||
<angular_velocity>1 2 1</angular_velocity> |
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 recommend adding a degrees
boolean attribute to //link_state/angular_velocity
to match the behavior of the //joint_state/position/@degrees
and //joint_state/velocity/@degrees
attributes. Then it would be nice to have pair of example boxes with angular velocity expressed in both deg/s and rad/s
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.
got it, I will make the changes
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
Signed-off-by: yaswanth1701 <[email protected]>
@yaswanth1701 can you open a separate pull request targeting the |
Yeah sure, I will try to do this by tomorrow. |
Signed-off-by: yaswanth1701 <[email protected]>
…pe' into scpeters/set_model_state_prototype
I just resolved conflicts since #2489 was merged |
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.
merging into my branch
set_model_state
plugin set_model_state
plugin
0adf71d
into
gazebosim:scpeters/set_model_state_prototype
🎉 New feature
Follow up PR to #2359
Summary
This PR introduces
WorldLinearVelocityReset
andWorldAngularVelocityReset
components for the LInk entity to set initial link velocities from SDF usingset_model_state
plugin. The link velocities are only set toroot link
of the FreeGroup for now.Test it
Should see the red cube moving and rotating.
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.