MCPcopy Create free account
hub / github.com/RoboMaster/RoboRTS / SetGlobalFrame

Method SetGlobalFrame

roborts_costmap/src/observation_buffer.cpp:78–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78bool ObservationBuffer::SetGlobalFrame(const std::string new_global_frame)
79{
80 ros::Time transform_time = ros::Time::now();
81 std::string tf_error;
82
83 if (!tf_.waitForTransform(new_global_frame, global_frame_, transform_time, ros::Duration(tf_tolerance_),
84 ros::Duration(0.01), &tf_error))
85 {
86 ROS_ERROR("Transform between %s and %s with tolerance %.2f failed: %s.", new_global_frame.c_str(),
87 global_frame_.c_str(), tf_tolerance_, tf_error.c_str());
88 return false;
89 }
90
91 list<Observation>::iterator obs_it;
92 for (obs_it = observation_list_.begin(); obs_it != observation_list_.end(); ++obs_it)
93 {
94 try
95 {
96 Observation& obs = *obs_it;
97
98 geometry_msgs::PointStamped origin;
99 origin.header.frame_id = global_frame_;
100 origin.header.stamp = transform_time;
101 origin.point = obs.origin_;
102
103 // we need to transform the origin of the observation to the new global frame
104 tf_.transformPoint(new_global_frame, origin, origin);
105 obs.origin_ = origin.point;
106
107 // we also need to transform the cloud of the observation to the new global frame
108 pcl_ros::transformPointCloud(new_global_frame, *obs.cloud_, *obs.cloud_, tf_);
109 }
110 catch (TransformException& ex)
111 {
112 ROS_ERROR("TF Error attempting to transform an observation from %s to %s: %s", global_frame_.c_str(),
113 new_global_frame.c_str(), ex.what());
114 return false;
115 }
116 }
117
118 // now we need to update our global_frame member
119 global_frame_ = new_global_frame;
120 return true;
121}
122
123void ObservationBuffer::BufferCloud(const sensor_msgs::PointCloud2& cloud)
124{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected