Designed a system that can efficiently sort recyclables and transfer them to corresponding bins using Python, a Raspberry Pi, and Quanser Labs.

Overview

System for Sorting and Recycling Containers - Project 3

Table of contents

Overview

The challenge

  • Develop a system that can efficiently sort recyclables and transfer them to corresponding bins. Using Python create a program that can control robotic devices by connecting to a Raspberry Pi and using a remote environment (Quanser Labs).
  • Use the Q-Arm and the Q-Bot to transfer the containers in their appropiate bins.

Screenshot

Both Q-Bot and Q-Arm at Loading Position

Pic-1

Random Container Dispensed From the Tube

Pic-2

Q-Arm Loads the Containers Being Dropped at the Same Bin

Pic-3

Q-Bot Transfers the Containers & Engages the Hopper to Drop the Containers

Pic-5

My process

Built with

  • Python: Functions, conditionals, and loops.
  • Q-Arm and Q-Bot (ground robot) methods (common_libraries folder) used to move both robotic devices.
  • Ultrasonic sensor modules (common_libraries folder) provided to track the final bin distance.

Code snippets

Code to Determine the Bin Location of a Dispensed Container

  while (True):
      #Tracks the total mass of the containers
      total_mass = 0

      #Dispenses and loads the first container
      while (True):
          #Stores the information of the dispensed container (material, bin destination)
          container_list = []

          #Stores the bin ID of the first loaded container
          first_loaded_container = []

          #Checks if this is the first or second time a container is loaded to transfer 
          if (deposit_counter >= 1):

              #Stores the bin ID of the container which is not loaded
              first_target_bin = next_container[len(next_container)-1]
          else:

              #Dispenses a random container as this is the first time
              container_properties = my_table.container_properties(random.randint(1,6))
              container_list.append(container_properties)
              my_table.dispense_container()

              #Stores the bin ID from the container properties (material,mass,bin destination)
              for properties in container_list:
                  total_mass = properties[1]
                  first_target_bin = properties[2]

          print("First Target Bin:  ", first_target_bin)

          #Checks if dispensed container matches bin ID
          if (first_target_bin == "Bin01"):
              bin_ID = "Bin01"
          elif (first_target_bin == "Bin02"):
              bin_ID = "Bin02"
          elif (first_target_bin == "Bin03"):
              bin_ID = "Bin03"
          elif (first_target_bin == "Bin04"):
              bin_ID = "Bin04"

Q-Arm Code to Pick Up First Dispensed Container using Determined XYZ Coordinates

  #Loads the first container on the Q-Bot
  if (first_target_bin == bin_ID and total_mass < 90):
      #Appends the containers bin ID to compare with second dispensed container
      first_loaded_container.append(bin_ID) 
      arm.move_arm(0.68, 0.0, 0.2496)
      arm.control_gripper(45)
      arm.move_arm(0.2256, 0.0, 0.1898)
      arm.move_arm(-0.11, -0.300, 0.6)
      arm.move_arm(-0.11, -0.44, 0.39)
      arm.control_gripper(-45)
      arm.rotate_elbow(-33)
      arm.home()
      break
  else:
      break

Q-Bot Code to Transfer the Loaded Container using the Ultrasonic Sensor

  bot.activate_ultrasonic_sensor()

  #Checks if the loaded container matches bin ID and assigns a sensor value
  if (transfer_location == "Bin01"):
      bin_ID = "Bin01"
      #Value collected from ultrasonic reading which indicates when the Q-Bot should stop for each bin
      bin_target_location = [0.1]

  elif (transfer_location == "Bin02"):
      bin_ID = "Bin02"
      bin_target_location = [0.15]

  elif (transfer_location == "Bin03"):
      bin_ID = "Bin03"
      bin_target_location = [0.20]

  elif (transfer_location == "Bin04"):
      bin_ID = "Bin04"
      bin_target_location = [0.24, 0.25]

  if(transfer_location  == bin_ID):
      #While loop which runs until the target bin is located using ultrasonic sensor
      #Follows the yellow line until it arrives at target bin
      lines = 0
      while(lines < 2):
          lines, velocity = bot.follow_line(0.07)
          bot.forward_velocity(velocity)
          ultrasonic_reading = bot.read_ultrasonic_sensor(bin_ID)

          #Checks if assigned bin locations match the sensor values to stop the Q-Bot
          if(ultrasonic_reading in bin_target_location):

              #Stops the Q-Bot parallel to the bin
              bot.stop()
              bot.deactivate_ultrasonic_sensor()
              print("Reached target bin...")
              time.sleep(1)
              print("Deposit Container...")
              break
          else:
              #Moves Q-Bot forward until target location is determined
              bot.forward_speed(0.06)

What I learned

From this challenge I strengthened my knowledge of Python computation and scripting. Moreover, I learned more about python functions and also developed my abilities to resolve any bugs or issues within the program.

You might also like...
raspberry pi servo control using pca9685

RPi_servo-control_pca9685 raspberry pi 180° servo control using pca9685 Requirements Requires you to have the adafruit servokit library installed You

The example shows using local self-hosted runners on-premises by making use of a runner on a Raspberry Pi with LED's attached to it

The example shows using local self-hosted runners on-premises by making use of a runner on a Raspberry Pi with LED's attached to it

A simple non-official manager interface I'm using for my Raspberry Pis.
A simple non-official manager interface I'm using for my Raspberry Pis.

My Raspberry Pi Manager Overview I have two Raspberry Pi 4 Model B devices that I hooked up to my two TVs (one in my bedroom and the other in my new g

🔆 A Python module for controlling power and brightness of the official Raspberry Pi 7
🔆 A Python module for controlling power and brightness of the official Raspberry Pi 7

rpi-backlight A Python module for controlling power and brightness of the official Raspberry Pi 7" touch display. Note: This GIF was created using the

A simple portable USB MIDI controller based on Raspberry-PI Pico and a 16-button keypad, written in Circuit Python

RPI-Pico-16-BTn-MIDI-Controller-using-CircuitPython A simple portable USB MIDI controller based on Raspberry-PI Pico, written in Circuit Python. Link

A Python class for controlling the Pimoroni RGB Keypad for Raspberry Pi Pico
A Python class for controlling the Pimoroni RGB Keypad for Raspberry Pi Pico

rgbkeypad A Python class for controlling the Pimoroni RGB Keypad for the Raspberry Pi Pico. Compatible with MicroPython and CircuitPython. keypad = RG

A python library written for the raspberry pi.

A python package for using certain components on the raspberry pi.

A dashboard for Raspberry Pi to display environmental weather data, rain radar, weather forecast, etc. written in Python
A dashboard for Raspberry Pi to display environmental weather data, rain radar, weather forecast, etc. written in Python

Weather Clock for Raspberry PI This project is a dashboard for Raspberry Pi to display environmental weather data, rain radar, weather forecast, etc.

Mycodo is open source software for the Raspberry Pi that couples inputs and outputs in interesting ways to sense and manipulate the environment.
Mycodo is open source software for the Raspberry Pi that couples inputs and outputs in interesting ways to sense and manipulate the environment.

Mycodo Environmental Regulation System Latest version: 8.12.9 Mycodo is open source software for the Raspberry Pi that couples inputs and outputs in i

Owner
Mit Patel
Computer Engineering at McMaster University.
Mit Patel
Rasberry Pie GPIO memory game. Press the corresponding key to the lit LED.

RPie-keyboard-game Rasberry Pie GPIO memory game. Press the corresponding key to the lit LED. Randem LED (general output) is lit up on rasberrypi rand

Shawn Dowling 1 Oct 24, 2021
Homeautomation system created with Raspberry Pi 3 and Firebase.

Homeautomation System - Raspberry Pi 3 Desenvolvido com Python, Flask com AJAX e Firebase permite o controle local e remoto Itens necessários Raspberr

Joselino Santos 0 Mar 9, 2022
This repository hosts the code for Stanford Pupper and Stanford Woofer, Raspberry Pi-based quadruped robots that can trot, walk, and jump.

This repository hosts the code for Stanford Pupper and Stanford Woofer, Raspberry Pi-based quadruped robots that can trot, walk, and jump.

Stanford Student Robotics 1.2k Dec 25, 2022
Home solar infrastructure (with Peimar Inverter) monitoring based on Raspberry Pi 3 B+ using Grafana, InfluxDB, Custom Python Collector and Shelly EM.

raspberry-solar-mon Home solar infrastructure (with Peimar Inverter) monitoring based on Raspberry Pi 3 B+ using Grafana, InfluxDB, Custom Python Coll

cislow 10 Dec 23, 2022
A PYTHON Library for Controlling Motors using SOLO Motor Controllers with RASPBERRY PI, Linux, windows, and more!

A PYTHON Library for Controlling Motors using SOLO Motor Controllers with RASPBERRY PI, Linux, windows, and more!

SOLO Motor Controllers 3 Apr 29, 2022
A rubiks cube timer using a distance sensor and a raspberry pi 4, and possibly the pi pico to reduce size and cost.

distance sensor cube timer A rubiks cube timer using a distance sensor and a raspberry pi 4, and possibly the pi pico to reduce size and cost. How to

null 3 Feb 21, 2022
KIRI - Keyboard Interception, Remapping, and Injection using Raspberry Pi as an HID Proxy.

KIRI - Keyboard Interception, Remapping and Injection using Raspberry Pi as a HID Proxy. Near limitless abilities for a keyboard warrior. Features Sim

Viggo Falster 10 Dec 23, 2022
Using a raspberry pi, we listen to the coffee machine and count the number of coffee consumption

A typical datarootsian consumes high-quality fresh coffee in their office environment. The board of dataroots had a very critical decision by the end of 2021-Q2 regarding coffee consumption.

dataroots 51 Nov 21, 2022
a library for using WS2812b leds (aka neopixels) with Raspberry Pi Pico

pico_ws2812b a library for using WS2812b leds (aka neopixels) with Raspberry Pi Pico You'll first need to save the ws2812b.py file to your device (for

null 76 Nov 25, 2022
A Macropad using the Raspberry Pi Pico, programmed with CircuitPython.

A Macropad using the Raspberry Pi Pico, programmed with CircuitPython.

null 15 Oct 14, 2022