6 from std_msgs.msg
import String
7 from sensor_msgs.msg
import Image,CompressedImage,Range,Imu
8 from geometry_msgs.msg
import Twist,Pose
12 from miro_msgs.msg
import platform_config,platform_sensors,platform_state,platform_mics,platform_control,core_state,core_control,core_config,bridge_config,bridge_stream
15 from opencv_apps.msg
import CircleArrayStamped
21 from miro_constants
import miro
23 from datetime
import datetime
29 for i
in range(0, len(x)):
32 s = s + f.format(x[i])
47 self.
rate = rospy.get_param(
'rate',200)
68 self.
h1 = int(fmt(datasensor.touch_head,
'{0:.0f}')[0])
69 self.
h2 = int(fmt(datasensor.touch_head,
'{0:.0f}')[3])
70 self.
h3 = int(fmt(datasensor.touch_head,
'{0:.0f}')[6])
71 self.
h4 = int(fmt(datasensor.touch_head,
'{0:.0f}')[9])
72 self.
b1 = int(fmt(datasensor.touch_body,
'{0:.0f}')[0])
73 self.
b2 = int(fmt(datasensor.touch_body,
'{0:.0f}')[3])
74 self.
b3 = int(fmt(datasensor.touch_body,
'{0:.0f}')[6])
75 self.
b4 = int(fmt(datasensor.touch_body,
'{0:.0f}')[9])
82 r = rospy.Rate(self.
rate)
83 q = platform_control()
85 while not rospy.is_shutdown():
89 if self.
h1 == 1
or self.
h2 == 1
or self.
h3 == 1
or self.
h4 == 1:
90 q.eyelid_closure = 0.4
91 q.lights_raw = [255,64,64,255,64,64,255,64,64,255,64,64,255,64,64,255,64,64]
93 q.body_config = [0.2,0.5,0.2,-0.5]
94 q.body_config_speed = [0.0,-1.0,-1.0,-1.0]
96 elif self.
b1 == 1
or self.
b2 == 1
or self.
b3 == 1
or self.
b4 == 1:
97 q.eyelid_closure = 0.1
98 q.lights_raw = [255,129,0,255,129,0,255,129,0,255,129,0,255,129,0,255,129,0]
100 q.body_config = [0.0,0.29,-0.6,-0.26]
101 q.body_config_speed = [0.0,-1.0,-1.0,-1.0]
102 q.ear_rotate = [0.5,0.5]
104 q.eyelid_closure = 0.0
105 q.body_config = [0.0,0.25,0.0,-0.25]
106 q.body_config_speed = [0.0,-1.0,-1.0,-1.0]
108 q.lights_raw = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
109 q.ear_rotate = [0.0,0.0]
110 self.pub_platform_control.publish(q)
115 if __name__==
'__main__':
116 rospy.init_node(
'good')
b1
Initialization of bodycapacitive sensors.
h1
Initialization of head capacitive sensors.
def callback_touch
Callback function that saves in class' attributes the capacitive sensor readings converted.
The class GoodMode implements a cheerful behavior and allows to interact with Miro's capacitive body...
def miro_good
Function that implements different behavior and lightening pattern depending on where it is touched...
sub_sensors_touch
Subscriber to the topic /miro/rob01/platform/sensors a message of type platform_sensors that cointain...
pub_platform_control
Publisher to the topic /miro_good a message of type platform_control which corresponds to the "Good" ...