Skip to content

Commit

Permalink
Updates for 2023
Browse files Browse the repository at this point in the history
- Move from pynetworktables references to pyntcore
- Emphasize ARM coprocessor install steps separately
  • Loading branch information
virtuald committed Jan 22, 2023
1 parent 1171fdf commit 9189465
Show file tree
Hide file tree
Showing 13 changed files with 96 additions and 253 deletions.
3 changes: 2 additions & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
}

redirects = {
"2020_notes": "upgrade_notes.html"
"2020_notes": "upgrade_notes.html",
"install/pynetworktables": "pyntcore.html"
}

# The version info for the project you're documenting, acts as replacement for
Expand Down
2 changes: 1 addition & 1 deletion dev/deploy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ If you wish for the code to be started up when the roboRIO boots up, you need to
make sure that "Disable RT Startup App" is **not** checked in the roboRIO's web
configuration.

These steps are compatible with what C++/Java does when deployed by eclipse,
These steps are compatible with what C++/Java does when deployed by GradleRIO,
so you should be able to seamlessly switch between python and other FRC
languages!

Expand Down
4 changes: 2 additions & 2 deletions getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ the following steps:
Once you've played around with some code in simulation, then you should
:ref:`install RobotPy on your robot <install_robotpy>`.

If you're looking to use pynetworktables on the driver station or on a
coprocessor, then check out the :ref:`pynetworktables install docs <install_pynetworktables>`.
If you're looking to use NetworkTables on the driver station or on a
coprocessor, then check out the :ref:`pyntcore install docs <install_pyntcore>`.

122 changes: 8 additions & 114 deletions guide/nt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
Using NetworkTables
===================

.. warning:: This documentation has not been documented for the 2023 season yet

NetworkTables is a communications protocol used in FIRST Robotics. It provides a
simple to use mechanism for communicating information between several computers.
There is a single server (typically your robot) and zero or more clients. These
Expand All @@ -22,7 +20,7 @@ Robot Configuration
FIRST introduced the mDNS based addressing for the RoboRIO in 2015, and
generally teams that use additional devices have found that while it works at
home and sometimes in the pits, it tends to not work correctly on the field at
events. For this reason, if you use pynetworktables on the field, we strongly
events. For this reason, if you use NetworkTables on the field, we strongly
encourage teams to `ensure every device has a static IP address`.

* Static IPs are ``10.XX.XX.2``
Expand All @@ -34,121 +32,17 @@ would be ``10.12.34.2``.
For information on configuring your RoboRIO and other devices to use static IPs, see the
:doc:`WPILib documentation <frc:docs/networking/networking-introduction/ip-configurations>`.

Server initialization (Robot)
-----------------------------

WPILib automatically starts NetworkTables for you, and no additional
configuration should need to be done.

Client initialization (Driver Station/Coprocessor)
--------------------------------------------------

.. note:: For install instructions, see
:ref:`pynetworktables installation instructions <install_pynetworktables>`

As of 2017, this is very easy to do. Here's the code::

from networktables import NetworkTables

NetworkTables.initialize(server='10.xx.xx.2')

The key is specifying the correct server hostname. See the above section on
robot configuration for this.

.. warning:: NetworkTables does not connect instantly! If you write a script
that calls ``initialize`` and immediately tries to read from
NetworkTables, you will almost certainly not be able to read
any data.

To write a script that waits for the connection, you can use the
following code::
import threading
from networktables import NetworkTables

cond = threading.Condition()
notified = [False]
Resources
---------

def connectionListener(connected, info):
print(info, '; Connected=%s' % connected)
with cond:
notified[0] = True
cond.notify()
Installation:

NetworkTables.initialize(server='10.xx.xx.2')
NetworkTables.addConnectionListener(connectionListener, immediateNotify=True)
.. seealso:: :ref:`pyntcore installation <install_pyntcore>`

with cond:
print("Waiting")
if not notified[0]:
cond.wait()
# Insert your processing code here
print("Connected!")

Theory of operation
-------------------

In its most abstract form, NetworkTables can be thought of as a dictionary that
is shared across multiple computers across the network. As you change the value
of a table on one computer, the value is transmitted to the other side and can
be retrieved there.

The keys of this dictionary **must** be strings, but the values can be numbers,
strings, booleans, various array types, or raw binary. Strictly speaking, the
keys can be any string value, but they are typically path-like values such as
``/SmartDashboard/foo``.

When you call :meth:`NetworkTablesInstance.getTable <networktables.NetworkTablesInstance.getTable>`,
this retrieves a :class:`NetworkTable <networktables.NetworkTable>` instance
that allows you to perform operations on a specified path::

table = NetworkTablesInstance.getTable('SmartDashboard')
# This retrieves a boolean at /SmartDashboard/foo
foo = table.getBoolean('foo', True)
There is also an concept of subtables::
subtable = table.getSubTable('bar')
# This retrieves /SmartDashboard/bar/baz
baz = table.getNumber('baz', 1)

As you may have guessed from the above example, once you obtain a NetworkTable
instance, there are very simple functions you can call to send and receive
NetworkTables data.

* To retrieve values, call ``table.getXXX(name, default)``
* To send values, call ``table.putXXX(name, value)``

NetworkTables can also be told to call a function when a particular key in the
table is updated.

Code Samples
~~~~~~~~~~~~
API:

.. seealso:: :ref:`NTCore API Reference <ntcore_api>`

Troubleshooting
~~~~~~~~~~~~~~~

.. seealso:: :ref:`pynetworktables troubleshooting <troubleshooting_nt>`

External tools
--------------

WPILib's OutlineViewer (requires Java) is a great tool for connecting to
networktables and seeing what's being transmitted.

* `Download OutlineViewer <http://first.wpi.edu/FRC/roborio/maven/release/edu/wpi/first/wpilib/OutlineViewer/>`_

WPILib's Shuffleboard (requires Java) is the new (as of 2018) tool to replace
SmartDashboard for creating custom NetworkTables-enabled dashboards.

* `Download Shuffleboard <http://first.wpi.edu/FRC/roborio/maven/release/edu/wpi/first/shuffleboard/shuffleboard/>`_

WPILib's SmartDashboard (requires Java) is an older tool used by teams to connect
to NetworkTables and used as a dashboard.
Troubleshooting:

* `Download SmartDashboard <http://first.wpi.edu/FRC/roborio/maven/release/edu/wpi/first/wpilib/SmartDashboard/>`_
.. seealso:: :ref:`NetworkTables troubleshooting <troubleshooting_nt>`
22 changes: 12 additions & 10 deletions install/components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ along with command based programming. You would do this
pip3 install -U robotpy[navx,commands]
.. tab:: Linux ARM Coprocessor

.. code-block:: sh
pip3 install --find-links=https://tortall.net/~robotpy/wheels/2023/raspbian/ -U robotpy[navx,commands]
Or if you wanted to install everything:

.. tab:: Windows
Expand All @@ -71,19 +77,15 @@ Or if you wanted to install everything:
pip3 install -U robotpy[all]
.. tab:: Linux ARM Coprocessor

.. code-block:: sh
pip3 install --find-links=https://tortall.net/~robotpy/wheels/2023/raspbian/ -U robotpy[all]
RoboRIO vs Computer
-------------------

The RobotPy meta package is used for installation on both the RoboRIO and
on your computer.

Coprocessor installation
------------------------

Building RobotPy components can take a really long time, so its best if you
use the pre-built wheels that we publish for ARM32 and AARCH64 systems.

.. code-block:: sh
pip3 install --find-links=https://tortall.net/~robotpy/wheels/2023/raspbian/ -U robotpy
31 changes: 30 additions & 1 deletion install/computer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ not recommended nor is it supported.

**source install**

Alternatively, if you have a C++17 compiler installed, you may be able
Alternatively, if you have a C++20 compiler installed, you may be able
to use pip to install RobotPy from source.

.. warning:: It may take a very long time to install!
Expand All @@ -141,3 +141,32 @@ not recommended nor is it supported.
export CC=gcc-12 CXX=g++-12
.. tab:: Linux ARM Coprocessor

We now publish prebuilt wheels at https://tortall.net/~robotpy/wheels/2023/raspbian/, which can be downloaded by giving the ``--find-links`` option to
pip:

.. code-block:: sh
pip3 install --find-links=https://tortall.net/~robotpy/wheels/2023/raspbian/ robotpy
**source install**

Alternatively, if you have a C++20 compiler installed, you may be able
to use pip to install RobotPy from source.

.. warning:: It may take a very long time to install!

.. warning::

Mixing our pre-built wheels with source installs may cause runtime errors.
This is due to internal ABI incompatibility between compiler versions.

Our ARM wheels are built on Ubuntu 22.04 with GCC 10.

If you need to build with a specific compiler version, you can specify them
using the :envvar:`CC` and :envvar:`CXX` environment variables:

.. code-block:: sh
export CC=gcc-12 CXX=g++-12
19 changes: 11 additions & 8 deletions install/cscore.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
robotpy-cscore install
======================

.. note:: cscore is not installed when you ``pip install robotpy``

RoboRIO installation
--------------------

Expand All @@ -17,29 +15,28 @@ is very simple:
.. code-block:: sh
# While connected to the internet
py -3 -m robotpy_installer download robotpy-cscore
py -3 -m robotpy_installer download robotpy[cscore]
# While connected to the network with a RoboRIO on it
py -3 -m robotpy_installer install robotpy-cscore
py -3 -m robotpy_installer install robotpy[cscore]
.. tab:: Linux/macOS

.. code-block:: sh
# While connected to the internet
robotpy-installer download robotpy-cscore
robotpy-installer download robotpy[cscore]
# While connected to the network with a RoboRIO on it
robotpy-installer install robotpy-cscore
robotpy-installer install robotpy[cscore]
For additional details about running robotpy-installer on your computer, see
the :ref:`robotpy-installer documentation <install_packages>`.

Non-roboRIO installation
------------------------

We now distribute wheels for CSCore on pypi, so you can just use the robotpy-meta
package to install it:
We now distribute pre-built wheels for CSCore, so you can just use pip to install it:

.. tab:: Windows

Expand All @@ -53,6 +50,12 @@ package to install it:
pip3 install -U robotpy[cscore]
.. tab:: ARM Coprocessor

.. code-block:: sh
pip3 install -U robotpy[cscore] --find-links=https://tortall.net/~robotpy/wheels/2023/raspbian/
Next steps
----------
Expand Down
6 changes: 3 additions & 3 deletions install/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Writing Robot code in Python:

Using NetworkTables from Python:

* To install pynetworktables on a system that does not have RobotPy
* To install NetworkTables on a system that does not have RobotPy
or pyfrc installed on it (such as a coprocessor like the Raspberry Pi), see the
:ref:`pynetworktables installation documentation <install_pynetworktables>`.
:ref:`pyntcore installation documentation <install_pyntcore>`.

Using cscore from Python:

Expand Down Expand Up @@ -45,7 +45,7 @@ Notes specific to individual packages
:maxdepth: 1

pyfrc
pynetworktables
pyntcore
commands
ctre
navx
Expand Down
Loading

0 comments on commit 9189465

Please sign in to comment.