1 #ifndef MULTI_ROBOT_INFO_VISUAL_HPP 2 #define MULTI_ROBOT_INFO_VISUAL_HPP 11 #include <OgreManualObject.h> 16 #include <boost/circular_buffer.hpp> 19 #include <tuw_multi_robot_msgs/RobotInfo.h> 20 #include <tuw_multi_robot_msgs/Route.h> 21 #include <geometry_msgs/PoseWithCovariance.h> 23 #include <Eigen/Geometry> 32 using buf_type = boost::circular_buffer<geometry_msgs::PoseWithCovariance>;
37 Ogre::ColourValue
color,
38 Ogre::SceneManager *_scene_manager,
39 Ogre::SceneNode *_parent_node);
68 void updatePose(
const geometry_msgs::PoseWithCovariance &pose)
71 current_pos = Ogre::Vector3(pose.pose.position.x, pose.pose.position.y, pose.pose.position.z);
72 current_orient = Ogre::Quaternion(pose.pose.orientation.w, pose.pose.orientation.x, pose.pose.orientation.y, pose.pose.orientation.z);
84 const auto current_pose = pose.front();
85 current_pos = Ogre::Vector3(current_pose.pose.position.x,
86 current_pose.pose.position.y,
87 current_pose.pose.position.z);
90 current_pose.pose.orientation.x,
91 current_pose.pose.orientation.y,
92 current_pose.pose.orientation.z);
114 std::shared_ptr<tuw_multi_robot_msgs::Route>
route;
126 std::unique_ptr<TextVisual>
text;
149 if (route ==
nullptr)
152 double min_dist = std::numeric_limits<double>::max();
155 for (
size_t i=seg_id_current; i < route->segments.size(); ++i)
157 const auto s = route->segments[i];
158 const auto position_s =
s.start.position;
159 const auto position_e =
s.end.position;
160 Eigen::Vector3f ps(position_s.x, position_s.y, position_s.z);
161 Eigen::Vector3f dvec (ps - Eigen::Vector3f(current_pos.x, current_pos.y, current_pos.z));
162 double dist = dvec.norm();
171 for (
size_t i=seg_id_current; i < route->segments.size(); ++i)
173 const auto s = route->segments[i];
174 auto position_s =
s.start.position;
175 if (i==seg_id_current)
177 position_s.x = current_pos.x;
178 position_s.y = current_pos.y;
179 position_s.z = current_pos.z;
181 const auto position_e =
s.end.position;
182 const double dist =
pow(position_e.x - position_s.x, 2) +
pow(position_e.y - position_s.y,2) +
pow(position_e.z - position_s.z,2);
183 acc_len +=
sqrt(dist);
185 path_length_ = acc_len;
198 void setMessage(
const tuw_multi_robot_msgs::RobotInfoConstPtr _msg);
200 void setFramePosition(
const Ogre::Vector3& _position);
201 void setFrameOrientation(
const Ogre::Quaternion& orientation );
205 void setScalePose(
float scale );
209 void setColorPose( Ogre::ColourValue
color );
211 void disableRobot(
const std::string &rName );
213 void enableRobot(
const std::string &rName );
217 void resetKeepMeasurementsCount (
const unsigned int c );
224 using map_type = std::map<std::string, std::shared_ptr<RobotAttributes>>;
225 using map_iterator = std::map<std::string, std::shared_ptr<RobotAttributes>>::iterator;
228 std::vector<std::string> recycle();
239 int default_size_ = {5};
256 Ogre::ColourValue color_pose_ = Ogre::ColourValue(1,0,0,1);
Ogre::ColourValue color_variance_
std::map< std::string, std::shared_ptr< RobotAttributes > >::iterator map_iterator
recycle_map_type recycle_map_
ros::Time last_render_time_
Ogre::ManualObject * arrow
Ogre::Quaternion current_orient
std::unique_ptr< TextVisual > text
void updatePose(const geometry_msgs::PoseWithCovariance &pose)
std::shared_ptr< tuw_multi_robot_msgs::Route > route
std::vector< std::unique_ptr< TextVisual > > route_visuals
void updatePose(const buf_type &pose)
boost::circular_buffer< geometry_msgs::PoseWithCovariance > buf_type
void updateArrow(bool first_time=false)
ros::Subscriber sub_route
void updateColor(Ogre::ColourValue &c)
Ogre::SceneNode * frame_node
std::map< std::string, ros::Time > recycle_map_type
RobotAttributes(size_t id, std::string &rname, double rad, buf_type &pose, Ogre::ColourValue color, Ogre::SceneManager *_scene_manager, Ogre::SceneNode *_parent_node)
INLINE Rall1d< T, V, S > sqrt(const Rall1d< T, V, S > &arg)
std::set< std::string > disabled_robots_
void setPoseBufferLength(size_t len)
Ogre::SceneNode * frame_node_
Ogre::ManualObject * circle
void updateCircle(bool first_time=false)
INLINE Rall1d< T, V, S > pow(const Rall1d< T, V, S > &arg, double m)
Ogre::SceneManager * scene_manager_
std::pair< std::string, std::shared_ptr< RobotAttributes > > internal_map_type
map_type robot2attribute_map_
void cbRoute(const ros::MessageEvent< const tuw_multi_robot_msgs::Route > &_event, int _topic)
std::size_t seg_id_current
void updateText(bool first_time=false)
std::map< std::string, std::shared_ptr< RobotAttributes > > map_type
Ogre::SceneManager * scene_manager
Ogre::Vector3 current_pos