Commit cf8f2d04 authored by xiaoqiang_user's avatar xiaoqiang_user

add keep running flag

parent 2912cc1e
<?xml version="1.0"?>
<package>
<package format="2">
<name>rplidar_ros</name>
<version>1.9.0</version>
<description>The rplidar ros package, support rplidar A2/A1 and A3</description>
......@@ -12,9 +12,9 @@
<build_depend>rosconsole</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>std_srvs</build_depend>
<run_depend>roscpp</run_depend>
<run_depend>rosconsole</run_depend>
<run_depend>sensor_msgs</run_depend>
<run_depend>std_srvs</run_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rosconsole</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>std_srvs</exec_depend>
</package>
......@@ -31,6 +31,7 @@ if __name__ == "__main__":
rospy.init_node("rplidar_manager")
rospy.Subscriber("/scan", rospy.AnyMsg, get_scan)
rospy.Subscriber("/galileo/status", GalileoStatus, get_galileo_status)
rospy.set_param("~keep_running", True)
uuid = roslaunch.rlutil.get_or_generate_uuid(None, False)
roslaunch.configure_logging(uuid)
rplidar_launch = roslaunch.parent.ROSLaunchParent(
......@@ -39,11 +40,15 @@ if __name__ == "__main__":
rospy.loginfo("rplidar started")
while not rospy.is_shutdown():
time.sleep(5)
keep_running_flag = rospy.get_param("~keep_running", True)
# 处于导航状态下且无法收到雷达数据
if int(time.time()) - LAST_UPDATE_TIME > 5 and VISUAL_FLAG:
if int(time.time()) - LAST_UPDATE_TIME > 5 and VISUAL_FLAG and keep_running_flag:
rospy.logerr("restart rplidar node")
rplidar_launch.shutdown()
roslaunch.configure_logging(uuid)
rplidar_launch = roslaunch.parent.ROSLaunchParent(
uuid, ["/home/xiaoqiang/Documents/ros/src/rplidar_ros/launch/rplidar.launch"])
rplidar_launch.start()
# 在停用状态下却有雷达数据
if int(time.time()) - LAST_UPDATE_TIME < 5 and not keep_running_flag:
rplidar_launch.shutdown()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment