5 from geometry_msgs.msg
import Twist
6 from math
import radians, pi
7 from std_msgs.msg
import Bool
11 rospy.init_node(
'BarDetectChanger', anonymous=
False)
13 bar_disabled = rospy.get_param(
"~barDetectFlag", 1.0)
16 self.
cmd_vel_pub = rospy.Publisher(
'cmd_vel', Twist, queue_size=1)
17 self.
barDetectFlag_pub = rospy.Publisher(
'/xiaoqiang_driver/infrared_sensor', Bool, queue_size=1)
18 if bar_disabled == 1 :
20 rospy.loginfo(
"Stopping the robot...")
22 self.cmd_vel_pub.publish(Twist())
24 rospy.loginfo(
"disable BarDetectFlag")
26 while not rospy.is_shutdown():
29 self.barDetectFlag_pub.publish(flag)
34 rospy.loginfo(
"Stopping the robot...")
36 self.cmd_vel_pub.publish(Twist())
37 rospy.loginfo(
"enable BarDetectFlag")
41 self.barDetectFlag_pub.publish(flag)
44 if __name__ ==
'__main__':
47 except rospy.ROSInterruptException:
48 rospy.loginfo(
"BarDetectChanger finished.")