footstep_planning_vis.cpp
Go to the documentation of this file.
2 
4 {
5 namespace vis
6 {
7 void publishFeet(ros::Publisher& pub, const msgs::Feet& feet, const geometry_msgs::Vector3& foot_size, const std_msgs::ColorRGBA& color)
8 {
9  visualization_msgs::MarkerArray marker_array;
10  msgs::feetToFootMarkerArray(feet, foot_size, color, marker_array);
11  pub.publish(marker_array);
12 }
13 
14 void publishStart(ros::Publisher& pub, const msgs::Feet& feet, const geometry_msgs::Vector3& foot_size)
15 {
16  std_msgs::ColorRGBA color;
17  color.r = 0.0;
18  color.g = 0.7;
19  color.b = 0.0;
20  color.a = 0.6;
21  publishFeet(pub, feet, foot_size, color);
22 }
23 
24 void publishGoal(ros::Publisher& pub, const msgs::Feet& feet, const geometry_msgs::Vector3& foot_size)
25 {
26  std_msgs::ColorRGBA color;
27  color.r = 0.7;
28  color.g = 0.0;
29  color.b = 0.0;
30  color.a = 0.6;
31  publishFeet(pub, feet, foot_size, color);
32 }
33 
34 void publishStepPlan(ros::Publisher& pub, const msgs::StepPlan& step_plan, const geometry_msgs::Vector3& foot_size, visualization_msgs::MarkerArray& last_step_plan_vis, bool add_step_index)
35 {
36  visualization_msgs::MarkerArray step_plan_vis;
37  msgs::stepPlanToFootMarkerArray(step_plan, foot_size, step_plan_vis, add_step_index);
38 
39  // resize marker array
40  if (last_step_plan_vis.markers.size() < step_plan_vis.markers.size())
41  last_step_plan_vis.markers.resize(step_plan_vis.markers.size());
42 
43  // overwrite old markers
44  for (size_t i = 0; i < step_plan_vis.markers.size(); i++)
45  last_step_plan_vis.markers[i] = step_plan_vis.markers[i];
46 
47  // set needless markers to be deleted
48  for (size_t i = step_plan_vis.markers.size(); i < last_step_plan_vis.markers.size(); i++)
49  last_step_plan_vis.markers[i].action = visualization_msgs::Marker::DELETE;
50 
51  // finally publish new markers
52  pub.publish(last_step_plan_vis);
53 
54  // delete old markers from array
55  last_step_plan_vis.markers.resize(step_plan_vis.markers.size());
56 }
57 
58 void publishUpperBody(ros::Publisher& pub, const msgs::StepPlan& step_plan, const geometry_msgs::Vector3& upper_body_size, const geometry_msgs::Vector3& upper_body_origin_shift, visualization_msgs::MarkerArray& last_upper_body_vis, bool add_step_index)
59 {
60  visualization_msgs::MarkerArray upper_body_vis;
61  msgs::stepPlanToUpperBodyMarkerArray(step_plan, upper_body_size, upper_body_origin_shift, upper_body_vis, add_step_index);
62 
63  // resize marker array
64  if (last_upper_body_vis.markers.size() < upper_body_vis.markers.size())
65  last_upper_body_vis.markers.resize(upper_body_vis.markers.size());
66 
67  // overwrite old markers
68  for (size_t i = 0; i < upper_body_vis.markers.size(); i++)
69  last_upper_body_vis.markers[i] = upper_body_vis.markers[i];
70 
71  // set needless markers to be deleted
72  for (size_t i = upper_body_vis.markers.size(); i < last_upper_body_vis.markers.size(); i++)
73  last_upper_body_vis.markers[i].action = visualization_msgs::Marker::DELETE;
74 
75  // finally publish new markers
76  pub.publish(last_upper_body_vis);
77 
78  // delete old markers from array
79  last_upper_body_vis.markers.resize(upper_body_vis.markers.size());
80 }
81 
82 void publishPath(ros::Publisher& pub, const msgs::StepPlan& step_plan)
83 {
84  nav_msgs::Path path;
85  msgs::stepPlanToPath(step_plan, path);
86  pub.publish(path);
87 }
88 
89 void clearFeet(ros::Publisher& pub, const std_msgs::Header& header)
90 {
91  visualization_msgs::MarkerArray marker_array;
92  visualization_msgs::Marker marker;
93 
94  marker.header = header;
95  marker.type = visualization_msgs::Marker::CUBE;
96  marker.action = visualization_msgs::Marker::DELETE;
97 
98  marker.id = 0;
99  marker_array.markers.push_back(marker);
100  marker.id++;
101  marker_array.markers.push_back(marker);
102 
103  pub.publish(marker_array);
104 }
105 
106 void clearMarkerArray(ros::Publisher& pub, visualization_msgs::MarkerArray& last_step_plan_vis)
107 {
108  for (std::vector<visualization_msgs::Marker>::iterator itr = last_step_plan_vis.markers.begin(); itr != last_step_plan_vis.markers.end(); itr++)
109  itr->action = visualization_msgs::Marker::DELETE;
110  pub.publish(last_step_plan_vis);
111 }
112 
113 void clearPath(ros::Publisher& pub, const std_msgs::Header& header)
114 {
115  nav_msgs::Path path;
116  path.header = header;
117  pub.publish(path);
118 }
119 
120 void publishRecentlyVistedSteps(ros::Publisher& pub, const std::vector<msgs::Step>& recently_visited_steps, const std_msgs::Header& header)
121 {
122  // populate point cloud
123  pcl::PointCloud<pcl::PointXYZ> point_cloud;
124  point_cloud.resize(recently_visited_steps.size());
125 
126  for (unsigned long i = 0; i < recently_visited_steps.size(); i++)
127  {
128  pcl::PointXYZ& point = point_cloud.points[i];
129  copyPosition(recently_visited_steps[i].foot.pose.position, point);
130  }
131 
132  // publish as point cloud msg
133  sensor_msgs::PointCloud2 point_cloud_msgs;
134  pcl::toROSMsg(point_cloud, point_cloud_msgs);
135  point_cloud_msgs.header = header;
136  pub.publish(point_cloud_msgs);
137 }
138 
139 void publishVistedSteps(ros::Publisher& pub, const std::vector<msgs::Step>& visited_steps, const std_msgs::Header& header)
140 {
141  // populate point cloud
142  pcl::PointCloud<pcl::PointXYZI> point_cloud;
143  point_cloud.resize(visited_steps.size());
144 
145  ros::Time current_time = ros::Time::now();
146  unsigned long i = 0;
147  for (std::vector<msgs::Step>::const_iterator itr = visited_steps.begin(); itr != visited_steps.end(); itr++, i++)
148  {
149  pcl::PointXYZI& point = point_cloud.points[i];
150  copyPosition(itr->foot.pose.position, point);
151  point.intensity = std::min(5.0, (current_time - itr->header.stamp).toSec());
152  }
153 
154  // publish as point cloud msg
155  sensor_msgs::PointCloud2 point_cloud_msgs;
156  pcl::toROSMsg(point_cloud, point_cloud_msgs);
157  point_cloud_msgs.header = header;
158  pub.publish(point_cloud_msgs);
159 }
160 
161 void publishVistedSteps(ros::Publisher& pub, const std::set<msgs::Step, StepMsgVisCompare>& visited_steps, const std_msgs::Header& header)
162 {
163  std::vector<msgs::Step> vec;
164  for (std::set<msgs::Step, StepMsgVisCompare>::const_iterator itr = visited_steps.begin(); itr != visited_steps.end(); itr++)
165  vec.push_back(*itr);
166  publishVistedSteps(pub, vec, header);
167 }
168 }
169 }
void publish(const boost::shared_ptr< M > &message) const
void publishVistedSteps(ros::Publisher &pub, const std::vector< msgs::Step > &visited_steps, const std_msgs::Header &header)
void publishFeet(ros::Publisher &pub, const msgs::Feet &feet, const geometry_msgs::Vector3 &foot_size, const std_msgs::ColorRGBA &color)
void publishUpperBody(ros::Publisher &pub, const msgs::StepPlan &step_plan, const geometry_msgs::Vector3 &upper_body_size, const geometry_msgs::Vector3 &upper_body_origin_shift, visualization_msgs::MarkerArray &last_upper_body_vis, bool add_step_index=true)
void publishRecentlyVistedSteps(ros::Publisher &pub, const std::vector< msgs::Step > &recently_visited_steps, const std_msgs::Header &header)
void publishGoal(ros::Publisher &pub, const msgs::Feet &feet, const geometry_msgs::Vector3 &foot_size)
void publishStart(ros::Publisher &pub, const msgs::Feet &feet, const geometry_msgs::Vector3 &foot_size)
void toROSMsg(const sensor_msgs::PointCloud2 &cloud, sensor_msgs::Image &image)
static Time now()
void publishStepPlan(ros::Publisher &pub, const msgs::StepPlan &step_plan, const geometry_msgs::Vector3 &foot_size, visualization_msgs::MarkerArray &last_step_plan_vis, bool add_step_index=true)
void clearPath(ros::Publisher &pub, const std_msgs::Header &header)
void clearMarkerArray(ros::Publisher &pub, visualization_msgs::MarkerArray &last_step_plan_vis)
void publishPath(ros::Publisher &pub, const msgs::StepPlan &step_plan)
void clearFeet(ros::Publisher &pub, const std_msgs::Header &header)


vigir_footstep_planning_lib
Author(s): Alexander Stumpf
autogenerated on Mon Jun 10 2019 15:47:33