10 from math
import degrees, radians
16 from tf.transformations
import euler_from_quaternion
17 from geometry_msgs.msg
import Twist
18 from nav_msgs.msg
import Odometry
19 from kobuki_msgs.msg
import BumperEvent, CliffEvent
27 Implements a safe wandering random motion using bump and cliff sensors. 30 init(speed,distance) : (re)initialise parameters 32 execute() - pass this to a thread to run 41 Initialise everything, then starts with start() 44 start() - start to wander. 45 stop() - stop wandering. 46 set_vels(lin_xvel,stepback_xvel,ang_zvel) 51 def __init__(self, cmd_vel_topic, odom_topic, bumper_topic, cliff_topic ):
69 def init(self, speed, stepback_speed, angular_speed):
80 self.odom_subscriber.unregister()
81 self.bumper_subscriber.unregister()
82 self.cliff_subscriber.unregister()
86 Lowest level of command - i.e. this is where the fine grained looping happens 87 so we check for aborts here. Don't waste time doing anything if this is the case. 89 if self.
_stop or rospy.is_shutdown():
91 self.cmd_vel_publisher.publish(twist)
105 for i
in range(0,35):
131 rospy.logerr(
"Kobuki TestSuite: already executing wandering, ignoring the request")
139 if not rospy.is_shutdown():
142 self.cmd_vel_publisher.publish(cmd)
149 quat = data.pose.pose.orientation
150 q = [quat.x, quat.y, quat.z, quat.w]
151 roll, pitch, yaw = euler_from_quaternion(q)
156 if data.state == BumperEvent.PRESSED:
158 if data.bumper == BumperEvent.LEFT:
160 elif data.bumper == BumperEvent.RIGHT:
163 self.
theta_goal = utils.wrap_to_pi(self.
theta + 3.141592*random.uniform(-1.0, 1.0))
166 if data.state == CliffEvent.CLIFF:
169 if data.sensor == CliffEvent.LEFT:
171 elif data.sensor == CliffEvent.RIGHT:
174 self.
theta_goal = utils.wrap_to_pi(self.
theta + 3.141592*random.uniform(-1.0, 1.0))
def init(self, speed, stepback_speed, angular_speed)
def cliff_event_callback(self, data)
def odometry_callback(self, data)
Callbacks.
def __init__(self, cmd_vel_topic, odom_topic, bumper_topic, cliff_topic)
def bumper_event_callback(self, data)