Skip to content

Commit

Permalink
Fix SDF namespacing for Video Plugin (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
davetcoleman authored Feb 21, 2017
1 parent e354f52 commit 0843acc
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions gazebo_plugins/src/gazebo_ros_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,48 +122,57 @@ namespace gazebo
{

model_ = parent;
sdf::ElementPtr p_sdf;
if (sdf->HasElement("sdf"))
{
p_sdf = sdf->GetElement("sdf");
}
else
{
p_sdf = sdf;
}

robot_namespace_ = "";
if (!sdf->HasElement("robotNamespace"))
if (!p_sdf->HasElement("robotNamespace"))
{
ROS_WARN_NAMED("video", "GazeboRosVideo plugin missing <robotNamespace>, "
"defaults to \"%s\".", robot_namespace_.c_str());
}
else
{
robot_namespace_ =
sdf->GetElement("robotNamespace")->Get<std::string>();
p_sdf->GetElement("robotNamespace")->Get<std::string>();
}

topic_name_ = "image_raw";
if (!sdf->HasElement("topicName"))
if (!p_sdf->HasElement("topicName"))
{
ROS_WARN_NAMED("video", "GazeboRosVideo Plugin (ns = %s) missing <topicName>, "
"defaults to \"%s\".", robot_namespace_.c_str(), topic_name_.c_str());
}
else
{
topic_name_ = sdf->GetElement("topicName")->Get<std::string>();
topic_name_ = p_sdf->GetElement("topicName")->Get<std::string>();
}

int height = 240;
if (!sdf->HasElement("height")) {
if (!p_sdf->HasElement("height")) {
ROS_WARN_NAMED("video", "GazeboRosVideo Plugin (ns = %s) missing <height>, "
"defaults to %i.", robot_namespace_.c_str(), height);
}
else
{
height = sdf->GetElement("height")->Get<int>();
height = p_sdf->GetElement("height")->Get<int>();
}

int width = 320;
if (!sdf->HasElement("width")) {
if (!p_sdf->HasElement("width")) {
ROS_WARN_NAMED("video", "GazeboRosVideo Plugin (ns = %s) missing <width>, "
"defaults to %i", robot_namespace_.c_str(), width);
}
else
{
width = sdf->GetElement("width")->Get<int>();
width = p_sdf->GetElement("width")->Get<int>();
}

std::string name = robot_namespace_ + "_visual";
Expand Down

0 comments on commit 0843acc

Please sign in to comment.