update from DuongTD
This commit is contained in:
@@ -128,6 +128,7 @@ void Costmap2DROBOT::getParams(const std::string& config_file_name, robot::NodeH
|
||||
|
||||
robot::PluginLoaderHelper loader;
|
||||
|
||||
|
||||
if (nh.hasParam("rolling_window"))
|
||||
nh.getParam("rolling_window", rolling_window);
|
||||
|
||||
@@ -395,6 +396,7 @@ void Costmap2DROBOT::updateMap()
|
||||
double x = pose.pose.position.x,
|
||||
y = pose.pose.position.y,
|
||||
yaw = data_convert::getYaw(pose.pose.orientation);
|
||||
// robot::log_error("ROBOT POSE: %f | %f | %f",x,y,yaw);
|
||||
layered_costmap_->updateMap(x, y, yaw);
|
||||
robot_geometry_msgs::PolygonStamped footprint;
|
||||
footprint.header.frame_id = global_frame_;
|
||||
@@ -498,6 +500,13 @@ bool Costmap2DROBOT::getRobotPose(robot_geometry_msgs::PoseStamped& global_pose)
|
||||
{
|
||||
robot_geometry_msgs::PoseStamped robot_pose;
|
||||
robot_geometry_msgs::Pose pose_default;
|
||||
pose_default.orientation.x = 0;
|
||||
pose_default.orientation.y = 0;
|
||||
pose_default.orientation.z = 0;
|
||||
pose_default.orientation.w = 1;
|
||||
pose_default.position.x = 0;
|
||||
pose_default.position.y = 0;
|
||||
pose_default.position.z = 0;
|
||||
global_pose.pose = pose_default;
|
||||
robot_pose.pose = pose_default;
|
||||
|
||||
@@ -509,10 +518,22 @@ bool Costmap2DROBOT::getRobotPose(robot_geometry_msgs::PoseStamped& global_pose)
|
||||
try
|
||||
{
|
||||
// use current time if possible (makes sure it's not in the future)
|
||||
if (tf_.canTransform(global_frame_, robot_base_frame_, data_convert::convertTime(current_time)))
|
||||
if (tf_.canTransform(global_frame_, robot_base_frame_, tf3::Time()))
|
||||
{
|
||||
tf3::TransformStampedMsg transform = tf_.lookupTransform(global_frame_, robot_base_frame_, data_convert::convertTime(current_time));
|
||||
tf3::TransformStampedMsg transform = tf_.lookupTransform(global_frame_, robot_base_frame_,tf3::Time());
|
||||
tf3::doTransform(robot_pose, global_pose, transform);
|
||||
// robot::log_error("%s ||| %f | %f | %f ||| %f | %f | %f | %f", transform.child_frame_id.c_str(),
|
||||
// global_pose.pose.position.x,
|
||||
// global_pose.pose.position.y,
|
||||
// global_pose.pose.position.z,
|
||||
// global_pose.pose.orientation.x,
|
||||
// global_pose.pose.orientation.y,
|
||||
// global_pose.pose.orientation.z,
|
||||
// global_pose.pose.orientation.w);
|
||||
// transform.transform.rotation.x,
|
||||
// transform.transform.rotation.y,
|
||||
// transform.transform.rotation.z,
|
||||
// transform.transform.rotation.w);
|
||||
}
|
||||
// use the latest otherwise
|
||||
else
|
||||
@@ -521,7 +542,7 @@ bool Costmap2DROBOT::getRobotPose(robot_geometry_msgs::PoseStamped& global_pose)
|
||||
tf3::TransformStampedMsg transform = tf_.lookupTransform(
|
||||
global_frame_, // frame đích
|
||||
robot_base_frame_, // frame nguồn
|
||||
data_convert::convertTime(robot_pose.header.stamp)
|
||||
tf3::Time()
|
||||
);
|
||||
tf3::doTransform(robot_pose, global_pose, transform);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user