-
Notifications
You must be signed in to change notification settings - Fork 311
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
fix: adds gazebo gravity vector to the gravity calculation #177
fix: adds gazebo gravity vector to the gravity calculation #177
Conversation
This commit adds a temporary gravity compensation hotfix for the controllering the `franka_gazebo` simulation (see frankaemika/franka_ros#160). Can be removed if frankaemika/franka_ros#177 is 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.
Thank you for this improvement @rickstaa, definitely makes sense!
I could imagine use cases, though, where you want to provide custom directions/strengths for the gravity vector. For example one might want to simulate their controller if the robot is in free space. For that the gravity in Gazebo would be set to zero. The Master Controller of the real robot always compensates the gravity by ~9.81 m/s^2, which the controller of such user would need to account for.
Other use cases from the top of my head:
- Simulation of the Robot mounted non-tabletop, say on a wall
- Simulation of the robot on different places with different strengths of gravity vectors (poles, equator...)
To encompass these use cases as well, we need a way to specify if franka_hw_sim
should use the gravity vector from Gazebo or a custom one.
My suggestion would be to make this configurable by ROS parameter. When the parameter is set, then this would be taken as gravity vector. If it is missing, then we could read it from Gazebo. This would also make a good default IMO.
If you agree with this approach, I would like to ask you to implement this. For reference you can have a look at FrankaHWSim::readParameter()
(probably the place, where this logic belongs as well):
87a7864
to
f35b14a
Compare
I like your suggestion. I will add it to this pull request. |
b90980e
to
6ba5602
Compare
franka_gazebo/src/franka_hw_sim.cpp
Outdated
@@ -331,7 +336,7 @@ void FrankaHWSim::writeSim(ros::Time /*time*/, ros::Duration /*period*/) { | |||
|
|||
void FrankaHWSim::eStopActive(bool /* active */) {} | |||
|
|||
bool FrankaHWSim::readParameters(const ros::NodeHandle& nh, const urdf::Model& urdf) { | |||
auto FrankaHWSim::readParameters(const ros::NodeHandle& nh, const urdf::Model& urdf) -> bool { |
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.
Automatically applied by clang-tidy.
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.
the const in the for loop can stay, however the trailing return types, look just look ugly imo. We currently use clang-tidy 7 in the CI. There are lots of things that could be fixed with a newer version of clang-tidy, however there are other lints like modernize-use-trailing-return-type or readability-function-cognitive-complexity that you do not want to have. Therefore, we currently stick to clang-tidy 7.
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.
Strange that the extension does not pick up the right clang-tidy config. I reverted the clang-tidy changes manually.
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 is because we include modernize* and readability*, so if new checks appear they will be included by default. Thats why you need to choose the correct clang-tidy version, so just use clang-tidy 7.
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.
Ah over overlooked that in your previous answer. I'm on clang-tidy 10.
franka_gazebo/src/franka_hw_sim.cpp
Outdated
ros::NodeHandle model_nh, | ||
gazebo::physics::ModelPtr parent, | ||
const urdf::Model* const urdf, | ||
std::vector<transmission_interface::TransmissionInfo> transmissions) { | ||
std::vector<transmission_interface::TransmissionInfo> transmissions) -> bool { |
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.
Automatically applied by clang-tidy. I can remove the automatic clang-tidy changes if you want.
franka_gazebo/src/franka_hw_sim.cpp
Outdated
@@ -200,7 +205,7 @@ void FrankaHWSim::initFrankaModelHandle( | |||
" joints were found beneath the <transmission> tag, but 2 are required."); | |||
} | |||
|
|||
for (auto& joint : transmission.joints_) { | |||
for (const auto & joint : transmission.joints_) { |
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.
Automatically applied by clang-tidy.
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.
There is a space between the auto and the &. Actually this should not pass the CI 🤔
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.
Ah, that's strange.
I also noticed that the clang-tidy vscode doesn't take that rule into account when formatting. This can of course be a bug with the extensions and not the .clang-tidy
config. If it is a bug in the extension it will probably be fixed when the C++ extension adds clang-tidy support (see microsoft/vscode-cpptools#2908).
5f6cacd
to
e49dc35
Compare
I vote for |
e49dc35
to
211ff3d
Compare
This commit adds the 'gravity_vector' ROS parameter. This parameter can be used to set the gravity vector used in the FrankaHWSim. If the 'g_vector' parameter is not set the gravity vector will be retrieved from Gazebo.
211ff3d
to
53a9be0
Compare
Great I updated the code to reflect that change. |
Thanks a lot for merging this! |
…o develop * commit 'bcd58208ce0b003e6621ad211139b2e9b545fecb': add catkin_install_python to CMakeLists.txt to generate proper shebang headers
This pull request makes sure that the gravity calculation uses the gravity vector that comes from the Gazebo simulation.
In the old version the default value set in the model_base.h class was used (i.e.
[0, 0, -9.81]
) while gazebo uses the following gravity vector[0, 0, -9.8000000000000007]
.franka_ros/franka_hw/include/franka_hw/model_base.h
Lines 236 to 238 in 1922fc9
This is because the
gravity_earth
argument is not used.franka_ros/franka_gazebo/src/franka_hw_sim.cpp
Line 306 in 1922fc9
Other todos