Tech Toolbox
  • Please Visit https://ftc-tech-toolbox.vercel.app/ for the new tech toolbox!!
    • Introduction
    • Choosing an IDE
    • Creating an OpMode
    • Motors and Encoders
    • Servos
    • Gamepad Controls
    • Drive Systems
    • Lynx Modules
    • Telemetry
    • Wireless Download
    • The Sleep Command
  • Please Visit the New Link
    • Tank Drive / Skid Steer (Part 1)
    • Mecanum Drive (Part 1)
    • Turrets
    • Linear Slides
    • Kicker
    • Active Intake / Sweepers
    • Flywheels / Shooters
  • Please Visit the new Link
    • Base Class (Step 1)
    • Module Classes (Step 2)
    • OpMode Classes (Step 3)
  • This domain is now depreciated and is no longer updated!
  • This domain is now depreciated and is no longer updated!
    • What is Localization?
    • General Odometry Logic
    • Tank (No Deadwheels)
    • Mecanum (No Deadwheels)
    • Deadwheel Odometry (Mecanum and Tank)
    • VSLAM
  • This domain is now depreciated and is no longer updated!
    • What is Control Theory?
    • Custom PID Loops
    • Essential Control Theory Concepts
    • Resources for Learning Advanced Control Theory
  • This domain is now depreciated and is no longer updated! Please visit this domain for the new TT!
    • Introduction
    • Mecanum Drive (Part 2)
    • Tank Drive (Part 2)
    • Introduction to Pure Pursuit
    • Pure Pursuit: Mecanum
    • Pure Pursuit: Tank
    • Advanced Pure Pursuit
    • Guided Vector Fields
    • Autonomous Movement Libraries
  • Sensors
    • IMU
    • Color Sensors
      • Advanced Sensing Code
    • Distance Sensors
    • Touch Sensor
  • Computer Vision
    • Setting up Camera/Intro to Computer Vision Tools
      • Intro to OpenCV
      • Vuforia
    • Streaming Frames
    • Color Thresholding
    • April Tags
    • Linear Regression
    • Machine Learning Toolchain
    • Object Distance Estimation
    • Object Tracking / Driving to an Object
    • Computer Vision Simulators
  • Simulators
    • Beta8397 Simulator
    • VRS
  • Cool Codebases
Powered by GitBook
On this page
  • Object Tracking
  • Driving to an Object
  • Our Way
  • Alternative Methods
  • Real World Example
  1. Computer Vision

Object Tracking / Driving to an Object

PreviousObject Distance EstimationNextComputer Vision Simulators

Last updated 1 year ago

Prerequisites

Object Tracking

Our turret module provides a tutorial on object tracking as well as a codebase where object tracking is implemented (be sure to also look at the case study section in the linked module):

Driving to an Object

Our Way

Implement the following algorithm:

  • Detect the object and store its bounding box (refer to the Machine Learning Toolchain module)

  • Determine the distance from the object to the camera (refer to the Object Distance Estimation module). You will only need the distance on the z and x axis for this.

  • You now have the hypotenuse (distance on the z-axis) and one side length (absolute value of the distance on the x-axis) of a right triangle! Solve for the other side length through the Pythagorean theorem. This second side is your y distance!

  • Add the x (horizontal) and newly calculated y distance to your robot's current position, this is the object's real-world position. Note that you have to account for the robot's orientation!

  • Plug the position into your autonomous movement functions (refer to the autonomous movement sections)

Alternative Methods

This video tutorial shows you how to drive to a detected object:

The FTC samples also give an excellent tutorial on driving to a detected object:

Real World Example

FTC Team Hazen Robotics has implemented code that can drive to a game element:

Object Distance Estimation
Autonomous Movement
https://github.com/HazenRobotics/freight-frenzy/blob/master/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/vision/HomographyTargetDistance.java
https://github.com/FIRST-Tech-Challenge/FtcRobotController/blob/e0282fcbd3de5116132a69a1d0ed229f3ca97e0f/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptVuforiaDriveToTargetWebcam.java
https://github.com/HazenRobotics/freight-frenzy/blob/master/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/utils/TargetPositionCalculator.java
GitBook
Logo