2022WinterTeam7

From MAE/ECE 148 - Introduction to Autonomous Vehicles
Jump to navigation Jump to search

The Maskcar

Robot-Team7-WI22.jpeg

Team Members(Left to Right)

  1. Quynh Nguyen (MAE)
  2. Caitlin Le (MAE)
  3. Jian Qin (MAE & MathCS)

Team-Picture-Team7-WI22.jpg

Project Proposal

Use ROS2, YOLOv5 image classification, and a mechanical mask delivery system to deliver masks to unmasked people.
The car will drive around the track. The car will eject a mask when it sees an unmasked person.

Robot Schematics

Wiring Diagram

Wiring-Diagram-Team7-WI22.png

Mask Dispenser

Mask-Dispenser-Team7-WI22.png

Videos / Quarter Summary

  1. Emergency Off (EMO): 0:13 - 0:18
  2. Donkey Car (Deep Learning): 0:19 - 0:50
  3. ROS2 (openCV): 0:51 - 1:38
  4. Mask Detection: 1:39 - 2:04

{{#ev:youtube|https://youtu.be/TlT4raD7VfE%7C700x500%7Cleft%7C Quarter Summary |frame}}
























Final Project Sub-Systems

Mask Dispenser System

Mask-Demo-Team7-WI22.png

YOLOv5 Detection System

YOLO-Team7-WI22.png

ROS2 Implementation System

ROS2-Team7-WI22.png

Source code

The source code for the mask_pkg can be found here: https://github.com/qinjianxyz/ros2_ws/tree/main/src/ucsd_robocar_hub2/mask_pkg

import os
import cv2
import time
import rclpy
import numpy as np
from rclpy.node import Node
from cv_bridge import CvBridge
from elements.yolo import OBJ_DETECTION
from sensor_msgs.msg import Image
from std_msgs.msg import Int32, Float32

# Give names for nodes and topics for ROS
NODE_NAME = 'mask_node'
CAMERA_TOPIC_NAME = '/camera/color/image_raw'
MASK_DETECTION_TOPIC_NAME = '/mask_detection'
SERVO_TOPIC_NAME = '/servo'

# types of objects that can be detected
Object_classes = ['temp', 'with_mask', 'without_mask']
Object_detector = OBJ_DETECTION('weights/best.pt', Object_classes)

class MaskDetection(Node):

    def __init__(self):
        # initialize the node
        super().__init__(NODE_NAME)
        self.camera_subscriber = self.create_subscription(Image,
        CAMERA_TOPIC_NAME, self.detect_mask, 10)
        self.mask_publisher = self.create_publisher(Int32, MASK_DETECTION_TOPIC_NAME, 1)
        self.servo_publisher = self.create_publisher(Float32,
        SERVO_TOPIC_NAME, 10)
        self.bridge = CvBridge()
        self.mask_detected = Int32()
        self.mask_degree = Float32()
        


    def detect_mask(self, data):

        frame = self.bridge.imgmsg_to_cv2(data)  # camera feed

        # detection process
        objs = Object_detector.detect(frame)  # detect the object

        if objs is None:
            self.get_logger().info("Nothing detected")

        # plotting
        for obj in objs:
            label = obj['label']
            score = obj['score']
            self.get_logger().info(f"Label: {label}, Score: {score}")
            # if no mask is detected send out a 1 else send out 0
            if label == 'without_mask' and score > 0.85:
                self.mask_detected.data = 1
                self.mask_degree.data = 0.0
            else:
                self.mask_detected.data = 0
                self.mask_degree.data = 90.0
            self.mask_publisher.publish(self.mask_detected)
            self.servo_publisher.publish(self.mask_degree)


def main(args=None):
    rclpy.init(args=args)
    mask_publisher = MaskDetection()
    try:
        rclpy.spin(mask_publisher)
        mask_publisher.destroy_node()
        rclpy.shutdown()
    except KeyboardInterrupt:
        mask_publisher.get_logger().info(
            f'Shutting down {NODE_NAME}...')
        time.sleep(1)
        mask_publisher.destroy_node()
        rclpy.shutdown()
        mask_publisher.get_logger().info(
        f'{NODE_NAME} shut down successfully.')

if __name__ == '__main__':
    main()

Project Gantt Chart

Gantt.png

Final Presentation

{{#ev:youtube|https://youtu.be/ACYHri5avdQ%7C700x500%7Cleft%7C Quarter Summary |frame}}
























Final Presentation Slides: https://docs.google.com/presentation/d/1GB6YJGGhiWTTizWGuItnPPd6_Nby0S8jRiF3QP13Sm0/

Acknowledgement

Instructor - Prof. Jack Silberman

TA - Dominic Nightingale

TA - Ivan Ferrier

ECE Makerspace