Skip to content

Commit cb7e4c7

Browse files
committed
add ugv rviz optimal list
1 parent 4be8ca1 commit cb7e4c7

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

Modules/communication/include/rviz_reduce_the_frequency.hpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class ReduceTheFrequency
4141

4242
void optimalListCb(const visualization_msgs::Marker::ConstPtr &msg);
4343

44+
void ugvOptimalListCb(const visualization_msgs::Marker::ConstPtr &msg);
45+
4446
void ugvPointCloudCb(const sensor_msgs::PointCloud2::ConstPtr &msg);
4547
void ugvOdomCb(const nav_msgs::Odometry::ConstPtr &msg);
4648
void ugvPathCb(const nav_msgs::Path::ConstPtr &msg);
@@ -60,7 +62,7 @@ class ReduceTheFrequency
6062
private:
6163
ros::Subscriber octomap_point_cloud_centers_sub_,occupancy_inflate_sub_,scan_sub_,
6264
scan_filtered_sub_,trajectory_sub_,odom_sub_,tf_sub_,uav_mesh_sub_,optimal_list_sub_,
63-
ugv_point_cloud_sub_,ugv_odom_sub_,ugv_path_sub_;
65+
ugv_point_cloud_sub_,ugv_odom_sub_,ugv_path_sub_,ugv_optimal_list_sub_;
6466

6567
// 1000ms
6668
ros::Publisher octomap_pub_,occupancy_inflate_pub_,scan_pub_,scan_filtered_pub_,
@@ -69,7 +71,7 @@ class ReduceTheFrequency
6971
// 500ms
7072
ros::Publisher trajectory_pub_,uav_mesh_pub_,ugv_path_pub_,ugv_odom_pub_;
7173
// 200ms
72-
ros::Publisher odom_pub_,tf_pub_,optimal_list_pub_;
74+
ros::Publisher odom_pub_,tf_pub_,optimal_list_pub_,ugv_optimal_list_pub_;
7375

7476
double uav_position_x = 0,uav_position_y = 0;
7577

@@ -84,6 +86,7 @@ class ReduceTheFrequency
8486
bool ugv_point_cloud_ready = false;
8587
bool ugv_odom_ready = false;
8688
bool ugv_path_ready = false;
89+
bool ugv_optimal_list_ready = false;
8790

8891
sensor_msgs::PointCloud2 octomap_point_cloud,octomap_compressed_point_cloud;
8992
sensor_msgs::PointCloud2 occupancy_inflate_point_cloud,occupancy_inflate_filtered_point_cloud,
@@ -94,7 +97,7 @@ class ReduceTheFrequency
9497
nav_msgs::Odometry odom,ugv_odom;
9598
tf2_msgs::TFMessage tf;
9699
visualization_msgs::Marker uav_mesh;
97-
visualization_msgs::Marker optimal_list;
100+
visualization_msgs::Marker optimal_list, ugv_optimal_list;
98101

99102
ros::Timer send_timer_1000MS,send_timer_200MS,send_timer_500MS,send_timer_50MS;
100103
};

Modules/communication/launch/bridge.launch

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<!-- 单机配置文件加载 -->
8484
<rosparam command="load" file="$(arg prometheus_moudles_url)$(arg uav_control_yaml)"/>
8585
<!-- 集群配置文件加载 -->
86-
<rosparam command="load" file="$(arg prometheus_moudles_url)$(arg swarm_control_yaml)"/>
86+
<!-- <rosparam command="load" file="$(arg prometheus_moudles_url)$(arg swarm_control_yaml)"/> -->
8787
<!-- 轨迹配置文件加载 -->
8888
<rosparam command="load" file="$(arg prometheus_moudles_url)$(arg uav_command_yaml)"/>
8989
</node>

Modules/communication/src/rviz_reduce_the_frequency.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ ReduceTheFrequency::ReduceTheFrequency(ros::NodeHandle &nh)
2525
ugv_point_cloud_sub_ = nh.subscribe("/ugv" + std::to_string(drone_id_) + "/cloud_registered",10,&ReduceTheFrequency::ugvPointCloudCb, this);
2626
ugv_odom_sub_ = nh.subscribe("/ugv" + std::to_string(drone_id_) + "/Odometry",10,&ReduceTheFrequency::ugvOdomCb, this);
2727
ugv_path_sub_ = nh.subscribe("/ugv" + std::to_string(drone_id_) + "/path",10,&ReduceTheFrequency::ugvPathCb, this);
28+
ugv_optimal_list_sub_ = nh.subscribe("/ugv" + std::to_string(drone_id_) + "_ego_planner_node/optimal_list", 10 , &ReduceTheFrequency::ugvOptimalListCb, this);
2829

2930
// 发布降低频率后的话题
3031
octomap_pub_ = nh.advertise<sensor_msgs::PointCloud2>("/uav" + std::to_string(drone_id_) + "/octomap_point_cloud_centers/reduce_the_frequency", 100);
@@ -47,6 +48,7 @@ ReduceTheFrequency::ReduceTheFrequency(ros::NodeHandle &nh)
4748
ugv_point_cloud_pub_ = nh.advertise<sensor_msgs::PointCloud2>("/ugv" + std::to_string(drone_id_) + "/cloud_registered/reduce_the_frequency/compressed", 100);
4849
ugv_odom_pub_ = nh.advertise<nav_msgs::Odometry>("/ugv" + std::to_string(drone_id_) + "/Odometry/reduce_the_frequency", 100);
4950
ugv_path_pub_ = nh.advertise<nav_msgs::Path>("/ugv" + std::to_string(drone_id_) + "/path/reduce_the_frequency", 100);
51+
ugv_optimal_list_pub_ = nh.advertise<visualization_msgs::Marker>("/ugv" + std::to_string(drone_id_) + "_ego_planner_node/optimal_list/reduce_the_frequency", 100);
5052

5153
send_timer_1000MS = nh.createTimer(ros::Duration(1.0), &ReduceTheFrequency::send1000MS, this);
5254
usleep(10000);
@@ -146,6 +148,12 @@ void ReduceTheFrequency::send50MS(const ros::TimerEvent &time_event)
146148
optimal_list_pub_.publish(optimal_list);
147149
optimal_list_ready = false;
148150
}
151+
usleep(100000);
152+
if(ugv_optimal_list_ready)
153+
{
154+
ugv_optimal_list_pub_.publish(ugv_optimal_list);
155+
ugv_optimal_list_ready = false;
156+
}
149157
}
150158

151159
void ReduceTheFrequency::octomapPointCloudCentersCb(const sensor_msgs::PointCloud2::ConstPtr &msg)
@@ -233,6 +241,12 @@ void ReduceTheFrequency::ugvPathCb(const nav_msgs::Path::ConstPtr &msg)
233241
ugv_path_ready = true;
234242
}
235243

244+
void ReduceTheFrequency::ugvOptimalListCb(const visualization_msgs::Marker::ConstPtr &msg)
245+
{
246+
ugv_optimal_list = *msg;
247+
ugv_optimal_list_ready = true;
248+
}
249+
236250
sensor_msgs::PointCloud2 ReduceTheFrequency::filtered(const sensor_msgs::PointCloud2 msg)
237251
{
238252
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);

0 commit comments

Comments
 (0)