Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Add PhotonVisionLabVIEW docs #256

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/docs/programming/photonlib/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ PhotonLib: Robot Code Interface
controlling-led
simulation
hardware-in-the-loop-sim
labview/index
23 changes: 23 additions & 0 deletions source/docs/programming/photonlib/labview/camera-controls.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Driver Mode Pipeline Index And LED Mode
=======================================

Set Driver Mode
---------------

Toggle driver mode using ``PhotonCamera_SetDriverMode.vi``.

.. image:: images/set_driver_mode.png

Set Pipeline Index
---------------

The same can be done to change the pipeline index by using ``PhotonCamera_SetPipelineIndex.vi``.

.. image:: images/set_pipeline_index.png

Set LED Mode
---------------

And the LED mode with ``PhotonCamera_SetLEDMode.vi``.

.. image:: images/set_led_mode.png
61 changes: 61 additions & 0 deletions source/docs/programming/photonlib/labview/getting-target-data.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Getting Target Data
mdurrani808 marked this conversation as resolved.
Show resolved Hide resolved
===================

Getting The Latest Result
mcm001 marked this conversation as resolved.
Show resolved Hide resolved
------------------------

What is a Photon Pipeline Result
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

A ``PhotonPipelineResult`` is a bundle that contains all information about currently detected targets from a camera. You can retrieve the latest pipeline result using ``PhotonCamera_GetLatestResult.vi``

.. image:: images/get_latest_result.png

Checking for Existence of Targets
--------------------

``PhotonCamera_GetLatestResult.vi`` will output a boolean named ``hasTargets?`` to inform the user as to whether the result contains any targets.

.. image:: images/has_targets_2.png

``PhotonPipelineResult_HasTargets?.vi`` can also be used to check for the existence of targets.

.. image:: images/has_targets.png


Getting an Array of Targets
---------------------------

What is a Photon Tracked Target?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

A tracked target contains information about a target from a pipeline result. This information includes yaw, pitch, area, and robot relative pose.

Each pipeline result contains an array of targets. Use LabVIEW's ``Unbunlde by name`` node to get access to the array of targets.

.. image:: images/get_targets.png

Getting The Best Target
-----------------------

You can get the `best target <https://docs.photonvision.org/en/latest/docs/getting-started/pipeline-tuning/reflectiveAndShape/contour-filtering.html#contour-grouping-and-sorting>`_ using ``PhotonPipelineResult_GetBestTarget.vi``

.. image:: images/get_best_target.png

Getting Target By ID
--------------------

If you are using an AprilTag pipeline you can use ``PhotonPipelineResult_GetBestTargetById.vi`` will return a target with a specified ID.

.. image:: images/get_target_by_id.png

Getting Target Data
-------------------
* double ``PhotonTrackedTarget_GetYaw.vi``: The yaw of the target in degrees (positive right).
* double ``PhotonTrackedTarget_GetPitch.vi``: The pitch of the target in degrees (positive up).
* double ``PhotonTrackedTarget_GetArea.vi``: The area (how much of the camera feed the bounding box takes up) as a percent (0-100).
* double ``PhotonTrackedTarget_GetSkew.vi``: The skew of the target in degrees (counter-clockwise positive).
* double[] ``PhotonTrackedTarget_GetConors.vi``: The 4 corners of the minimum bounding box rectangle.
* Transform2d ``PhotonTrackedTarget_GetBestCameraToTarget.vi``: The camera to target transform. See `2d transform documentation here <https://docs.wpilib.org/en/latest/docs/software/advanced-controls/geometry/transformations.html#transform2d-and-twist2d>`_.

.. image:: images/get_data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions source/docs/programming/photonlib/labview/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PhotonVisionLabVIEW (Unofficial)
=================================

What is PhotonVisionLabVIEW
----------------------------
PhotonVisionLabVIEW is a third-party LabVIEW Port of the PhotonVision library made by `jsimpso81 <https://github.com/jsimpso81>`_.


.. warning:: This project was not made and is not maintained by the PhotonVision team and may not receive updates as fast and some features may be missing. because of this the main development team will not be able provide support. Issues / questions should be reported at https://github.com/jsimpso81/PhotonVisionLabVIEW/issues or on ChiefDelphi.

.. toctree::
:maxdepth: 1

installing
getting-target-data
using-target-data
camera-controls
14 changes: 14 additions & 0 deletions source/docs/programming/photonlib/labview/installing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Installing PhotonVisionLabVIEW
================================

Installing
----------
Download the latest install package. These can be found in the Releases section of the github repository. Here is a direct link. https://github.com/jsimpso81/PhotonVisionLabVIEW/releases/latest

Select the .nipkg installation file for the version of LabVIEW being used, then double click it, or right click and select install. Administrative privledges will be needed to perform this installation. Follow the instructions. Usually selection of all the default answers is sufficient. Installation should take 5 minutes or less.

Previous versions do not have to be uninstalled prior to installing a new version. The new version will automatically upgrade the older version.

Removal
-------
To uninstall, open NI Package Manager. Select the Installed tab. Find and highlight PhotonVisionLib. Then click the REMOVE button. The uninstall should start. It should take 5 minutes or less.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Using Target Data
=================

Calculate Distance to Target
------------------------------

If your camera is at a fixed height on your robot and the height of the target is fixed, you can calculate the distance to the target based on your camera’s pitch and the pitch to the target.

.. image:: images/distance_to_target.png
Loading