forked from Auterion/px4-simulation-ignition
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c3e92a
commit dc8d86a
Showing
5 changed files
with
227 additions
and
676 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <gz/sim/config.hh> | ||
#include <gz/sim/System.hh> | ||
#include <gz/transport/Node.hh> | ||
#include "gz/sim/Model.hh" | ||
#include "common.h" | ||
#include <gz/msgs/pose_v.pb.h> | ||
|
||
namespace gz { | ||
namespace sim { | ||
// Inline bracket to help doxygen filtering. | ||
inline namespace GZ_SIM_VERSION_NAMESPACE { | ||
namespace systems { | ||
|
||
/// \brief Pose publisher system. Attach to an entity to publish the | ||
/// transform of its child entities in the form of gz::msgs::Pose | ||
/// messages | ||
/// | ||
/// ## System Parameters | ||
/// | ||
/// - `<update_frequency>`: Frequency of pose publications in Hz. A negative | ||
/// frequency publishes as fast as possible (i.e, at the rate of the | ||
/// simulation step) | ||
class GroundtruthPlugin | ||
: public System, | ||
public ISystemConfigure, | ||
public ISystemPostUpdate { | ||
public: | ||
/// \brief Constructor | ||
GroundtruthPlugin(); | ||
|
||
/// \brief Destructor | ||
~GroundtruthPlugin() override = default; | ||
|
||
// Documentation inherited | ||
void Configure(const Entity &_entity, | ||
const std::shared_ptr<const sdf::Element> &_sdf, | ||
EntityComponentManager &_ecm, | ||
EventManager &_eventMgr) override; | ||
|
||
// Documentation inherited | ||
void PostUpdate( | ||
const UpdateInfo &_info, | ||
const EntityComponentManager &_ecm) override; | ||
|
||
/// \brief Publishes pose with the provided time | ||
/// stamp. | ||
/// \param[in] _stampMsg Time stamp associated with published poses | ||
void PublishPose(const EntityComponentManager &_ecm, | ||
const msgs::Time &_stampMsg); | ||
|
||
private: | ||
/// \brief Gazebo communication node. | ||
transport::Node node; | ||
|
||
/// \brief publisher for pose data | ||
transport::Node::Publisher posePub; | ||
|
||
/// \brief Model interface | ||
Model model{kNullEntity}; | ||
|
||
/// \brief Frequency of pose publications in Hz. A negative frequency | ||
/// publishes as fast as possible (i.e, at the rate of the simulation step) | ||
double updateFrequency = -1; | ||
|
||
/// \brief Last time poses were published. | ||
std::chrono::steady_clock::duration lastPosePubTime{0}; | ||
|
||
/// \brief Update period in nanoseconds calculated from the update_frequency | ||
/// parameter | ||
std::chrono::steady_clock::duration updatePeriod{0}; | ||
|
||
/// \brief A variable that gets populated with poses. This also here as a | ||
/// member variable to avoid repeated memory allocations and improve | ||
/// performance. | ||
msgs::Pose poseMsg; | ||
|
||
/// \brief Model name | ||
std::string model_name_{}; | ||
|
||
// Home defaults to Zurich Irchel Park | ||
// @note The home position can be specified using the environment variables: | ||
// PX4_HOME_LAT, PX4_HOME_LON, and PX4_HOME_ALT | ||
double lat_home_ = kDefaultHomeLatitude; | ||
double lon_home_ = kDefaultHomeLongitude; | ||
double alt_home_ = kDefaultHomeAltitude; | ||
double world_latitude_ = 0.0; | ||
double world_longitude_ = 0.0; | ||
double world_altitude_ = 0.0; | ||
}; | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.