footstep_planning_vis_node.cpp
Go to the documentation of this file.
2 
4 
5 
6 
8 {
10 {
11  ros::NodeHandle nh;
12 
13  // load param
17 
18  // subscribe topics
19  step_plan_request_vis_sub = nh.subscribe<msgs::StepPlanRequest>("vis/step_plan_request", 1, &FootstepPlanningVisNode::stepPlanRequestVisCallback, this);
20  step_plan_vis_sub = nh.subscribe<msgs::StepPlan>("vis/step_plan", 1, &FootstepPlanningVisNode::stepPlanVisCallback, this);
21  planning_feedback_sub = nh.subscribe<msgs::PlanningFeedback>("planning_feedback", 1, &FootstepPlanningVisNode::planningFeedbackCallback, this);
22 
23  // publish topics
24  step_plan_vis_pub = nh.advertise<visualization_msgs::MarkerArray>("vis/step_plan_vis", 1, true);
25  upper_body_vis_pub = nh.advertise<visualization_msgs::MarkerArray>("vis/upper_body_vis", 1, true);
26  step_plan_path_pub = nh.advertise<nav_msgs::Path>("vis/step_plan_path", 1, true);
27  start_feet_pose_pub = nh.advertise<visualization_msgs::MarkerArray>("vis/start_feet_pose", 1, true);
28  goal_feet_pose_pub = nh.advertise<visualization_msgs::MarkerArray>("vis/goal_feet_pose", 1, true);
29  visited_steps_pub = nh.advertise<sensor_msgs::PointCloud2>("feedback/visited_steps", 1);
30  total_visited_steps_pub = nh.advertise<sensor_msgs::PointCloud2>("feedback/total_visited_steps", 1);
31  current_step_plan_pub = nh.advertise<visualization_msgs::MarkerArray>("feedback/current_step_plan", 1);
32 
33  // start service clients
34  transform_foot_pose_client = nh.serviceClient<msgs::TransformFootPoseService>("transform_foot_pose");
35  transform_feet_poses_client = nh.serviceClient<msgs::TransformFeetPosesService>("transform_feet_poses");
36  transform_step_plan_client = nh.serviceClient<msgs::TransformStepPlanService>("transform_step_plan");
37 }
38 
40 {
41 }
42 
43 void FootstepPlanningVisNode::stepPlanRequestVisCallback(const msgs::StepPlanRequestConstPtr& step_plan_request)
44 {
45  // clear old vis
46  clearVisualization(step_plan_request->header);
47 
48  msgs::Feet start = step_plan_request->start;
49  msgs::Feet goal = step_plan_request->goal;
50 
51  // transform start pose to planner frame and visualize
52  if (!start.header.frame_id.empty())
53  {
56  }
57 
58  // transform goal pose to planner frame and visualize
59  if (!goal.header.frame_id.empty())
60  {
63  }
64 }
65 
66 void FootstepPlanningVisNode::stepPlanVisCallback(const msgs::StepPlanConstPtr& step_plan)
67 {
68  // transform to planner frame
69  msgs::StepPlan step_plan_t = *step_plan;
71 
72  // visualize plan
76 }
77 
78 void FootstepPlanningVisNode::planningFeedbackCallback(const msgs::PlanningFeedbackConstPtr& planning_feedback)
79 {
80  // collect data
81  for (std::vector<msgs::Step>::const_iterator itr = planning_feedback->visited_steps.begin(); itr != planning_feedback->visited_steps.end(); itr++)
82  {
83  msgs::Step step = *itr;
84  total_visited_steps.erase(step);
85  total_visited_steps.insert(step);
86  }
87 
89  vis::publishRecentlyVistedSteps(visited_steps_pub, planning_feedback->visited_steps, planning_feedback->header);
90 
93 
94  msgs::StepPlan current_step_plan = planning_feedback->current_step_plan;
97 }
98 
99 void FootstepPlanningVisNode::clearVisualization(const std_msgs::Header& header)
100 {
101  total_visited_steps.clear();
102 
103  // last start and goal pose from request
106 
107  // last planner feedback
109  sensor_msgs::PointCloud2 point_cloud_msgs;
110  point_cloud_msgs.header = header;
111  visited_steps_pub.publish(point_cloud_msgs);
112  total_visited_steps_pub.publish(point_cloud_msgs);
113 
114  // last solution
118 }
119 }
120 
121 int main(int argc, char **argv)
122 {
123  ros::init(argc, argv, "footstep_planning_vis_node");
125  ros::spin();
126 
127  return 0;
128 }
bool getFootSize(ros::NodeHandle &nh, geometry_msgs::Vector3 &foot_size)
Definition: helper.cpp:130
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
void stepPlanVisCallback(const msgs::StepPlanConstPtr &step_plan)
bool getUpperBodyOriginShift(ros::NodeHandle &nh, geometry_msgs::Vector3 &upper_body_origin_shift)
Definition: helper.cpp:140
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void stepPlanRequestVisCallback(const msgs::StepPlanRequestConstPtr &step_plan_request)
msgs::ErrorStatus transformToPlannerFrame(T &p, ros::ServiceClient &foot_pose_transformer_client)
Definition: helper.h:125
void publishVistedSteps(ros::Publisher &pub, const std::vector< msgs::Step > &visited_steps, const std_msgs::Header &header)
ROSCPP_DECL void spin(Spinner &spinner)
int main(int argc, char **argv)
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)
bool getUpperBodySize(ros::NodeHandle &nh, geometry_msgs::Vector3 &upper_body_size)
Definition: helper.cpp:135
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
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)
unsigned int step
uint32_t getNumSubscribers() const
std::set< msgs::Step, vis::StepMsgVisCompare > total_visited_steps
void planningFeedbackCallback(const msgs::PlanningFeedbackConstPtr &planning_feedback)
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