diff --git a/turtlebot3_gazebo/models/turtlebot3_dqn_world/obstacle_plugin/obstacle1.cc b/turtlebot3_gazebo/models/turtlebot3_dqn_world/obstacle_plugin/obstacle1.cc index b61344e5..56ea6cb9 100644 --- a/turtlebot3_gazebo/models/turtlebot3_dqn_world/obstacle_plugin/obstacle1.cc +++ b/turtlebot3_gazebo/models/turtlebot3_dqn_world/obstacle_plugin/obstacle1.cc @@ -24,70 +24,68 @@ namespace gazebo { - class Obstacle1: public ModelPlugin - { +class Obstacle1: public ModelPlugin +{ public: - void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/) - { - // Store the pointer to the model - this->model = _parent; - - // create the animation - gazebo::common::PoseAnimationPtr anim( - // name the animation "move_1", - // make it last 260 seconds, - // and set it on a repeat loop - new gazebo::common::PoseAnimation("move1", 160.0, true)); + void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/) + { + // Store the pointer to the model + this->model = _parent; - gazebo::common::PoseKeyFrame * key; + // create the animation + gazebo::common::PoseAnimationPtr anim( + // name the animation "move_1", + // make it last 260 seconds, + // and set it on a repeat loop + new gazebo::common::PoseAnimation("move1", 160.0, true)); - // set starting location of the box - key = anim->CreateKeyFrame(0); - key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + gazebo::common::PoseKeyFrame * key; - key = anim->CreateKeyFrame(10); - key->Translation(ignition::math::Vector3d(-0.5, -1.0, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + // set starting location of the box + key = anim->CreateKeyFrame(0); + key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(50); - key->Translation(ignition::math::Vector3d(-3.5, -1.0, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + key = anim->CreateKeyFrame(10); + key->Translation(ignition::math::Vector3d(-0.5, -1.0, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(70); - key->Translation(ignition::math::Vector3d(-3.7, -3.0, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + key = anim->CreateKeyFrame(50); + key->Translation(ignition::math::Vector3d(-3.5, -1.0, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(90); - key->Translation(ignition::math::Vector3d(-3.5, -1.0, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + key = anim->CreateKeyFrame(70); + key->Translation(ignition::math::Vector3d(-3.7, -3.0, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(130); - key->Translation(ignition::math::Vector3d(-0.5, -1.0, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + key = anim->CreateKeyFrame(90); + key->Translation(ignition::math::Vector3d(-3.5, -1.0, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(140); - key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + key = anim->CreateKeyFrame(130); + key->Translation(ignition::math::Vector3d(-0.5, -1.0, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(160); - key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + key = anim->CreateKeyFrame(140); + key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - // set the animation - _parent->SetAnimation(anim); - } + key = anim->CreateKeyFrame(160); + key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - // Pointer to the model + // set the animation + _parent->SetAnimation(anim); + } +// Pointer to the model private: - physics::ModelPtr model; + physics::ModelPtr model; // Pointer to the update event connection - private: - event::ConnectionPtr updateConnection; - }; - // Register this plugin with the simulator - GZ_REGISTER_MODEL_PLUGIN(Obstacle1) -} // namespace gazebo + event::ConnectionPtr updateConnection; +}; +// Register this plugin with the simulator +GZ_REGISTER_MODEL_PLUGIN(Obstacle1) +}// namespace gazebo diff --git a/turtlebot3_gazebo/models/turtlebot3_dqn_world/obstacle_plugin/obstacle2.cc b/turtlebot3_gazebo/models/turtlebot3_dqn_world/obstacle_plugin/obstacle2.cc index 301ccbcf..84050abc 100644 --- a/turtlebot3_gazebo/models/turtlebot3_dqn_world/obstacle_plugin/obstacle2.cc +++ b/turtlebot3_gazebo/models/turtlebot3_dqn_world/obstacle_plugin/obstacle2.cc @@ -24,85 +24,84 @@ namespace gazebo { - class Obstacle2: public ModelPlugin - { +class Obstacle2: public ModelPlugin +{ public: - void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/) - { - // Store the pointer to the model - this->model = _parent; - - // create the animation - gazebo::common::PoseAnimationPtr anim( - // name the animation "move_2", - // make it last 260 seconds, - // and set it on a repeat loop - new gazebo::common::PoseAnimation("move2", 140.0, true)); + void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/) + { + // Store the pointer to the model + this->model = _parent; - gazebo::common::PoseKeyFrame * key; + // create the animation + gazebo::common::PoseAnimationPtr anim( + // name the animation "move_2", + // make it last 260 seconds, + // and set it on a repeat loop + new gazebo::common::PoseAnimation("move2", 140.0, true)); - // set starting location of the box - key = anim->CreateKeyFrame(0); - key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + gazebo::common::PoseKeyFrame * key; - key = anim->CreateKeyFrame(10); - key->Translation(ignition::math::Vector3d(0.7, 0.2, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + // set starting location of the box + key = anim->CreateKeyFrame(0); + key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(40); - key->Translation(ignition::math::Vector3d(2.5, 3.5, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + key = anim->CreateKeyFrame(10); + key->Translation(ignition::math::Vector3d(0.7, 0.2, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(55); - key->Translation(ignition::math::Vector3d(0.3, 3.5, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + key = anim->CreateKeyFrame(40); + key->Translation(ignition::math::Vector3d(2.5, 3.5, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(85); - key->Translation(ignition::math::Vector3d(3.5, 1.8, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + key = anim->CreateKeyFrame(55); + key->Translation(ignition::math::Vector3d(0.3, 3.5, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(100); - key->Translation(ignition::math::Vector3d(3.5, 0.0, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + key = anim->CreateKeyFrame(85); + key->Translation(ignition::math::Vector3d(3.5, 1.8, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(110); - key->Translation(ignition::math::Vector3d(2.0, 0.5, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + key = anim->CreateKeyFrame(100); + key->Translation(ignition::math::Vector3d(3.5, 0.0, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(115); - key->Translation(ignition::math::Vector3d(1.5, 1.0, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + key = anim->CreateKeyFrame(110); + key->Translation(ignition::math::Vector3d(2.0, 0.5, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(120); - key->Translation(ignition::math::Vector3d(1.0, 0.5, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + key = anim->CreateKeyFrame(115); + key->Translation(ignition::math::Vector3d(1.5, 1.0, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(125); - key->Translation(ignition::math::Vector3d(0.5, 0.1, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + key = anim->CreateKeyFrame(120); + key->Translation(ignition::math::Vector3d(1.0, 0.5, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(130); - key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + key = anim->CreateKeyFrame(125); + key->Translation(ignition::math::Vector3d(0.5, 0.1, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(140); - key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + key = anim->CreateKeyFrame(130); + key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - // set the animation - _parent->SetAnimation(anim); - } + key = anim->CreateKeyFrame(140); + key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - // Pointer to the model + // set the animation + _parent->SetAnimation(anim); + } +// Pointer to the model private: - physics::ModelPtr model; - // Pointer to the update event connection + physics::ModelPtr model; +// Pointer to the update event connection private: - event::ConnectionPtr updateConnection; - }; - // Register this plugin with the simulator - GZ_REGISTER_MODEL_PLUGIN(Obstacle2) -} // namespace gazebo + event::ConnectionPtr updateConnection; +}; +// Register this plugin with the simulator +GZ_REGISTER_MODEL_PLUGIN(Obstacle2) +}// namespace gazebo diff --git a/turtlebot3_gazebo/models/turtlebot3_dqn_world/obstacle_plugin/obstacles.cc b/turtlebot3_gazebo/models/turtlebot3_dqn_world/obstacle_plugin/obstacles.cc index 389a1c65..185766e6 100644 --- a/turtlebot3_gazebo/models/turtlebot3_dqn_world/obstacle_plugin/obstacles.cc +++ b/turtlebot3_gazebo/models/turtlebot3_dqn_world/obstacle_plugin/obstacles.cc @@ -26,49 +26,48 @@ namespace gazebo { - class Obstacles: public ModelPlugin - { +class Obstacles: public ModelPlugin +{ public: - void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/) - { - // Store the pointer to the model - this->model = _parent; - - // create the animation - gazebo::common::PoseAnimationPtr anim( - // name the animation "move", - // make it last 40 seconds, - // and set it on a repeat loop - new gazebo::common::PoseAnimation("move", 40.0, true)); + void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/) + { + // Store the pointer to the model + this->model = _parent; - gazebo::common::PoseKeyFrame * key; + // create the animation + gazebo::common::PoseAnimationPtr anim( + // name the animation "move", + // make it last 40 seconds, + // and set it on a repeat loop + new gazebo::common::PoseAnimation("move", 40.0, true)); - // set starting location of the box - key = anim->CreateKeyFrame(0); - key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 0)); + gazebo::common::PoseKeyFrame * key; - key = anim->CreateKeyFrame(20); - key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, PI)); + // set starting location of the box + key = anim->CreateKeyFrame(0); + key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 0)); - key = anim->CreateKeyFrame(40); - key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); - key->Rotation(ignition::math::Quaterniond(0, 0, 2 * PI)); + key = anim->CreateKeyFrame(20); + key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, PI)); - // set the animation - _parent->SetAnimation(anim); - } + key = anim->CreateKeyFrame(40); + key->Translation(ignition::math::Vector3d(0.0, 0.0, 0.0)); + key->Rotation(ignition::math::Quaterniond(0, 0, 2 * PI)); - // Pointer to the model + // set the animation + _parent->SetAnimation(anim); + } +// Pointer to the model private: - physics::ModelPtr model; - // Pointer to the update event connection + physics::ModelPtr model; +// Pointer to the update event connection private: - event::ConnectionPtr updateConnection; - }; + event::ConnectionPtr updateConnection; +}; // Register this plugin with the simulator - GZ_REGISTER_MODEL_PLUGIN(Obstacles) -} // namespace gazebo +GZ_REGISTER_MODEL_PLUGIN(Obstacles) +}// namespace gazebo