Auto Ware 代码解析系列 lane_select节点
来源:互联网 发布:知乎折叠是什么意思 编辑:程序博客网 时间:2024/05/19 17:56
/// get closest waypoint from current poseint32_t getClosestWaypointNumber(const waypoint_follower::lane ¤t_lane, const geometry_msgs::Pose ¤t_pose, const geometry_msgs::Twist ¤t_velocity, const int32_t previous_number, const double distance_threshold){ if (current_lane.waypoints.empty()) return -1; std::vector<uint32_t> idx_vec; // if previous number is -1, search closest waypoint from waypoints in front of current pose if (previous_number == -1) { idx_vec.reserve(current_lane.waypoints.size()); for (uint32_t i = 0; i < current_lane.waypoints.size(); i++) { geometry_msgs::Point converted_p = convertPointIntoRelativeCoordinate(current_lane.waypoints.at(i).pose.pose.position, current_pose); double angle = getRelativeAngle(current_lane.waypoints.at(i).pose.pose, current_pose); if (converted_p.x > 0 && angle < 90) idx_vec.push_back(i); } } else { if (distance_threshold < getTwoDimensionalDistance(current_lane.waypoints.at(previous_number).pose.pose.position, current_pose.position)) { ROS_WARN("Current_pose is far away from previous closest waypoint. Initilized..."); return -1; } double ratio = 3; double minimum_dt = 2.0; double dt = current_velocity.linear.x * ratio > minimum_dt ? current_velocity.linear.x * ratio : minimum_dt; auto range_max = static_cast<uint32_t>(previous_number + dt) < current_lane.waypoints.size() ? static_cast<uint32_t>(previous_number + dt) : current_lane.waypoints.size(); for (uint32_t i = static_cast<uint32_t>(previous_number); i < range_max; i++) { geometry_msgs::Point converted_p = convertPointIntoRelativeCoordinate(current_lane.waypoints.at(i).pose.pose.position, current_pose); double angle = getRelativeAngle(current_lane.waypoints.at(i).pose.pose, current_pose); if (converted_p.x > 0 && angle < 90) idx_vec.push_back(i); } } if (idx_vec.empty()) return -1; std::vector<double> dist_vec; dist_vec.reserve(idx_vec.size()); for (const auto &el : idx_vec) { double dt = getTwoDimensionalDistance(current_pose.position, current_lane.waypoints.at(el).pose.pose.position); dist_vec.push_back(dt); } std::vector<double>::iterator itr = std::min_element(dist_vec.begin(), dist_vec.end()); int32_t found_number = idx_vec.at(static_cast<uint32_t>(std::distance(dist_vec.begin(), itr))); return found_number;}
阅读全文
0 0
- Auto Ware 代码解析系列 lane_select节点
- Auto Ware 代码解析系列-can_info_translator节点
- Auto Ware 代码解析系列-pure_pursuit节点
- Auto Ware 代码解析系列-twist_filter节点
- Auto Ware 代码解析系列-astar_planner节点
- hibernate.hbm2ddl.auto节点配置
- hibernate.hbm2ddl.auto节点配置
- Auto Complete解析
- iOS 8 Auto Layout界面自动布局系列3-使用代码添加布局约束
- Auto Layout 界面自动布局系列 (使用代码添加布局约束)
- iOS 8 Auto Layout界面自动布局系列3-使用代码添加布局约束
- iOS 8 Auto Layout界面自动布局系列3-使用代码添加布局约束
- iOS 8 Auto Layout界面自动布局系列3-使用代码添加布局约束
- iOS 8 Auto Layout界面自动布局系列3-使用代码添加布局约束
- iOS 8 Auto Layout界面自动布局系列3-使用代码添加布局约束
- iOS 8 Auto Layout界面自动布局系列3-使用代码添加布局约束
- Core Ware
- my ware
- Kotlin Android Studio入门学习研究
- 怎样成为一个合格的程序员
- Java开发中最常用的Linux命令整理
- 书签整理
- Ruby 中 sort方法、reverse方法、shuffle方法
- Auto Ware 代码解析系列 lane_select节点
- Linux--线程池与进程池及线程池的简单实现
- thinkphp整合系列之融云即时通讯在线聊天
- 关于常量成员函数(const member function)
- Android各种访问权限Permission详解
- android平板以太网设置
- PCA
- STM32 USB设计原理
- Linux 环境下 Java jdk 安装方法 注:此方法为 jdk.bin类型的jdk文件