Skip to content

Commit

Permalink
Add support for Gazebo9
Browse files Browse the repository at this point in the history
This fixes the problem related to Gazebo's position control, which can be seen
when dropping a position-controlled robot. The issue is fixed by using the
_preserveWorldVelocity argument introduced in Gazebo 9.0.0.

https://bitbucket.org/osrf/gazebo/pull-requests/2814/fix-issue-2111-by-providing-options-to/diff

Related issue/commit in gazebo_ros_pkgs, which introduces a similar fix:

ros-simulation/gazebo_ros_pkgs@3164e4c
ros-simulation/gazebo_ros_pkgs#479
  • Loading branch information
Naoki Mizuno committed Mar 20, 2018
1 parent cf98664 commit b5b8ddc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions steer_bot_hardware_gazebo/src/steer_bot_hardware_gazebo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ namespace steer_bot_hardware_gazebo
{
pos_cmd = front_steer_jnt_pos_cmd_;
}
#if GAZEBO_MAJOR_VERSION >= 9
sim_joints_[i]->SetPosition(0, pos_cmd, true);
#else
sim_joints_[i]->SetPosition(0, pos_cmd);
#endif
}
else if(gazebo_jnt_name == virtual_front_steer_jnt_names_[INDEX_LEFT])
{
Expand All @@ -228,7 +232,11 @@ namespace steer_bot_hardware_gazebo
{
pos_cmd = 2*front_steer_jnt_pos_cmd_;
}
#if GAZEBO_MAJOR_VERSION >= 9
sim_joints_[i]->SetPosition(0, pos_cmd, true);
#else
sim_joints_[i]->SetPosition(0, pos_cmd);
#endif
}
else
{
Expand Down Expand Up @@ -461,8 +469,13 @@ namespace steer_bot_hardware_gazebo
void SteerBotHardwareGazebo::GetCurrentState(std::vector<double>& _jnt_pos, std::vector<double>& _jnt_vel, std::vector<double>& _jnt_eff,
const int _if_index, const int _sim_jnt_index)
{
#if GAZEBO_MAJOR_VERSION >= 9
_jnt_pos[_if_index] +=
angles::shortest_angular_distance(_jnt_pos[_if_index], sim_joints_[_sim_jnt_index]->Position(0u));
#else
_jnt_pos[_if_index] +=
angles::shortest_angular_distance(_jnt_pos[_if_index], sim_joints_[_sim_jnt_index]->GetAngle(0u).Radian());
#endif
_jnt_vel[_if_index] = sim_joints_[_sim_jnt_index]->GetVelocity(0u);
_jnt_eff[_if_index] = sim_joints_[_sim_jnt_index]->GetForce(0u);
}
Expand Down

0 comments on commit b5b8ddc

Please sign in to comment.