Skip to content

Commit

Permalink
fix: adds gazebo gravity vector to the gravity calculation
Browse files Browse the repository at this point in the history
This commit makes sure that the gravity calculation uses the gravity
values of gazebo instead of using the default values.
  • Loading branch information
rickstaa committed Nov 3, 2021
1 parent 7558302 commit 87a7864
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 0.x - UNRELEASED

* Fix Gazebo simulation gravity compensation gravity vector
* Add realistic hand/finger collision geometries to the Gazebo robot description
* Add `joint_state_desired` publisher to `franka_gazebo`
* No further ROS Kinetic support, since [End-of-Life was in April 2021](http://wiki.ros.org/Distributions)
Expand Down
2 changes: 2 additions & 0 deletions franka_gazebo/include/franka_gazebo/franka_hw_sim.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class FrankaHWSim : public gazebo_ros_control::RobotHWSim {
void eStopActive(const bool active) override;

private:
std::array<double, 3> gravity_earth_;

std::string arm_id_;
gazebo::physics::ModelPtr robot_;
std::map<std::string, std::shared_ptr<franka_gazebo::Joint>> joints_;
Expand Down
6 changes: 5 additions & 1 deletion franka_gazebo/src/franka_hw_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ bool FrankaHWSim::initSim(const std::string& robot_namespace,

ROS_INFO_STREAM_NAMED("franka_hw_sim", "Using physics type " << physics->GetType());

// Retrieve physics parameters
auto gravity = physics->World()->Gravity();
this->gravity_earth_ = {gravity.X(), gravity.Y(), gravity.Z()};

// Generate a list of franka_gazebo::Joint to store all relevant information
for (const auto& transmission : transmissions) {
if (transmission.type_ != "transmission_interface/SimpleTransmission") {
Expand Down Expand Up @@ -307,7 +311,7 @@ void FrankaHWSim::readSim(ros::Time time, ros::Duration period) {
}

void FrankaHWSim::writeSim(ros::Time /*time*/, ros::Duration /*period*/) {
auto g = this->model_->gravity(this->robot_state_);
auto g = this->model_->gravity(this->robot_state_, this->gravity_earth_);

for (auto& pair : this->joints_) {
auto joint = pair.second;
Expand Down

0 comments on commit 87a7864

Please sign in to comment.