Gazebo | Ignition | Community
Ask Your Question
0

plugin for actor to follow particular trajectory

asked 2021-03-30 12:46:45 -0500

updated 2021-03-31 00:17:38 -0500

By referring to this file ActorPlugin.hh in Gazebo, I am trying to migrate this into ignition gazebo using ROS for my application.

OS/Environment: Ubuntu 18.04 LTS (Installed on MacOSX using Virtual Machine)

Source/binary: Ignition-4 (binary files)

Unfortunately, my header file (code is given below) throws some syntax error.

Error:

<source-file, line>: error: ‘std::chrono::steady_clock’ has not been declared

Code:

#include <string>
#include <fstream>
#include <queue>
#include <vector>
#include <chrono>


#include <ignition/math/Pose3.hh>
#include <ignition/math/Quaternion.hh>
#include <ignition/math/Vector3.hh>

#include <ros/ros.h>
#include <ros/package.h>
#include <ros/callback_queue.h>

#include <std_msgs/String.h>

#include <ignition/gazebo/Model.hh>
#include <ignition/gazebo/EntityComponentManager.hh>
#include <ignition/gazebo/Util.hh>
#include <ignition/gazebo/System.hh>
#include <ignition/gazebo/components/Physics.hh>
#include <ignition/plugin/Register.hh>
#include <ignition/transport/Node.hh>

#include "igniton/common/Plugin.hh"

#include "dart/simulation/World.hpp"


namespace igniton 

{

namespace gazebo

{

namespace systems

{

    class IGNITION_GAZEBO_VISIBLE ignGazeboPathFollowerRosActor:

            public ignition::gazebo::System,
            public ignition::gazebo::ISystemConfigure,
            public ignition::gazebo::ISystemPostUpdate,
            public ignition::gazebo::ISystemPreUpdate 
      {

        /// \brief Constructor
        public: ignGazeboPathFollowRosActor();

        ///  \brief Destructor 
        public: ~ignGazeboPathFollowRosActor();

        // Implement Configure callback, provided by ISystemConfigure
        // and called once at startup.
        public: void Configure(const Entity & _entity,
          const std::shared_ptr <
            const sdf::Element > & _sdf,
              EntityComponentManager & _ecm,
              EventManager & /*_eventMgr*/ );

        // Documentation inherite
        public: void PreUpdate(const ignition::gazebo::UpdateInfo &_info,
                  ignition::gazebo::EntityComponentManager &_ecm);

        public: void PostUpdate(const ignition::gazebo::UpdateInfo &_info,
                   const ignition::gazebo::EntityComponentManager &_ecm);


        /// \function to reset
        public: virtual void Reset();

        /// \brief callback for updating the activation of the actor
        private: void OnActive(const std_msgs::String::ConstPtr& msg);


        private: void QueueThread();

        private: void ReadTrajectoryFile();


        private: ros::NodeHandle * ros_node_;

        private: ros::Subscriber state_sub_;

        /// \brief Custom Callback Queue
        private: ros::CallbackQueue queue_;

        /// \brief Custom Callback Queue thread
        private: boost::thread callbackQueueThread_;

        /// \brief Pointer to the parent actor
        private: ignition::gazebo::Entity actor_entity;


        /// \brief Pointer to the world
        private: std::vector<dart::simulation::WorldPtr> world;


        /// \brief pointer to the sdf element
        private: std::shared_ptr< const sdf::Element> &_sdf;


        /// \brief Reference velocity of the actor
        private: ignition::math::Vector3d ref_velocity_;

        /// \brief Time scaling factor. Used to coordinate translational motion
        /// with the actor's walking animation.
        private: double animation_factor_;


        /// \Connecting the entity
        private: ignition::gazebo::Entity entity{ignition::gazebo::kNullEntity};
        private: ignition::gazebo::Entity modelLink{ignition::gazebo::kNullEntity};

        /// \brief Time of the last update.
        private: std::chrono::steady_clock::duration last_update

        /// \brief Time of start.
        private: std::chrono::time_point start_time_;

        /// \brief Custom trajectory info.
        private: physics::TrajectoryInfoPtr trajectoryInfo;

        /// \brief Variable for control the non-constant velocity.
        private: bool oscillation_enable_;

        /// \brief To make the actor to have non-constant velocity.
        private: double oscillation_factor_;

        private: std::string active_topic_;

        private: std::string actor_state_;

        private: std::string traj_file_name_;

        /// \brief Data structure for saving the trajectory read from file
        private: std::queue<ignition::math::Pose3d>trajectory_;

      };

    }
  }
}
#endif

Additional Context

I need some help with finding equivalent class/member functions for the following in the ignition gazebo

   private: common::Time last_update;

  private: common::Time start_time_;

  private: physics::TrajectoryInfoPtr trajectoryInfo;

  private: physics::WorldPtr world;

  private: std::queue<ignition::math::Pose3d> trajectory_;
edit retag flag offensive close merge delete

Comments

Can you update your question with the actual console output/error

josephcoombe gravatar imagejosephcoombe ( 2021-03-30 18:26:30 -0500 )edit

I have updated the question.

Adwait gravatar imageAdwait ( 2021-03-31 00:07:43 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2021-04-02 13:15:14 -0500

bach gravatar image

Try to have a look to this plugin. You can define a trajectory by waypoints. It works quite well for me.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2021-03-30 12:46:45 -0500

Seen: 71 times

Last updated: Mar 31