31 #include <boost/bind/bind.hpp> 
   33 #include <OGRE/OgreSceneNode.h> 
   34 #include <OGRE/OgreSceneManager.h> 
   53 class FrameSelectionHandler : 
public SelectionHandler
 
   61   void createProperties(
const Picked& obj, Property* parent_property) 
override;
 
   80   : SelectionHandler(context)
 
   82   , category_property_(nullptr)
 
   83   , enabled_property_(nullptr)
 
   84   , parent_property_(nullptr)
 
   85   , position_property_(nullptr)
 
   86   , orientation_property_(nullptr)
 
   93       new Property(
"Frame " + QString::fromStdString(
frame_->
name_), QVariant(), 
"", parent_property);
 
   96                                        SLOT(updateVisibilityFromSelection()), 
frame_);
 
  105       new QuaternionProperty(
"Orientation", Ogre::Quaternion::IDENTITY, 
"", 
category_property_);
 
  163   showFaces_(true), showGazes_(true), showSkeletons_(true) 
 
  166       new BoolProperty(
"Show Names", 
true, 
"Whether or not names should be shown next to the frames.",
 
  170       new BoolProperty(
"Show Axes", 
true, 
"Whether or not the axes of each frame should be shown.", 
this,
 
  174                                            "Whether or not arrows from child to parent should be shown.",
 
  178       new FloatProperty(
"Marker Scale", 1, 
"Scaling factor for all names, axes and arrows.", 
this);
 
  185       new BoolProperty(
"Show Faces", 
true, 
"Whether or not the face_ frames should be displayed.", 
this,
 
  188       new BoolProperty(
"Show Gazes", 
true, 
"Whether or not the gaze_ frames should be displayed.", 
this,
 
  192       new BoolProperty(
"Show Skeletons", 
true, 
"'Whether or not human skeleton frames should be displayed.", 
this,
 
  196                                             "The interval, in seconds, at which to update the frame " 
  197                                             "transforms. 0 means to do so every update cycle.",
 
  203       "The length of time, in seconds, before a frame that has not been updated is considered \"dead\"." 
  204       "  For 1/3 of this time the frame will appear correct, for the second 1/3rd it will fade to gray," 
  205       " and then it will fade out completely.",
 
  212       new BoolProperty(
"All Enabled", 
true, 
"Whether all the frames should be enabled or not.",
 
  216       "Tree", QVariant(), 
"A tree-view of the frames, showing the parent/child relationships.", 
this);
 
  277     QString key = iter.currentKey();
 
  278     if (key != 
"All Enabled")
 
  280       const Config& child = iter.currentChild();
 
  324   M_FrameInfo::iterator it = 
frames_.begin();
 
  325   M_FrameInfo::iterator end = 
frames_.end();
 
  326   for (; it != end; ++it)
 
  338   M_FrameInfo::iterator it = 
frames_.begin();
 
  339   M_FrameInfo::iterator end = 
frames_.end();
 
  340   for (; it != end; ++it)
 
  364   M_FrameInfo::iterator it = 
frames_.begin();
 
  365   M_FrameInfo::iterator end = 
frames_.end();
 
  366   for (; it != end; ++it)
 
  382   M_FrameInfo::iterator it = 
frames_.begin();
 
  383   M_FrameInfo::iterator end = 
frames_.end();
 
  384   for (; it != end; ++it)
 
  396   if (update_rate < 0.0001f || update_timer_ > update_rate)
 
  406   M_FrameInfo::iterator it = 
frames_.find(frame);
 
  417   typedef std::vector<std::string> 
V_string;
 
  420   std::sort(frames.begin(), frames.end());
 
  428   bool skeletonFound;  
bool idFound;
 
  430   auto framesIt = frames.begin();
 
  431   while(framesIt != frames.end()){
 
  432     faceFound = ((*framesIt).rfind(
"face_", 0) == 0);
 
  435       id = (*framesIt).substr((*framesIt).size()-5);
 
  436       idFound = (faces.find(
id) != faces.end()); 
 
  440         framesIt = frames.erase(framesIt);
 
  445     gazeFound = ((*framesIt).rfind(
"gaze_", 0) == 0);
 
  448       id = (*framesIt).substr((*framesIt).size()-5);
 
  449       idFound = (faces.find(
id) != faces.end()); 
 
  453         framesIt = frames.erase(framesIt);
 
  465     std::string frameName = *framesIt;
 
  470     if (frameName.length() < 10){
 
  471       framesIt = frames.erase(framesIt);
 
  475     std::string possibleSkeletonComponent = frameName.substr(0, frameName.length()-6);
 
  478       id = (*framesIt).substr((*framesIt).size()-5);
 
  479       idFound = (bodies.find(
id) != bodies.end()); 
 
  483         framesIt = frames.erase(framesIt);
 
  487       framesIt = frames.erase(framesIt);
 
  495     for (
const std::string& frame : frames)
 
  512       current_frames.insert(info);
 
  517     M_FrameInfo::iterator frame_it = 
frames_.begin();
 
  518     M_FrameInfo::iterator frame_end = 
frames_.end();
 
  519     while (frame_it != frame_end)
 
  521       if (current_frames.find(frame_it->second) == current_frames.end())
 
  537   frames_.insert(std::make_pair(frame, info));
 
  558                                              "Enable or disable this individual frame.",
 
  567                          "Position of this frame, in the current Fixed Frame.  (Not editable)",
 
  573                              "Orientation of this frame, in the current Fixed Frame.  (Not editable)",
 
  579                          "Position of this frame, relative to it's parent frame.  (Not editable)",
 
  585                              "Orientation of this frame, relative to it's parent frame.  (Not editable)",
 
  601 Ogre::ColourValue 
lerpColor(
const Ogre::ColourValue& start, 
const Ogre::ColourValue& end, 
float t)
 
  603   return start * 
t + end * (1 - 
t);
 
  614   tf->_getLatestCommonTime(target_id, source_id, latest_time, 
nullptr);
 
  625   float one_third_timeout = frame_timeout * 0.3333333f;
 
  635     Ogre::ColourValue grey(0.7, 0.7, 0.7, 1.0);
 
  639       float a = std::max(0.0, (frame_timeout - age.
toSec()) / one_third_timeout);
 
  640       Ogre::ColourValue c = Ogre::ColourValue(grey.r, grey.g, grey.b, a);
 
  650       float t = std::max(0.0, (one_third_timeout * 2 - age.
toSec()) / one_third_timeout);
 
  669   Ogre::Vector3 position;
 
  670   Ogre::Quaternion orientation;
 
  673     std::stringstream ss;
 
  674     ss << 
"No transform from [" << frame->
name_ << 
"] to frame [" << 
fixed_frame_.toStdString() << 
"]";
 
  676     ROS_DEBUG(
"Error transforming frame '%s' to frame '%s'", frame->
name_.c_str(),
 
  699   frame->
name_node_->setScale(scale, scale, scale);
 
  704   std::string old_parent = frame->
parent_;
 
  709     geometry_msgs::TransformStamped transform;
 
  716       ROS_DEBUG(
"Error transforming frame '%s' (parent of '%s') to frame '%s'", frame->
parent_.c_str(),
 
  718       transform.transform.rotation.w = 1.0;
 
  722     const auto& translation = transform.transform.translation;
 
  723     const auto& quat = transform.transform.rotation;
 
  724     Ogre::Vector3 relative_position(translation.x, translation.y, translation.z);
 
  725     Ogre::Quaternion relative_orientation(quat.w, quat.x, quat.y, quat.z);
 
  731       Ogre::Vector3 parent_position;
 
  732       Ogre::Quaternion parent_orientation;
 
  736         ROS_DEBUG(
"Error transforming frame '%s' (parent of '%s') to frame '%s'", frame->
parent_.c_str(),
 
  740       Ogre::Vector3 direction = parent_position - position;
 
  741       float distance = direction.length();
 
  742       direction.normalise();
 
  744       Ogre::Quaternion orient = Ogre::Vector3::NEGATIVE_UNIT_Z.getRotationTo(direction);
 
  747       float head_length = (distance < 0.1 * scale) ? (0.1 * scale * distance) : 0.1 * scale;
 
  748       float shaft_length = distance - head_length;
 
  751       frame->
parent_arrow_->
set(shaft_length, 0.01 * scale, head_length, 0.04 * scale);
 
  753       if (distance > 0.001
f)
 
  789     if (!parent_tree_property)
 
  794           new Property(QString::fromStdString(frame->
name_), QVariant(), 
"", parent_tree_property);
 
  818   if (delete_properties)
 
  845   , parent_arrow_(nullptr)
 
  846   , name_text_(nullptr)
 
  847   , distance_to_parent_(0.0
f)
 
  848   , arrow_orientation_(
Ogre::Quaternion::IDENTITY)
 
  849   , tree_property_(nullptr)