Browse Source

更新雷达跟随:距离大于两米时停止,最大角速度调为0.8,雷达范围为-90-90.

zhuo 4 years ago
parent
commit
11a8e16f05

+ 1 - 1
src/robot_follower/launch/laser_follower.launch

@@ -1,5 +1,5 @@
 <launch>
-  <include file='$(find robot_navigation)/launch/ydlidar_X2L.launch' />
+  <include file='$(find robot_follower)/launch/ydlidar_X2L.launch' />
   <include file='$(find robot_follower)/launch/nodes/laserTracker.launch' />
   <include file='$(find robot_follower)/launch/nodes/follower.launch' />
 </launch>

+ 1 - 1
src/robot_follower/launch/nodes/follower.launch

@@ -3,7 +3,7 @@
     <!-- switchMode: (if true one button press will change betwenn active, not active. If false the button will have to be kept pressed all the time to be active -->
     <param name="switchMode" value="True" type="bool" />
     <!-- maximal speed (angular and linear both), tartet distance: the robot will try to keep this fixed distance -->
-    <param name='maxSpeed' value='0.4' type='double' />
+    <param name='maxSpeed' value='0.8' type='double' />
     <param name='targetDist' value='0.5' type='double' />
     <!-- index of the button in the buttons field of the joy message from the ps3 controller, that switches active/inactive  -->
     <param name='controllButtonIndex' value='-4' type='int' />

+ 28 - 0
src/robot_follower/launch/ydlidar_X2L.launch

@@ -0,0 +1,28 @@
+<!--
+  Copyright: 2016-2020 www.corvin.cn ROS小课堂
+  Description:加载启动EAI的X2L雷达.
+  Author: corvin
+  History:
+    20200325: init this file.
+-->
+<launch>
+  <node name="ydlidar_X2L_node" pkg="ydlidar_ros" type="ydlidar_node" output="screen" respawn="false" >
+    <param name="port"      type="string" value="/dev/ydlidar"/>
+    <param name="baudrate"  type="int"    value="115200"/>
+    <param name="frame_id"  type="string" value="lidar"/>
+
+    <param name="resolution_fixed" type="bool"  value="true"/>
+    <param name="auto_reconnect"   type="bool"  value="true"/>
+
+    <param name="reversion"    type="bool"   value="false"/>
+    <param name="angle_min"    type="double" value="-90" />
+    <param name="angle_max"    type="double" value="90" />
+    <param name="range_min"    type="double" value="0.1" />
+    <param name="range_max"    type="double" value="8.0" />
+    <param name="ignore_array" type="string" value="" />
+
+    <param name="frequency"    type="double" value="7"/>
+    <param name="samp_rate"    type="int"    value="3"/>
+    <param name="isSingleChannel" type="bool"  value="true"/>
+  </node>
+</launch>

+ 5 - 1
src/robot_follower/scripts/follower.py

@@ -4,7 +4,7 @@
 '''
 Author: adam_zhuo
 Date: 2020-09-14 13:56:07
-LastEditTime: 2020-09-18 15:56:16
+LastEditTime: 2020-09-18 18:01:10
 LastEditors: Please set LastEditors
 Description: laser_follow
 FilePath: /blackTornadoRobot/src/robot_follower/scripts/follower.py
@@ -60,6 +60,10 @@ class Follower:
 		distance = position.distance
 
 		rospy.logwarn('Angle: {}, Distance: {}, '.format(angleX, distance))
+
+		if distance >= 2:
+			self.stopMoving()
+			return
 		
 		# call the PID controller to update it and get new speeds
 		[uncliped_ang_speed, uncliped_lin_speed] = self.PID_controller.update([angleX, distance])