Skip to content

Commit

Permalink
navigator_ball_launcher: Create ball launcher package, add packets us…
Browse files Browse the repository at this point in the history
…ed to communicate with board to docs
  • Loading branch information
cbrxyz committed Sep 23, 2024
1 parent 18d8364 commit c8b2c81
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 3 deletions.
14 changes: 14 additions & 0 deletions NaviGator/hardware_drivers/navigator_ball_launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.0.2)
project(navigator_ball_launcher)

find_package(catkin REQUIRED COMPONENTS
rospy
)

catkin_python_setup()

catkin_package(
)
if(CATKIN_ENABLE_TESTING)
find_package(rostest REQUIRED)
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
The :mod:`navigator_ball_launcher` module is used to control the ball launcher
on NaviGator. The module implements the electrical protocol to communicate with
a board that controls the flywheel and servo to drop the balls.
"""

from .packets import ReleaseBallPacket, SetSpinPacket
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from dataclasses import dataclass

from electrical_protocol import Packet


@dataclass
class ReleaseBallPacket(Packet, class_id=0x11, subclass_id=0x00, payload_format=""):
"""
Packet sent by the motherboard to the board to release a ball (aka, spin the servo
such that one ball is released.)
A valid response to this packet being sent would be :class:`~electrical_protocol.AckPacket`
(if the ball was successfully released) or :class:`~electrical_protocol.NackPacket`
(if there was an issue).
"""

pass


@dataclass
class SetSpinPacket(Packet, class_id=0x11, subclass_id=0x01, payload_format="<B"):
"""
Packet sent by the motherboard to the board to spin up the flywheel.
A valid response to this packet being sent would be :class:`~electrical_protocol.AckPacket`
(if the flywheel was successfully spun up) or :class:`~electrical_protocol.NackPacket`
(if there was an issue).
Attributes:
spin_up (bool): A boolean used to represent whether the flywheel should
be spun up (aka, sped up to a fast rpm) or whether it should be spun
down (aka, slowed to zero rpm).
"""

spin_up: bool
12 changes: 12 additions & 0 deletions NaviGator/hardware_drivers/navigator_ball_launcher/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<package>
<name>navigator_ball_launcher</name>
<version>1.0.0</version>
<description>The navigator_ball_launcher package</description>
<maintainer email="cameron.brown@todo.todo">Cameron Brown</maintainer>
<license>MIT</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>rospy</build_depend>
<run_depend>rospy</run_depend>
<export/>
</package>
11 changes: 11 additions & 0 deletions NaviGator/hardware_drivers/navigator_ball_launcher/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ! DO NOT MANUALLY INVOKE THIS setup.py, USE CATKIN INSTEAD

from catkin_pkg.python_setup import generate_distutils_setup
from setuptools import setup

# Fetch values from package.xml
setup_args = generate_distutils_setup(
packages=["navigator_ball_launcher"],
)

setup(**setup_args)
20 changes: 20 additions & 0 deletions docs/navigator/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,23 @@ RobotXClient

.. autoclass:: navigator_robotx_comms.nodes.robotx_comms_client.RobotXClient
:members:

:mod:`navigator_ball_launcher` - Ball launcher
----------------------------------------------

.. automodule:: navigator_ball_launcher
:members:

ReleaseBallPacket
^^^^^^^^^^^^^^^^^
.. attributetable:: navigator_ball_launcher.ReleaseBallPacket

.. autoclass:: navigator_ball_launcher.ReleaseBallPacket
:members:

SetSpinPacket
^^^^^^^^^^^^^
.. attributetable:: navigator_ball_launcher.SetSpinPacket

.. autoclass:: navigator_ball_launcher.SetSpinPacket
:members:
12 changes: 9 additions & 3 deletions docs/reference/electrical_protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,16 @@ byte length.
| (System | | | |
| Status) | | | |
+------------+--------------+----------------+-------------------------------------------------------------------------+
| 0x10 | 0x00 | ``?B`` | :class:`navigator_pico_kill_board.KillSetPacket` |
| 0x10 | 0x00 | ``?B`` | :class:`navigator_kill_light_board.KillSetPacket` |
| (NaviGator +--------------+----------------+-------------------------------------------------------------------------+
| Temporary | 0x01 | ``?B`` | :class:`navigator_pico_kill_board.KillReceivePacket` |
| Pico Kill | | | |
| Temporary | 0x01 | ``?B`` | :class:`navigator_kill_light_board.KillReceivePacket` |
| Pico Kill +--------------+----------------+-------------------------------------------------------------------------+
| Board) | 0x02 | | :class:`navigator_kill_light_board.SetMovementModePacket` |
+------------+--------------+----------------+-------------------------------------------------------------------------+
| 0x11 | 0x00 | Empty | :class:`navigator_ball_launcher.ReleaseBallPacket` |
| (NaviGator +--------------+----------------+-------------------------------------------------------------------------+
| Ball | 0x01 | ``B`` | :class:`navigator_ball_launcher.SetSpinPacket` |
| Launcher | | | |
| Board) | | | |
+------------+--------------+----------------+-------------------------------------------------------------------------+

Expand Down

0 comments on commit c8b2c81

Please sign in to comment.