20 #include <yaml-cpp/yaml.h> 29 spinner_(1, &callback_queue_) {}
32 sdf::ElementPtr _sdf) {
37 if (not _sdf->HasElement(
"trackedModels"))
39 YAML::Node node = YAML::Load(_sdf->Get<std::string>(
"trackedModels"));
40 for (
const auto &model : node)
44 if (not _sdf->HasElement(
"cameras"))
46 node = YAML::Load(_sdf->Get<std::string>(
"cameras"));
47 for (
const auto &camera : node)
cameras_.push_back(camera.as<std::string>());
50 if (not _sdf->HasElement(
"pose"))
52 auto pose = _sdf->Get<ignition::math::Pose3d>(
"pose");
55 if (not _sdf->HasElement(
"size"))
57 auto size = _sdf->Get<ignition::math::Vector3d>(
"size");
60 container_ = ignition::math::OrientedBoxd(size, pose);
64 "A ROS node for Gazebo has not been initialized, unable to load " 65 "plugin. Load the Gazebo system plugin 'libgazebo_ros_api_plugin.so' " 66 "in the gazebo_ros package");
70 nh_ = boost::make_shared<ros::NodeHandle>();
75 if (not _sdf->HasElement(
"topic"))
77 publisher_ =
nh_->advertise<gazebo_video_monitor_msgs::Strings>(
78 _sdf->Get<std::string>(
"topic"), 10);
82 bool visualize =
false;
83 if (_sdf->HasElement(
"visualize")) visualize = _sdf->Get<
bool>(
"visualize");
86 std::make_shared<BoxMarkerVisualizer>(_sdf->Get<std::string>(
"name"));
91 if (not _sdf->HasElement(
"updateRate"))
93 double update_rate = _sdf->Get<
double>(
"updateRate");
101 auto model =
world_->ModelByName(name);
102 if (not model)
return false;
103 auto position = model->WorldPose().Pos();
111 bool contains_model = std::any_of(
113 [&](
const auto &name) ->
bool {
return this->
contains(name); });
115 if (contains_model) {
118 contains_model_ =
true;
ros::AsyncSpinner spinner_
ros::Publisher publisher_
ROSCPP_DECL bool isInitialized()
void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf) override
std::vector< std::string > tracked_models_
bool contains(const std::string &name) const
void publish(const boost::shared_ptr< M > &message) const
#define ROS_FATAL_STREAM(args)
std::string logger_prefix_
event::ConnectionPtr update_connection_
ros::CallbackQueue callback_queue_
BoxMarkerVisualizerPtr container_visualizer_
gazebo_video_monitor_msgs::Strings msg_
static std::string getClassName()
std::vector< std::string > cameras_
ignition::math::OrientedBoxd container_
Publishes a camera select message when a model enters a certain space.
void onUpdate(const common::UpdateInfo &info)
common::Time last_update_time_