35 import roslib; roslib.load_manifest(
'kobuki_testsuite')
38 from geometry_msgs.msg
import Twist
39 from nav_msgs.msg
import Odometry
40 from sensor_msgs.msg
import Imu
41 from kobuki_msgs.msg
import BumperEvent
42 from kobuki_msgs.msg
import Sound
47 rospy.init_node(
"test_translation")
48 rospy.loginfo(
'hello kobuki')
71 self.twist.linear.x = 0
72 self.twist.linear.y = 0
73 self.twist.linear.z = 0
74 self.twist.angular.x = 0
75 self.twist.angular.y = 0
76 self.twist.angular.z = 0
79 self.
cmd_vel_pub = rospy.Publisher(
"/mobile_base/commands/velocity", Twist)
87 self.
odom = data.pose.pose.position.x
94 self.
state = data.state
98 self.
imu = data.orientation.w
107 self.twist.linear.x = 0.02
108 self.cmd_vel_pub.publish(self.
twist)
111 self.twist.linear.x = 0
112 self.cmd_vel_pub.publish(self.
twist)
114 self.twist.linear.x = 0.2
115 self.cmd_vel_pub.publish(self.
twist)
118 while not self.
state == 0:
119 rospy.loginfo(
"bumper event")
120 self.twist.linear.x = 0
121 self.cmd_vel_pub.publish(self.
twist)
122 print(
'---- bumper event ----')
126 rospy.loginfo(
"info_odom : %.4f start_odom : %.4f dist_percent %.4f cmd_vel : %.4f ", self.
odom, self.
last_odom, (self.
odom -self.
last_odom)*100, self.twist.linear.x)
129 if(self.
state == BumperEvent.RELEASED):
133 if(self.
bumper == BumperEvent.LEFT):
135 elif(self.
bumper == BumperEvent.CENTER):
139 rospy.loginfo(
"%s bumper is %s", bumper, state)
142 print "imu : %.6f"%self.
imu 148 while not rospy.is_shutdown():
149 test_trans_obj.ShowOdomInfo()
162 if __name__ ==
'__main__':
def OdomInfoCallback(self, data)
def BumperEventCallback(self, data)
def ImuInfoCallback(self, data)
def ShowBumperEventInfo(self)