Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreliable option on image, camera and map #976

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/rviz/default_plugin/map_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ MapDisplay::MapDisplay()
"Orientation of the map. (not editable)",
this );
orientation_property_->setReadOnly( true );

unreliable_property_ = new BoolProperty( "Unreliable", false,
"Prefer UDP topic transport",
this,
SLOT( updateTopic() ));
}

MapDisplay::~MapDisplay()
Expand Down Expand Up @@ -343,7 +348,12 @@ void MapDisplay::subscribe()
{
try
{
map_sub_ = update_nh_.subscribe( topic_property_->getTopicStd(), 1, &MapDisplay::incomingMap, this );
if(unreliable_property_->getBool())
{
map_sub_ = update_nh_.subscribe( topic_property_->getTopicStd(), 1, &MapDisplay::incomingMap, this, ros::TransportHints().unreliable());
}else{
map_sub_ = update_nh_.subscribe( topic_property_->getTopicStd(), 1, &MapDisplay::incomingMap, this, ros::TransportHints().reliable() );
}
setStatus( StatusProperty::Ok, "Topic", "OK" );
}
catch( ros::Exception& e )
Expand Down
2 changes: 2 additions & 0 deletions src/rviz/default_plugin/map_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ protected Q_SLOTS:
FloatProperty* alpha_property_;
Property* draw_under_property_;
EnumProperty* color_scheme_property_;

BoolProperty* unreliable_property_;
};

} // namespace rviz
Expand Down
19 changes: 17 additions & 2 deletions src/rviz/image/image_display_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ ImageDisplayBase::ImageDisplayBase() :

transport_property_->setStdString("raw");

unreliable_property_ = new BoolProperty( "Unreliable", false,
"Prefer UDP topic transport",
this,
SLOT( updateTopic() ));

}

ImageDisplayBase::~ImageDisplayBase()
Expand Down Expand Up @@ -152,8 +157,18 @@ void ImageDisplayBase::subscribe()

if (!topic_property_->getTopicStd().empty() && !transport_property_->getStdString().empty() )
{
sub_->subscribe(*it_, topic_property_->getTopicStd(), (uint32_t)queue_size_property_->getInt(),
image_transport::TransportHints(transport_property_->getStdString()));

// Determine UDP vs TCP transport for user selection.
if (unreliable_property_->getBool())
{
sub_->subscribe(*it_, topic_property_->getTopicStd(), (uint32_t)queue_size_property_->getInt(),
image_transport::TransportHints(transport_property_->getStdString(), ros::TransportHints().unreliable()));
}
else{
sub_->subscribe(*it_, topic_property_->getTopicStd(), (uint32_t)queue_size_property_->getInt(),
image_transport::TransportHints(transport_property_->getStdString()));
}


if (targetFrame_.empty())
{
Expand Down
2 changes: 2 additions & 0 deletions src/rviz/image/image_display_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ protected Q_SLOTS:
std::string transport_;

std::set<std::string> transport_plugin_types_;

BoolProperty* unreliable_property_;
};

} // end namespace rviz
Expand Down