Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: maxsieber/nxt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: spotrh/nxt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 12 commits
  • 7 files changed
  • 1 contributor

Commits on Sep 8, 2013

  1. rviz plugins need qt now

    spotrh committed Sep 8, 2013
    Copy the full SHA
    91312d3 View commit details
  2. fix plugin

    spotrh committed Sep 8, 2013
    Copy the full SHA
    1bcae62 View commit details
  3. add props fixes

    spotrh committed Sep 8, 2013
    Copy the full SHA
    4f1f849 View commit details

Commits on Sep 9, 2013

  1. add props fixes

    spotrh committed Sep 9, 2013
    Copy the full SHA
    83355a3 View commit details
  2. more fixes

    spotrh committed Sep 9, 2013
    Copy the full SHA
    e5c7200 View commit details
  3. MOAR FIXES

    spotrh committed Sep 9, 2013
    Copy the full SHA
    13a6ae9 View commit details
  4. Copy the full SHA
    5b95e6b View commit details
  5. fixup color display too

    spotrh committed Sep 9, 2013
    Copy the full SHA
    322a8b5 View commit details
  6. fixup color display too

    spotrh committed Sep 9, 2013
    Copy the full SHA
    2d3200a View commit details
  7. fixup color display again

    spotrh committed Sep 9, 2013
    Copy the full SHA
    4878ddd View commit details
  8. Copy the full SHA
    38ea411 View commit details
  9. patches already applied

    spotrh committed Sep 9, 2013
    Copy the full SHA
    b44602e View commit details
6 changes: 3 additions & 3 deletions nxt_python/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: nxt-python

TARBALL = build/nxt-python-1.1.2.zip
TARBALL_URL = http://nxt-python.googlecode.com/files/nxt-python-1.1.2.zip
TARBALL_URL = http://spot.fedorapeople.org/nxt-python-1.1.2-fixed.zip
UNPACK_CMD = unzip
SOURCE_DIR = build/nxt-python-1.1.2
include $(shell rospack find mk)/download_unpack_build.mk
@@ -15,8 +15,8 @@ $(INSTALL_DIR)/installed: $(SOURCE_DIR)/unpacked
rm -rf src
cd $(SOURCE_DIR) && python setup.py install --prefix=$(INSTALL_DIR) --install-purelib=$(INSTALL_DIR)/src
#patch -p0<ultrasonic.patch
patch -p0 src/nxt/sensor.py gyro.patch
patch -p0 src/nxt/sensor.py colorsensor.patch
#patch -p0 src/nxt/sensor.py gyro.patch
#patch -p0 src/nxt/sensor.py colorsensor.patch
touch $(INSTALL_DIR)/installed

clean:
7 changes: 6 additions & 1 deletion nxt_rviz_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -21,6 +21,8 @@ set(SOURCE_FILES src/nxt_ultrasonic_display.cpp
src/nxt_color_display.cpp
src/init.cpp)

set(CMAKE_CXX_FLAGS "-DQT_NO_KEYWORDS")


include(CMakeDetermineSystem)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
@@ -33,11 +35,14 @@ find_package(wxWidgets REQUIRED)
include(${wxWidgets_USE_FILE})
include_directories( ${wxWidgets_INCLUDE_DIRS} )

find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
include(${QT_USE_FILE})

pkg_check_modules(OGRE OGRE)
include_directories( ${OGRE_INCLUDE_DIRS} )
link_directories( ${OGRE_LIBRARY_DIRS} )

target_link_libraries(${PROJECT_NAME} ${wxWidgets_LIBRARIES} ${OGRE_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${wxWidgets_LIBRARIES} ${OGRE_LIBRARIES} ${QT_LIBRARIES})
rosbuild_link_boost(${PROJECT_NAME} thread)

#uncomment if you have defined messages
12 changes: 3 additions & 9 deletions nxt_rviz_plugin/src/init.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
#include "rviz/plugin/type_registry.h"
#include <pluginlib/class_list_macros.h>

#include "nxt_ultrasonic_display.h"
#include "nxt_color_display.h"

using namespace nxt_rviz_plugin;

extern "C" void rvizPluginInit(rviz::TypeRegistry* reg)
{
reg->registerDisplay<NXTUltrasonicDisplay>("nxt_rviz_plugin::NXTUltrasonicDisplay");
reg->registerDisplay<NXTColorDisplay>("nxt_rviz_plugin::NXTColorDisplay");

}
PLUGINLIB_DECLARE_CLASS( rviz_qt, NXTUltrasonicDisplay, nxt_rviz_plugin::NXTUltrasonicDisplay, rviz::Display )
PLUGINLIB_DECLARE_CLASS( rviz_qt, NXTColorDisplay, nxt_rviz_plugin::NXTColorDisplay, rviz::Display )

130 changes: 54 additions & 76 deletions nxt_rviz_plugin/src/nxt_color_display.cpp
Original file line number Diff line number Diff line change
@@ -1,91 +1,76 @@
#include "nxt_color_display.h"
#include "rviz/visualization_manager.h"
#include "rviz/properties/property.h"
#include "rviz/properties/property_manager.h"
#include "rviz/common.h"
#include "rviz/properties/float_property.h"
#include "rviz/properties/ros_topic_property.h"
//#include "rviz/properties/property_manager.h"
//#include "rviz/common.h"
#include "rviz/frame_manager.h"
#include "rviz/validate_floats.h"

#include <tf/transform_listener.h>

#include <ogre_tools/shape.h>
#include <rviz/ogre_helpers/shape.h>

#include <OGRE/OgreSceneNode.h>
#include <OGRE/OgreSceneManager.h>

namespace nxt_rviz_plugin
{
NXTColorDisplay::NXTColorDisplay( const std::string& name, rviz::VisualizationManager* manager )
: Display( name, manager )
NXTColorDisplay::NXTColorDisplay()
: Display()
, messages_received_(0)
, tf_filter_(*manager->getTFClient(), "", 10, update_nh_)
{
scene_node_ = scene_manager_->getRootSceneNode()->createChildSceneNode();

cylinder_ = new ogre_tools::Shape(ogre_tools::Shape::Cylinder, vis_manager_->getSceneManager(), scene_node_);

scene_node_->setVisible( false );

setAlpha( 0.5f );
setDisplayLength( 0.003f );

Ogre::Vector3 scale( 0, 0, 0);
rviz::scaleRobotToOgre( scale );
cylinder_->setScale(scale);

tf_filter_.connectInput(sub_);
tf_filter_.registerCallback(boost::bind(&NXTColorDisplay::incomingMessage, this, _1));
vis_manager_->getFrameManager()->registerFilterForTransformStatusCheck(tf_filter_, this);
display_property_ = new rviz::FloatProperty( "Display Length", 0.003f,
"Display length.",
this, SLOT( updateDisplayLength() ));
alpha_property_ = new rviz::FloatProperty( "Alpha", 0.5f,
"Amount of transparency to apply to the circle.",
this, SLOT( updateAlpha() ));
topic_property_ = new rviz::RosTopicProperty( "Topic", "",
QString::fromStdString( ros::message_traits::datatype<nxt_msgs::Color>() ),
"nxt_msgs::Color topic to subscribe to.",
this, SLOT (updateTopic() ));
}

NXTColorDisplay::~NXTColorDisplay()
{
unsubscribe();
clear();
delete cylinder_;
delete tf_filter_;
}

void NXTColorDisplay::clear()
{

messages_received_ = 0;
setStatus(rviz::status_levels::Warn, "Topic", "No messages received");
}

void NXTColorDisplay::setTopic( const std::string& topic )
void NXTColorDisplay::onInitialize()
{
unsubscribe();

topic_ = topic;
float alpha_ = alpha_property_->getFloat();
float displayLength_ = display_property_->getFloat();

subscribe();
tf_filter_ = new tf::MessageFilter<nxt_msgs::Color>(*context_->getTFClient(), "", 10, update_nh_);
scene_node_ = scene_manager_->getRootSceneNode()->createChildSceneNode();

propertyChanged(topic_property_);
cylinder_ = new rviz::Shape(rviz::Shape::Cylinder, context_->getSceneManager(), scene_node_);

causeRender();
}
scene_node_->setVisible( false );

void NXTColorDisplay::setAlpha( float alpha )
{
alpha_ = alpha;
// setAlpha( 0.5f );
// setDisplayLength( 0.003f );

propertyChanged(alpha_property_);
Ogre::Vector3 scale( 0, 0, 0);
// rviz::scaleRobotToOgre( scale );
cylinder_->setScale(scale);

processMessage(current_message_);
causeRender();
tf_filter_->connectInput(sub_);
tf_filter_->registerCallback(boost::bind(&NXTColorDisplay::incomingMessage, this, _1));
context_->getFrameManager()->registerFilterForTransformStatusCheck(tf_filter_, this);
}

void NXTColorDisplay::setDisplayLength( float displayLength )
void NXTColorDisplay::clear()
{
displayLength_ = displayLength;

propertyChanged(display_property_);

processMessage(current_message_);
causeRender();
messages_received_ = 0;
setStatus( rviz::StatusProperty::Warn, "Topic", "No messages received" );
}


void NXTColorDisplay::subscribe()
{
if ( !isEnabled() )
@@ -118,7 +103,7 @@ void NXTColorDisplay::fixedFrameChanged()
{
clear();

tf_filter_.setTargetFrame( fixed_frame_ );
tf_filter_->setTargetFrame( fixed_frame_.toStdString() );
}

void NXTColorDisplay::update(float wall_dt, float ros_dt)
@@ -135,11 +120,7 @@ void NXTColorDisplay::processMessage(const nxt_msgs::Color::ConstPtr& msg)

++messages_received_;

{
std::stringstream ss;
ss << messages_received_ << " messages received";
setStatus(rviz::status_levels::Ok, "Topic", ss.str());
}
setStatus( rviz::StatusProperty::Ok, "Topic", QString::number( messages_received_ ) + " messages received" );

Ogre::Vector3 position;
Ogre::Quaternion orientation;
@@ -149,15 +130,16 @@ void NXTColorDisplay::processMessage(const nxt_msgs::Color::ConstPtr& msg)
pose.position.x = 0.0185 + displayLength_/2;
pose.orientation.x = 0.707;
pose.orientation.z = -0.707;
if (!vis_manager_->getFrameManager()->transform(msg->header.frame_id,msg->header.stamp,pose, position, orientation, true))
if (!context_->getFrameManager()->transform(msg->header, pose, position, orientation))
{
ROS_DEBUG( "Error transforming from frame '%s' to frame '%s'", msg->header.frame_id.c_str(), fixed_frame_.c_str() );
ROS_DEBUG( "Error transforming from frame '%s' to frame '%s'",
msg->header.frame_id.c_str(), qPrintable( fixed_frame_ ));
}

cylinder_->setPosition(position);
cylinder_->setOrientation(orientation);
Ogre::Vector3 scale( 0.0155, 0.0155, displayLength_);
rviz::scaleRobotToOgre( scale );
// rviz::scaleRobotToOgre( scale );
cylinder_->setScale(scale);
cylinder_->setColor(msg->r, msg->g, msg->b, alpha_);

@@ -174,26 +156,22 @@ void NXTColorDisplay::reset()
clear();
}

void NXTColorDisplay::createProperties()
void NXTColorDisplay::updateAlpha()
{
topic_property_ = property_manager_->createProperty<rviz::ROSTopicStringProperty>( "Topic", property_prefix_, boost::bind( &NXTColorDisplay::getTopic, this ),
boost::bind( &NXTColorDisplay::setTopic, this, _1 ), parent_category_, this );
setPropertyHelpText(topic_property_, "nxt_msgs::Color topic to subscribe to.");
rviz::ROSTopicStringPropertyPtr topic_prop = topic_property_.lock();
topic_prop->setMessageType(ros::message_traits::datatype<nxt_msgs::Color>());


alpha_property_ = property_manager_->createProperty<rviz::FloatProperty>( "Alpha", property_prefix_, boost::bind( &NXTColorDisplay::getAlpha, this ),
boost::bind( &NXTColorDisplay::setAlpha, this, _1 ), parent_category_, this );

display_property_ = property_manager_->createProperty<rviz::FloatProperty>( "Display Length", property_prefix_, boost::bind( &NXTColorDisplay::getDisplayLength, this ),
boost::bind( &NXTColorDisplay::setDisplayLength, this, _1 ), parent_category_, this );
}

setPropertyHelpText(alpha_property_, "Amount of transparency to apply to the circle.");
void NXTColorDisplay::updateDisplayLength()
{
}

const char* NXTColorDisplay::getDescription()
void NXTColorDisplay::updateTopic()
{
return "Displays data from a nxt_msgs::Color message as a cirle of color.";
unsubscribe();
subscribe();
}

} // namespace nxt_rviz_plugin

#include <pluginlib/class_list_macros.h>
PLUGINLIB_EXPORT_CLASS( nxt_rviz_plugin::NXTColorDisplay, rviz::Display )

38 changes: 18 additions & 20 deletions nxt_rviz_plugin/src/nxt_color_display.h
Original file line number Diff line number Diff line change
@@ -3,16 +3,18 @@

#include "rviz/display.h"
#include "rviz/helpers/color.h"
#include "rviz/properties/forwards.h"
//#include "rviz/properties/forwards.h"
#include <rviz/properties/float_property.h>
#include <rviz/properties/ros_topic_property.h>

#include <nxt_msgs/Color.h>

#include <boost/shared_ptr.hpp>

#include <message_filters/subscriber.h>
#include <tf/message_filter.h>

#include <boost/shared_ptr.hpp>

namespace ogre_tools
namespace rviz
{
class Shape;
}
@@ -33,28 +35,24 @@ namespace nxt_rviz_plugin
class NXTColorDisplay : public rviz::Display
{
public:
NXTColorDisplay( const std::string& name, rviz::VisualizationManager* manager );
NXTColorDisplay();
virtual ~NXTColorDisplay();

void setTopic( const std::string& topic );
const std::string& getTopic() { return topic_; }

void setAlpha( float alpha );
float getAlpha() { return alpha_; }

void setDisplayLength( float displayLength );
float getDisplayLength() { return displayLength_; }
virtual void onInitialize();

// Overrides from Display
virtual void targetFrameChanged() {}
virtual void fixedFrameChanged();
virtual void createProperties();
virtual void update(float wall_dt, float ros_dt);
virtual void reset();

static const char* getTypeStatic() { return "Color"; }
virtual const char* getType() const { return getTypeStatic(); }
static const char* getDescription();

private Q_SLOTS:
void updateAlpha();
void updateDisplayLength();
void updateTopic();

protected:
void subscribe();
@@ -74,15 +72,15 @@ class NXTColorDisplay : public rviz::Display
uint32_t messages_received_;

Ogre::SceneNode* scene_node_;
ogre_tools::Shape* cylinder_; ///< Handles actually drawing the cone
rviz::Shape* cylinder_; ///< Handles actually drawing the cone

message_filters::Subscriber<nxt_msgs::Color> sub_;
tf::MessageFilter<nxt_msgs::Color> tf_filter_;
tf::MessageFilter<nxt_msgs::Color>* tf_filter_;
nxt_msgs::Color::ConstPtr current_message_;

rviz::ROSTopicStringPropertyWPtr topic_property_;
rviz::FloatPropertyWPtr alpha_property_;
rviz::FloatPropertyWPtr display_property_;
rviz::FloatProperty* alpha_property_;
rviz::FloatProperty* display_property_;
rviz::RosTopicProperty* topic_property_;
};

} // namespace nxt_rviz_plugin
134 changes: 58 additions & 76 deletions nxt_rviz_plugin/src/nxt_ultrasonic_display.cpp
Original file line number Diff line number Diff line change
@@ -1,88 +1,75 @@
#include "nxt_ultrasonic_display.h"
#include "rviz/visualization_manager.h"
#include "rviz/properties/property.h"
#include "rviz/properties/property_manager.h"
#include "rviz/common.h"
#include "rviz/properties/color_property.h"
#include "rviz/properties/float_property.h"
#include "rviz/properties/parse_color.h"
#include "rviz/properties/ros_topic_property.h"
//#include "rviz/properties/property_manager.h"
//#include "rviz/common.h"
#include "rviz/frame_manager.h"
#include "rviz/validate_floats.h"

#include <tf/transform_listener.h>

#include <ogre_tools/shape.h>
#include <rviz/ogre_helpers/shape.h>

#include <OGRE/OgreSceneNode.h>
#include <OGRE/OgreSceneManager.h>

namespace nxt_rviz_plugin
{
NXTUltrasonicDisplay::NXTUltrasonicDisplay( const std::string& name, rviz::VisualizationManager* manager )
: Display( name, manager )
, color_( 0.1f, 1.0f, 0.0f )
, messages_received_(0)
, tf_filter_(*manager->getTFClient(), "", 10, update_nh_)
NXTUltrasonicDisplay::NXTUltrasonicDisplay()
: Display()
, messages_received_(0)
{
scene_node_ = scene_manager_->getRootSceneNode()->createChildSceneNode();

cone_ = new ogre_tools::Shape(ogre_tools::Shape::Cone, vis_manager_->getSceneManager(), scene_node_);

scene_node_->setVisible( false );

setAlpha( 0.5f );
Ogre::Vector3 scale( 0, 0, 0);
rviz::scaleRobotToOgre( scale );
cone_->setScale(scale);
cone_->setColor(color_.r_, color_.g_, color_.b_, alpha_);

tf_filter_.connectInput(sub_);
tf_filter_.registerCallback(boost::bind(&NXTUltrasonicDisplay::incomingMessage, this, _1));
vis_manager_->getFrameManager()->registerFilterForTransformStatusCheck(tf_filter_, this);
color_property_ = new rviz::ColorProperty( "Color", Qt::gray,
"Color to draw the range.",
this, SLOT( updateColor() ));
alpha_property_ = new rviz::FloatProperty( "Alpha", 0.5f,
"Amount of transparency to apply to the range.",
this, SLOT( updateColor() ));
topic_property_ = new rviz::RosTopicProperty( "Topic", "",
QString::fromStdString( ros::message_traits::datatype<nxt_msgs::Range>() ),
"nxt_msgs::Range topic to subscribe to.",
this, SLOT (updateTopic() ));
}

NXTUltrasonicDisplay::~NXTUltrasonicDisplay()
{
unsubscribe();
clear();
delete cone_;
delete tf_filter_;
}

void NXTUltrasonicDisplay::clear()
void NXTUltrasonicDisplay::onInitialize()
{
Ogre::ColourValue color = color_property_->getOgreColor();
float alpha = alpha_property_->getFloat();

messages_received_ = 0;
setStatus(rviz::status_levels::Warn, "Topic", "No messages received");
}

void NXTUltrasonicDisplay::setTopic( const std::string& topic )
{
unsubscribe();

topic_ = topic;

subscribe();

propertyChanged(topic_property_);
tf_filter_ = new tf::MessageFilter<nxt_msgs::Range>(*context_->getTFClient(), "", 10, update_nh_);
scene_node_ = scene_manager_->getRootSceneNode()->createChildSceneNode();

causeRender();
}
cone_ = new rviz::Shape(rviz::Shape::Cone, context_->getSceneManager(), scene_node_);

void NXTUltrasonicDisplay::setColor( const rviz::Color& color )
{
color_ = color;
scene_node_->setVisible( false );

propertyChanged(color_property_);
// setAlpha( 0.5f );
Ogre::Vector3 scale( 0, 0, 0);
// rviz::scaleRobotToOgre( scale );
cone_->setScale(scale);
cone_->setColor(color.r, color.g, color.b, alpha);

processMessage(current_message_);
causeRender();
tf_filter_->connectInput(sub_);
tf_filter_->registerCallback(boost::bind(&NXTUltrasonicDisplay::incomingMessage, this, _1));
context_->getFrameManager()->registerFilterForTransformStatusCheck(tf_filter_, this);
}

void NXTUltrasonicDisplay::setAlpha( float alpha )
void NXTUltrasonicDisplay::clear()
{
alpha_ = alpha;

propertyChanged(alpha_property_);

processMessage(current_message_);
causeRender();
messages_received_ = 0;
setStatus( rviz::StatusProperty::Warn, "Topic", "No messages received" );
}

void NXTUltrasonicDisplay::subscribe()
@@ -117,7 +104,7 @@ void NXTUltrasonicDisplay::fixedFrameChanged()
{
clear();

tf_filter_.setTargetFrame( fixed_frame_ );
tf_filter_->setTargetFrame( fixed_frame_.toStdString() );
}

void NXTUltrasonicDisplay::update(float wall_dt, float ros_dt)
@@ -134,11 +121,7 @@ void NXTUltrasonicDisplay::processMessage(const nxt_msgs::Range::ConstPtr& msg)

++messages_received_;

{
std::stringstream ss;
ss << messages_received_ << " messages received";
setStatus(rviz::status_levels::Ok, "Topic", ss.str());
}
setStatus( rviz::StatusProperty::Ok, "Topic", QString::number( messages_received_ ) + " messages received" );

Ogre::Vector3 position;
Ogre::Quaternion orientation;
@@ -147,15 +130,16 @@ void NXTUltrasonicDisplay::processMessage(const nxt_msgs::Range::ConstPtr& msg)
pose.position.x = msg->range/2;
pose.orientation.x = 0.707;
pose.orientation.z = -0.707;
if (!vis_manager_->getFrameManager()->transform(msg->header.frame_id,msg->header.stamp,pose, position, orientation, true))
if (!context_->getFrameManager()->transform(msg->header, pose, position, orientation))
{
ROS_DEBUG( "Error transforming from frame '%s' to frame '%s'", msg->header.frame_id.c_str(), fixed_frame_.c_str() );
ROS_DEBUG( "Error transforming from frame '%s' to frame '%s'",
msg->header.frame_id.c_str(), qPrintable( fixed_frame_ ));
}

cone_->setPosition(position);
cone_->setOrientation(orientation);
Ogre::Vector3 scale( sin(msg->spread_angle) * msg->range, sin(msg->spread_angle) * msg->range , msg->range);
rviz::scaleRobotToOgre( scale );
// rviz::scaleRobotToOgre( scale );
cone_->setScale(scale);
cone_->setColor(color_.r_, color_.g_, color_.b_, alpha_);

@@ -172,23 +156,21 @@ void NXTUltrasonicDisplay::reset()
clear();
}

void NXTUltrasonicDisplay::createProperties()
{
topic_property_ = property_manager_->createProperty<rviz::ROSTopicStringProperty>( "Topic", property_prefix_, boost::bind( &NXTUltrasonicDisplay::getTopic, this ),
boost::bind( &NXTUltrasonicDisplay::setTopic, this, _1 ), parent_category_, this );
setPropertyHelpText(topic_property_, "nxt_msgs::Range topic to subscribe to.");
rviz::ROSTopicStringPropertyPtr topic_prop = topic_property_.lock();
topic_prop->setMessageType(ros::message_traits::datatype<nxt_msgs::Range>());
color_property_ = property_manager_->createProperty<rviz::ColorProperty>( "Color", property_prefix_, boost::bind( &NXTUltrasonicDisplay::getColor, this ),
boost::bind( &NXTUltrasonicDisplay::setColor, this, _1 ), parent_category_, this );
setPropertyHelpText(color_property_, "Color to draw the range.");
alpha_property_ = property_manager_->createProperty<rviz::FloatProperty>( "Alpha", property_prefix_, boost::bind( &NXTUltrasonicDisplay::getAlpha, this ),
boost::bind( &NXTUltrasonicDisplay::setAlpha, this, _1 ), parent_category_, this );
setPropertyHelpText(alpha_property_, "Amount of transparency to apply to the range.");
void NXTUltrasonicDisplay::updateColor()
{
QColor color = color_property_->getColor();
color.setAlphaF( alpha_property_->getFloat() );
cone_->setColor( rviz::qtToOgre( color ));
context_->queueRender();
}

const char* NXTUltrasonicDisplay::getDescription()
void NXTUltrasonicDisplay::updateTopic()
{
return "Displays data from a nxt_msgs::Range message as a cone.";
unsubscribe();
subscribe();
}

} // namespace nxt_rviz_plugin

#include <pluginlib/class_list_macros.h>
PLUGINLIB_EXPORT_CLASS( nxt_rviz_plugin::NXTUltrasonicDisplay, rviz::Display )
39 changes: 19 additions & 20 deletions nxt_rviz_plugin/src/nxt_ultrasonic_display.h
Original file line number Diff line number Diff line change
@@ -33,16 +33,20 @@

#include "rviz/display.h"
#include "rviz/helpers/color.h"
#include "rviz/properties/forwards.h"
// #include "rviz/properties/forwards.h"
#include <rviz/properties/property.h>
#include <rviz/properties/color_property.h>
#include <rviz/properties/float_property.h>
#include <rviz/properties/ros_topic_property.h>

#include <nxt_msgs/Range.h>

#include <boost/shared_ptr.hpp>

#include <message_filters/subscriber.h>
#include <tf/message_filter.h>

#include <boost/shared_ptr.hpp>

namespace ogre_tools
namespace rviz
{
class Shape;
}
@@ -63,28 +67,23 @@ namespace nxt_rviz_plugin
class NXTUltrasonicDisplay : public rviz::Display
{
public:
NXTUltrasonicDisplay( const std::string& name, rviz::VisualizationManager* manager );
NXTUltrasonicDisplay();
virtual ~NXTUltrasonicDisplay();

void setTopic( const std::string& topic );
const std::string& getTopic() { return topic_; }

void setColor( const rviz::Color& color );
const rviz::Color& getColor() { return color_; }

void setAlpha( float alpha );
float getAlpha() { return alpha_; }
virtual void onInitialize();

// Overrides from Display
virtual void targetFrameChanged() {}
virtual void fixedFrameChanged();
virtual void createProperties();
virtual void update(float wall_dt, float ros_dt);
virtual void reset();

static const char* getTypeStatic() { return "Range"; }
virtual const char* getType() const { return getTypeStatic(); }
static const char* getDescription();

private Q_SLOTS:
void updateColor();
void updateTopic();

protected:
void subscribe();
@@ -104,15 +103,15 @@ class NXTUltrasonicDisplay : public rviz::Display
uint32_t messages_received_;

Ogre::SceneNode* scene_node_;
ogre_tools::Shape* cone_; ///< Handles actually drawing the cone
rviz::Shape* cone_; ///< Handles actually drawing the cone

message_filters::Subscriber<nxt_msgs::Range> sub_;
tf::MessageFilter<nxt_msgs::Range> tf_filter_;
tf::MessageFilter<nxt_msgs::Range>* tf_filter_;
nxt_msgs::Range::ConstPtr current_message_;

rviz::ColorPropertyWPtr color_property_;
rviz::ROSTopicStringPropertyWPtr topic_property_;
rviz::FloatPropertyWPtr alpha_property_;
rviz::ColorProperty* color_property_;
rviz::RosTopicProperty* topic_property_;
rviz::FloatProperty* alpha_property_;
};

} // namespace nxt_rviz_plugin