Skip to content

Commit

Permalink
Reset Gazebo with initial joint positions and velocities (#241)
Browse files Browse the repository at this point in the history
(cherry picked from commit c5b0b90)

# Conflicts:
#	ign_ros2_control/src/ign_system.cpp
  • Loading branch information
mrjogo authored and mergify[bot] committed Feb 26, 2024
1 parent 62e7663 commit 4f9c743
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions ign_ros2_control/src/ign_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,41 @@
#include <utility>
#include <vector>

<<<<<<< HEAD:ign_ros2_control/src/ign_system.cpp
=======
#ifdef GZ_HEADERS
#include <gz/msgs/imu.pb.h>

#include <gz/sim/components/AngularVelocity.hh>
#include <gz/sim/components/Imu.hh>
#include <gz/sim/components/JointForce.hh>
#include <gz/sim/components/JointForceCmd.hh>
#include <gz/sim/components/JointPosition.hh>
#include <gz/sim/components/JointPositionReset.hh>
#include <gz/sim/components/JointVelocity.hh>
#include <gz/sim/components/JointVelocityCmd.hh>
#include <gz/sim/components/JointVelocityReset.hh>
#include <gz/sim/components/LinearAcceleration.hh>
#include <gz/sim/components/Name.hh>
#include <gz/sim/components/ParentEntity.hh>
#include <gz/sim/components/Pose.hh>
#include <gz/sim/components/Sensor.hh>
#include <gz/transport/Node.hh>
#define GZ_TRANSPORT_NAMESPACE gz::transport::
#define GZ_MSGS_NAMESPACE gz::msgs::
#else
#include <ignition/msgs/imu.pb.h>

>>>>>>> c5b0b90 (Reset Gazebo with initial joint positions and velocities (#241)):gz_ros2_control/src/gz_system.cpp
#include <ignition/gazebo/components/AngularVelocity.hh>
#include <ignition/gazebo/components/Imu.hh>
#include <ignition/gazebo/components/JointForce.hh>
#include <ignition/gazebo/components/JointForceCmd.hh>
#include <ignition/gazebo/components/JointPosition.hh>
#include <ignition/gazebo/components/JointPositionReset.hh>
#include <ignition/gazebo/components/JointVelocity.hh>
#include <ignition/gazebo/components/JointVelocityCmd.hh>
#include <ignition/gazebo/components/JointVelocityReset.hh>
#include <ignition/gazebo/components/LinearAcceleration.hh>
#include <ignition/gazebo/components/Name.hh>
#include <ignition/gazebo/components/ParentEntity.hh>
Expand Down Expand Up @@ -376,9 +404,15 @@ bool IgnitionSystem::initSim(
// independently of existence of command interface set initial value if defined
if (!std::isnan(initial_position)) {
this->dataPtr->joints_[j].joint_position = initial_position;
this->dataPtr->ecm->CreateComponent(
this->dataPtr->joints_[j].sim_joint,
sim::components::JointPositionReset({initial_position}));
}
if (!std::isnan(initial_velocity)) {
this->dataPtr->joints_[j].joint_velocity = initial_velocity;
this->dataPtr->ecm->CreateComponent(
this->dataPtr->joints_[j].sim_joint,
sim::components::JointVelocityReset({initial_velocity}));
}
}

Expand Down

0 comments on commit 4f9c743

Please sign in to comment.