12 from geometry_msgs.msg
import Twist, Pose
13 from nav_msgs.msg
import Odometry
14 from kobuki_msgs.msg
import CliffEvent
23 Travels forward a set distance. 26 init(speed,distance) : (re)initialise parameters 28 execute() - pass this to a thread to run 38 def __init__(self, cmd_vel_topic, odom_topic, cliff_sensor_topic):
49 def init(self, speed, distance):
57 self.cmd_vel_publisher.unregister()
58 self.odom_subscriber.unregister()
65 Drop this into threading.Thread or QThread for execution 68 rospy.logerr(
"Kobuki TestSuite: already executing a motion, ignoring the request")
74 current_distance_sq = 0.0
77 while not self.
_stop and not rospy.is_shutdown():
78 if current_distance_sq > distance_sq:
81 current_distance_sq = (self._current_pose.position.x - self._starting_pose.position.x)*(self._current_pose.position.x - self._starting_pose.position.x) + \
82 (self._current_pose.position.y - self._starting_pose.position.y)*(self._current_pose.position.y - self._starting_pose.position.y)
84 print(
"Distance %s"%math.sqrt(current_distance_sq))
93 self.cmd_vel_publisher.publish(cmd)
95 if not rospy.is_shutdown():
98 self.cmd_vel_publisher.publish(cmd)
106 rospy.loginfo(
"Kobuki Testsuite: cliff event on sensor [%s]"%str(data.sensor))
107 if data.state == CliffEvent.CLIFF:
108 if not rospy.is_shutdown():
111 self.cmd_vel_publisher.publish(cmd)
def init(self, speed, distance)
def cliff_sensor_callback(self, data)
Ros Callbacks.
def odometry_callback(self, data)
def __init__(self, cmd_vel_topic, odom_topic, cliff_sensor_topic)