Go to the documentation of this file.00001 #include <OGRE/OgreSceneNode.h>
00002 #include <OGRE/OgreSceneManager.h>
00003
00004 #include <tf/transform_listener.h>
00005
00006 #include <rviz/visualization_manager.h>
00007 #include <rviz/properties/color_property.h>
00008 #include <rviz/properties/float_property.h>
00009 #include <rviz/properties/int_property.h>
00010 #include <rviz/frame_manager.h>
00011
00012 #include "ndt_visual.hpp"
00013
00014 #include "ndt_display.hpp"
00015
00016 namespace lslgeneric{
00017
00018 NDTDisplay::NDTDisplay(){
00019 ROS_ERROR("BUILDING OBJECT");
00020 color_property_ = new rviz::ColorProperty( "Color", QColor( 204, 51, 204 ),
00021 "Color to draw the acceleration arrows.",
00022 this, SLOT( updateColorAndAlpha() ));
00023
00024 alpha_property_ = new rviz::FloatProperty( "Alpha", 1.0,
00025 "0 is fully transparent, 1.0 is fully opaque.",
00026 this, SLOT( updateColorAndAlpha() ));
00027
00028 history_length_property_ = new rviz::IntProperty( "History Length", 1,
00029 "Number of prior measurements to display.",
00030 this, SLOT( updateHistoryLength() ));
00031 history_length_property_->setMin( 1 );
00032 history_length_property_->setMax( 100000 );
00033 }
00034 void NDTDisplay::onInitialize(){
00035 MFDClass::onInitialize();
00036 }
00037
00038 NDTDisplay::~NDTDisplay(){
00039 }
00040 void NDTDisplay::reset(){
00041 MFDClass::reset();
00042 visuals_.clear();
00043 }
00044 void NDTDisplay::updateColorAndAlpha(){
00045 float alpha=alpha_property_->getFloat();
00046 Ogre::ColourValue color=color_property_->getOgreColor();
00047 for(size_t i=0;i<visuals_.size();i++){
00048 visuals_[i]->setColor(color.r,color.g,color.b,alpha);
00049 }
00050 }
00051 void NDTDisplay::processMessage( const ndt_map::NDTMapMsg::ConstPtr& msg ){
00052 ROS_ERROR("MESSAGE RECIVED");
00053 Ogre::Quaternion orientation;
00054 Ogre::Vector3 position;
00055 if( !context_->getFrameManager()->getTransform( msg->header.frame_id,msg->header.stamp,position, orientation)){
00056 ROS_DEBUG( "Error transforming from frame '%s' to frame '%s'",msg->header.frame_id.c_str(), qPrintable( fixed_frame_ ));
00057 return;
00058 }
00059 for(int itr=0;itr<msg->cells.size();itr++){
00060
00061 boost::shared_ptr<NDTVisual> visual;
00062 visual.reset(new NDTVisual(context_->getSceneManager(), scene_node_));
00063 if(!(msg->x_cell_size==msg->y_cell_size&&msg->y_cell_size==msg->z_cell_size)){
00064 ROS_ERROR("SOMETHING HAS GONE VERY WRONG YOUR VOXELL IS NOT A CUBE");
00065
00066 }
00067
00068 visual->setCell(msg->cells[itr],msg->x_cell_size);
00069 visual->setFramePosition(position);
00070 visual->setFrameOrientation(orientation);
00071 float alpha = alpha_property_->getFloat();
00072 Ogre::ColourValue color=color_property_->getOgreColor();
00073 visual->setColor(color.r,color.g,color.b,alpha);
00074 visuals_.push_back(visual);
00075 }
00076 }
00077 }
00078
00079 #include <pluginlib/class_list_macros.h>
00080 PLUGINLIB_EXPORT_CLASS(lslgeneric::NDTDisplay,rviz::Display)
00081