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
11 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
14 from opencv_apps.msg
import CircleArrayStamped
20 from miro_constants
import miro
22 from datetime
import datetime
36 self.
rate = rospy.get_param(
'rate',200)
80 print "NO DETECTION IN RIGHT CAMERA"
87 print "BALL DETECTED IN RIGHT CAMERA"
101 print "NO DETECTION IN LEFT CAMERA"
108 print "BALL DETECTED IN LEFT CAMERA"
117 r = rospy.Rate(self.
rate)
118 q = platform_control()
120 while not rospy.is_shutdown():
126 print "DETECTION COMPLETE"
127 q.body_vel.linear.x = 100.0
128 q.body_vel.angular.z = 0.0
129 q.lights_raw = [255,150,0,255,150,0,255,150,0,255,150,0,255,150,0,255,150,0]
130 self.pub_follow_ball.publish(q)
137 print "NO COMPLETE DETECTION"
139 q.body_vel.linear.x = 0.0
140 q.body_vel.angular.z = -0.2
142 q.body_vel.linear.x = 0.0
143 q.body_vel.angular.z = 0.2
145 q.body_vel.linear.x = 0.0
146 q.body_vel.angular.z = 0.0
148 self.pub_follow_ball.publish(q)
152 if __name__==
'__main__':
153 rospy.init_node(
'play')
155 ball.compared_detection()
pub_follow_ball
Publisher to the topic /miro_play a message of type platform_control which corresponds to the "Play" ...
count_no_right
Number of negative detection on Right camera.
detect_left
Initialization of the CircleArrayStamped variable in the Left callback.
ball_left
Flag for Red Ball detected in Leftcamera.
count_no_left
Number of negative detection on Left camera.
ball
Flag for Red Ball detected in Both cameras.
def callback_camera_right
Callback that receive the message that contains the information of the circles detected in the Right ...
def callback_camera_left
Callback that receive the message that contains the information of the circles detected in the Left c...
sub_camera_left
Subscriber to the topic /right/hough_circles/circles a message of type CircleArrayStamped that cointa...
The class BallDetection implements the detection of the circles in the cameras and the robot behavior...
count_left
Number of positive detection on Left camera.
count_right
Number of positive detection on Right camera.
count_ball
Number of positive detection on Both cameras.
detect_right
Initialization of the CircleArrayStamped variable in the Right callback.
sub_camera_right
Subscriber to the topic /right/hough_circles/circles a message of type CircleArrayStamped that cointa...
ball_right
Flag for Red Ball detected in Right camera.
def compared_detection
Function that evaluate the detection of the ball and publish a message of type platform_control in or...