Skip to content

Commit

Permalink
Distance updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bhjelstrom committed Feb 18, 2022
1 parent 822d8fb commit 5a0ed03
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions docs/cs_estimating_distance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ d = (h2-h1) / tan(a1+a2)

The tan function usually assumes that its input is measured in radians. To convert an angle measurement from degrees to radians, multiply the angle measurement by (3.14159/180.0). Essentially, 3.14 radians = 180 degrees. See the full code example below.


.. tabs::

..tab:: Java
.. tab:: Java

.. code-block:: java
Expand All @@ -48,7 +49,8 @@ The tan function usually assumes that its input is measured in radians. To conve
//calculate distance
double distanceFromLimelightToGoalInches = (goalHeightInches - limelightHeightInches)/tan(angleToGoalRadians);
..tab:: c++
.. tab:: C++

.. code-block:: c++

Expand All @@ -70,6 +72,8 @@ The tan function usually assumes that its input is measured in radians. To conve
//calculate distance
double distanceFromLimelightToGoalInches = (goalHeightInches - limelightHeightInches)/tan(angleToGoalRadians);



When using this technique it is important to choose the mounting angle of your camera carefully. You want to be able to see the target both when you're too close and too far away. You also do not want this angle to change, so mount it securely and avoid using slots in your mounting geometry.

If you are having trouble figuring out what the angle a1 is, you can also use the above equation to solve for a1. Just put your robot at a known distance (measuring from the lens of your camera) and solve the same equation for a1.
Expand Down

0 comments on commit 5a0ed03

Please sign in to comment.