4 import roslib; roslib.load_manifest(
'kobuki_node')
7 from kobuki_msgs.msg
import DockInfraRed
8 from kobuki_msgs.msg
import SensorState
13 rospy.init_node(
"dock_ir_intepreter", anonymous=
True)
16 self.
window = rospy.get_param(
'~window',10)
17 self.
oneline = rospy.get_param(
'~oneline',
False)
29 array = [ ord(x)
for x
in data.data]
32 self.stack.append(array)
36 head =
"window: {0:d}/{1:d} ".format(len(self.
stack),self.
window)
37 head +=
"charger: {0:d} ".format(self.
charger)
38 head +=
"[ON] " if self.
charger else "[ ] " 40 head +=
"L" if self.
bumper&4
else "~" 41 head +=
"C" if self.
bumper&2
else "~" 42 head +=
"R" if self.bumper&1 else "~"
46 for i
in range(len(self.
stack)):
48 array[j] |= self.
stack[i][j]
51 delimiter =
" " if self.
oneline else "\n" 53 ostr_top =
"[far ] "; ostr_bot =
"[near] "; ostr_bin=
"[bin ] "; ostr_dec=
"[dec ] " 62 ostr_top +=
" L" if top&2
else " ~" 63 ostr_top +=
"|C" if top&1
else "|~" 64 ostr_top +=
"|R" if top&4
else "|~" 65 ostr_bot +=
" L" if bot&1
else " ~" 66 ostr_bot +=
"|C" if bot&2
else "|~" 67 ostr_bot +=
"|R" if bot&4
else "|~" 68 ostr_top +=
" "; ostr_bot +=
" " 69 ostr_bin +=
"{0:#08b}".format(ir)[2:] +
" " 71 ostr = head + delimiter + ostr_top + delimiter + ostr_bot + delimiter + ostr_bin
76 if __name__ ==
'__main__':
80 print "It converts dock_ir data to human friendly format." 83 except rospy.ROSInterruptException:
pass
def SensorStateCallback(self, data)
def DockIRCallback(self, data)