def __init__(self): rospy.init_node('beacon_node') self.camera_subscriber = rospy.Subscriber("/camera/rgb/image_raw", Image, self.camera_callback) self.lidar_subscriber = rospy.Subscriber('/scan', LaserScan, self.callback_lidar) self.cvbridge_interface = CvBridge() self.lidar = {'range': 0.0, 'closest': 0.0, 'closest angle': 0} self.robot_controller = MoveTB3() self.turn_vel_fast = -0.5 self.turn_vel_slow = -0.1 self.robot_controller.set_move_cmd(0.0, self.turn_vel_fast) self.move_rate = '' # fast, slow or stop self.stop_counter = 0 self.start_yaw = 0.0 self.start_posy = 0.0 self.start_posx = 0.0 self.robot_controller = MoveTB3() self.robot_odom = TB3Odometry() #var to check task is complete self.complete = False #var to check if move forward is needed self.move_forward = True #var to turn to check the color # self.turn = True #var to turn back facing the front self.turn_back = True #var to check if statr yaw has been initiated self.face_turn = False self.pillar_lined_with_home = False self.finding_pillar = False self.get_colour = False self.colour = -1 self.check = True self.counter = 0 self.ctrl_c = False rospy.on_shutdown(self.shutdown_ops) self.rate = rospy.Rate(5) self.all_colours = True self.m00 = 0 self.m00_min = 10000 # self.img = None self.finished_initialising = False
def __init__(self): rospy.init_node('turn_and_face') self.camera_subscriber = rospy.Subscriber("/camera/rgb/image_raw", Image, self.camera_callback) self.cvbridge_interface = CvBridge() self.robot_controller = MoveTB3() self.robot_odom = TB3Odometry() self.turn_vel_fast = -0.5 self.turn_vel_slow = -0.1 self.robot_controller.set_move_cmd(0.0, self.turn_vel_fast) self.move_rate = '' # fast, slow or stop self.ctrl_c = False rospy.on_shutdown(self.shutdown_ops) self.rate = rospy.Rate(5) self.m00 = 0 self.m00_min = 10000 self.turn = False self.color_name = "" self.lower_bound = [] self.upper_bound = [] self.mask = np.zeros((1080, 1920, 1), np.uint8) self.hsv_img = np.zeros((1080, 1920, 3), np.uint8) self.find_target = False
def __init__(self): self.actionserver = actionlib.SimpleActionServer("/search_action_server", SearchAction, self.action_server_launcher, auto_start=False) self.actionserver.start() self.rate = rospy.Rate(10) self.scanSub = rospy.Subscriber('scan', LaserScan, self.callback_function) self.robot_controller = MoveTB3() self.robot_odom = TB3Odometry() # define the robot pose variables and set them all to zero to start with: self.x0 = 0.0 self.y0 = 0.0 self.stop_distance = 0 self.desired_velocity = 0 self.turn_direction = False # define a Twist instance, which can be used to set robot velocities self.front_distance = 0.0 self.front_angle = 0.0 self.right_distance = 0.0 self.right_angle = 0.0 self.left_distance = 0.0 self.left_angle = 0.0 self.back_distance = 0.0 self.back_angle = 0.0
def __init__(self): rospy.init_node('turn_and_face') self.base_image_path = '/home/student/myrosdata/week6_images' self.camera_subscriber = rospy.Subscriber("/camera/rgb/image_raw", Image, self.camera_callback) self.cvbridge_interface = CvBridge() self.robot_odom = TB3Odometry() self.robot_controller = MoveTB3() self.turn_vel_fast = -0.5
def __init__(self): rospy.init_node('pillar_detection') self.camera_subscriber = rospy.Subscriber("/camera/rgb/image_raw", Image, self.camera_callback) self.cvbridge_interface = CvBridge() self.robot_controller = MoveTB3() self.turn_vel_fast = -0.5 self.turn_vel_slow = -0.1 self.robot_controller.set_move_cmd(0.0, self.turn_vel_fast) self.move_rate = '' # fast, slow or stop self.stop_counter = 0 self.start_yaw = 0.0 self.start_posy = 0.0 self.robot_controller = MoveTB3() self.robot_odom = TB3Odometry() #var to check task is complete self.complete = False #var to check if move forward is needed self.move_forward = True #var to turn to check the color self.turn = True #var to turn back facing the front self.turn_back = True #var to check if statr yaw has been initiated self.face_turn = False self.finding_pillar = False self.get_colour = False self.colour = -1 self.ctrl_c = False rospy.on_shutdown(self.shutdown_ops) self.rate = rospy.Rate(5) self.m00 = 0 self.m00_min = 10000
def __init__(self): self.actionserver = actionlib.SimpleActionServer( "/obstacle_avoid_action_server", SearchAction, self.action_server_launcher, auto_start=False) self.actionserver.start() #self.base_image_path = '/home/student/myrosdata/week5_images' self.camera_subscriber = rospy.Subscriber("/scan", LaserScan, self.scan_callback) #self.cv_image = CvBridge() self.robot_controller = MoveTB3() self.robot_odom = TB3Odometry()
def __init__(self): rospy.init_node('obst_avoidance', anonymous=True) self.rate = rospy.Rate(5) self.lidar_subscriber = rospy.Subscriber('/scan', LaserScan, self.callback_lidar) self.lidar = {'range': 0.0, 'closest': 0.0, 'closest angle': 0, 'range left': 0, 'range right': 0} self.robot_controller = MoveTB3() self.robot_odom = TB3Odometry() self.ctrl_c = False rospy.on_shutdown(self.shutdown_ops)
def __init__(self): rospy.init_node('maze_nav') self.scan_subscriber = rospy.Subscriber("/scan", LaserScan, self.callback) self.robot_controller = MoveTB3() self.robot_odom = TB3Odometry() rospy.on_shutdown(self.shutdown_ops) self.rate = rospy.Rate(1000) # variable self.ctrl_c = False self.check_at_j = 0 self.left_arc = 0 self.right_arc = 0 self.right_status = False self.left_status = False self.front_status = False
def __init__(self): rospy.init_node('color_beacon') self.camera_subscriber = rospy.Subscriber("/camera/rgb/image_raw", Image, self.camera_callback) self.cvbridge_interface = CvBridge() self.robot_controller = MoveTB3() self.robot_odom = TB3Odometry() self.scanSub = rospy.Subscriber('scan', LaserScan, self.scan_callback_function) self.turn_vel_fast = -0.5 self.turn_vel_slow = -0.1 self.robot_controller.set_move_cmd(0.0, self.turn_vel_fast) self.move_rate = '' # fast, slow or stop self.ctrl_c = False rospy.on_shutdown(self.shutdown_ops) self.rate = rospy.Rate(5) self.m00 = 0 self.m00_min = 1000000 self.turn = False self.color_name = "" self.lower_bound = [] self.upper_bound = [] self.mask = np.zeros((1080,1920,1), np.uint8) self.hsv_img = np.zeros((1080,1920,3), np.uint8) self.find_target = False self.stop_at_target = False self.raw_data = np.array(tuple()) # define a Twist instance, which can be used to set robot velocities self.all_distance = 0.0 self.all_angle = 0.0 self.front_distance = 0.0 self.front_angle = 0.0 self.right_distance = 0.0 self.right_angle = 0.0 self.left_distance = 0.0 self.left_angle = 0.0 self.back_distance = 0.0 self.back_angle = 0.0 self.init_x = 0.0 self.init_y = 0.0 self.small_front_distance = 0 self.small_front_angle = 0 color_forwards = ""
def __init__(self): # Initialise action server self.actionserver = actionlib.SimpleActionServer( "/search_action_server", SearchAction, self.action_server_launcher, auto_start=False) self.actionserver.start() # Lidar subscriber self.lidar_subscriber = rospy.Subscriber('/scan', LaserScan, self.callback_lidar) self.lidar = {'range': 0.0, 'closest': 0.0, 'closest angle': 0} # Robot movement and odometry self.robot_controller = MoveTB3() self.robot_odom = TB3Odometry()
def __init__(self): self.actionserver = actionlib.SimpleActionServer( "/search_action_server", SearchAction, self.action_server_launcher, auto_start=False) self.actionserver.start() #subscribe to lidar scan data node self.scan_subscriber = rospy.Subscriber("/scan", LaserScan, self.scan_callback) self.min_distance = 0.5 self.object_angle = 0 self.robot_controller = MoveTB3() self.robot_odom = TB3Odometry() self.arc_angles = np.arange(-40, 41)
def __init__(self): self.actionserver = actionlib.SimpleActionServer( "/camera_sweep_action_server", CameraSweepAction, self.action_server_launcher, auto_start=False) self.actionserver.start() self.base_image_path = '/home/student/myrosdata/actions' if not os.path.exists(self.base_image_path): os.makedirs(self.base_image_path) self.camera_subscriber = rospy.Subscriber( "/camera/rgb/image_raw/compressed", CompressedImage, self.camera_callback) self.cv_image = CvBridge() self.robot_controller = MoveTB3() self.robot_odom = TB3Odometry()
def __init__(self): rospy.init_node('turn_and_face') self.base_image_path = '/home/student/myrosdata/week6_images' self.camera_subscriber = rospy.Subscriber("/camera/rgb/image_raw", Image, self.camera_callback) self.cvbridge_interface = CvBridge() self.robot_controller = MoveTB3() self.turn_vel_fast = -0.5 self.turn_vel_slow = -0.1 self.robot_controller.set_move_cmd(0.0, self.turn_vel_fast) self.move_rate = '' # fast, slow or stop self.stop_counter = 0 self.ctrl_c = False rospy.on_shutdown(self.shutdown_ops) self.rate = rospy.Rate(5) self.m00 = 0 self.m00_min = 10000
def __init__(self): rospy.init_node('object_detection', anonymous=True) self.rate = rospy.Rate(5) self.camera_subscriber = rospy.Subscriber("/camera/rgb/image_raw", Image, self.camera_callback) self.cvbridge_interface = CvBridge() self.robot_controller = MoveTB3() self.robot_odom = TB3Odometry() self.turn_vel_fast = -0.5 self.turn_vel_slow = -0.1 self.robot_controller.set_move_cmd(0.0, self.turn_vel_fast) self.move_rate = '' # fast, slow or stop self.stop_counter = 0 self.m00 = 0 self.m00_min = 100000 self.lower = [(115, 224, 100), (0, 185, 100), (25, 150, 100), (75, 150, 100), (145, 220, 100),(27, 200,255)] self.upper = [(130, 255, 255), (10, 255, 255), (70, 255, 255), (100, 255, 255), (155, 250, 255),(33, 255,255)] self.ctrl_c = False rospy.on_shutdown(self.shutdown_ops)
def __init__(self): rospy.init_node('turn_and_face') self.base_image_path = '/home/student/myrosdata/week6_images' self.camera_subscriber = rospy.Subscriber("/camera/rgb/image_raw", Image, self.camera_callback) self.cvbridge_interface = CvBridge() self.robot_odom = TB3Odometry() self.robot_controller = MoveTB3() self.turn_vel_fast = 0.5 self.turn_vel_med = 0.25 self.turn_vel_slow = 0.1 self.robot_controller.set_move_cmd(0.0, self.turn_vel_fast) self.move_rate = '' # fast, slow or stop self.stop_counter = 0 self.task_stage = 1 self.found_colour = False self.start_angle = self.robot_odom.yaw #convert angle to 0-360 if self.start_angle < 0: self.start_angle += 360 if self.start_angle == 0.0: self.start_angle = 90 print(self.start_angle) self.ctrl_c = False rospy.on_shutdown(self.shutdown_ops) self.lowers = { "blue": (115, 224, 100), "red": (-5, 225, 100), "green": (40, 150, 100), "cyan": (75, 100, 100), "purple": (145, 485, 100), "yellow": (22, 93, 0) } self.uppers = { "blue": (130, 255, 255), "red": (8, 255, 255), "green": (65, 255, 255), "cyan": (95, 255, 255), "purple": (150, 255, 255), "yellow": (45, 255, 255) } #blue, red, green, cyan, purple, yellow self.colour_boundaries = [[(115, 224, 100), (130, 255, 255), "blue"], [(-5, 225, 100), (8, 255, 255), "red"], [(40, 150, 100), (65, 255, 255), "green"], [(75, 100, 100), (95, 255, 255), "cyan"], [(145, 485, 100), (150, 255, 255), "purple"], [(22, 93, 0), (45, 255, 255), "yellow"]] self.centre_pixel_colours = [0, 0, 0] self.rate = rospy.Rate(10) self.m00 = 0 self.m00_min = 10000 self.search_colour = "blue"
def __init__(self): # arena_server.py self.actionserver = actionlib.SimpleActionServer( "/arena_action_server", SearchAction, self.action_server_launcher, auto_start=False) self.actionserver.start() # Lidar subscriber self.lidar_subscriber = rospy.Subscriber('/scan', LaserScan, self.callback_lidar) self.camera_subscriber = rospy.Subscriber("/camera/rgb/image_raw", Image, self.camera_callback) self.lidar = { 'range': 0.0, 'wider range': 0.0, 'closest': 0.0, 'closest angle': 0 } # Robot movement and odometry self.robot_controller = MoveTB3() self.robot_odom = TB3Odometry() self.current_yaw = 0.0 # beacon_search self.cvbridge_interface = CvBridge() self.turn_vel_fast = -0.5 self.turn_vel_slow = -0.1 self.robot_controller.set_move_cmd(0.0, self.turn_vel_fast) self.move_rate = '' # fast, slow or stop self.stop_counter = 0 self.start_yaw = 0.0 self.start_posy = 0.0 self.start_posx = 0.0 #var to check task is complete self.complete = False #var to check if move forward is needed self.move_forward = True #var to turn to check the color # self.turn = True #var to turn back facing the front self.turn_back = True #var to check if statr yaw has been initiated self.face_turn = False self.pillar_lined_with_home = False self.finding_pillar = False self.get_colour = False self.colour = -1 self.check = True self.counter = 0 self.ctrl_c = False rospy.on_shutdown(self.shutdown_ops) self.rate = rospy.Rate(5) self.all_colours = True self.m00 = 0 self.m00_min = 10000 self.finished_initialising = False
def __init__(self): self.actionserver = actionlib.SimpleActionServer( "/beacon_detection_server", SearchAction, self.action_server_launcher, auto_start=False) self.actionserver.start() self.base_image_path = '/home/student/myrosdata/week6_images' #subscribe to camera node self.camera_subscriber = rospy.Subscriber("/camera/rgb/image_raw", Image, self.camera_callback) self.cvbridge_interface = CvBridge() #subscribe to lidar scan data node self.scan_subscriber = rospy.Subscriber("/scan", LaserScan, self.scan_callback) self.robot_odom = TB3Odometry() self.robot_controller = MoveTB3() self.turn_vel_fast = 0.5 self.turn_vel_fast_rev = -0.5 self.turn_vel_med = 0.25 self.turn_vel_slow = -0.1 self.robot_controller.set_move_cmd(0.0, self.turn_vel_fast) self.move_rate = '' # fast, slow or stop self.task_stage = 1 self.found_colour = False self.need_reverse = False self.start_angle = self.robot_odom.yaw #convert angle to 0-360 if self.start_angle < 0: self.start_angle += 360 #sometimes the odom doesn't return the actual angle, so set it to 90 by default if self.start_angle == 0.0: self.start_angle = 90 self.min_distance = 0.5 self.object_angle = 0 self.arc_angles = np.arange(-40, 41) self.ctrl_c = False rospy.on_shutdown(self.shutdown_ops) self.lowers = { "blue": (115, 224, 100), "red": (-5, 225, 100), "green": (40, 150, 100), "cyan": (75, 100, 100), "purple": (145, 485, 100), "yellow": (22, 93, 0) } self.uppers = { "blue": (130, 255, 255), "red": (8, 255, 255), "green": (65, 255, 255), "cyan": (95, 255, 255), "purple": (150, 255, 255), "yellow": (45, 255, 255) } #blue, red, green, cyan, purple, yellow self.colour_boundaries = [[(115, 224, 100), (130, 255, 255), "blue"], [(-5, 225, 100), (8, 255, 255), "red"], [(40, 150, 100), (65, 255, 255), "green"], [(75, 100, 100), (95, 255, 255), "cyan"], [(145, 485, 100), (150, 255, 255), "purple"], [(22, 93, 0), (45, 255, 255), "yellow"]] self.centre_pixel_colours = [0, 0, 0] self.rate = rospy.Rate(10) self.m00 = 0 self.m00_min = 10000 self.search_colour = "blue"