Skip to content
Draft
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ _testmain.go
.DS_Store
static/logs
static/img/avatars
.venv/
5 changes: 5 additions & 0 deletions field_nodes/shooter_hub/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
10 changes: 10 additions & 0 deletions field_nodes/shooter_hub/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}
7 changes: 7 additions & 0 deletions field_nodes/shooter_hub/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files.associations": {
"*.ls": "fanuctp",
"*.funuctp": "funuctp",
"string": "cpp"
}
}
19 changes: 19 additions & 0 deletions field_nodes/shooter_hub/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
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.
39 changes: 39 additions & 0 deletions field_nodes/shooter_hub/include/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

This directory is intended for project header files.

A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.

```src/main.c

#include "header.h"

int main (void)
{
...
}
```

Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.

In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.

Read more about using header files in official GCC documentation:

* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes

https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
23 changes: 23 additions & 0 deletions field_nodes/shooter_hub/include/app/app_motor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef APP_MOTOR_H
#define APP_MOTOR_H
#include "hw/hw_motor.hpp"

/**
* @file app_motor.hpp
* @brief Application layer for motor control.
*/
void app_motor_reset(void);

/**
* @brief Run the motor control application logic.
*/
void app_motor_run(void);

/**
* @brief Get the commanded duty cycle for a specified motor.
* @param motor The motor identifier.
* @return float The commanded duty cycle (-1.0 to 1.0).
*/
float app_motor_getCommandedDuty(hw_motor_configInstalledMotors_E motor);

#endif // APP_MOTOR_H
21 changes: 21 additions & 0 deletions field_nodes/shooter_hub/include/app/app_scoring.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef APP_SCORING_H
#define APP_SCORING_H
#include "io/io_comms.h"

/**
* @brief Initialize the scoring application.
*/
void app_scoring_reset(void);

/**
* @brief Run the scoring application logic, to be called periodically.
*/
void app_scoring_run(void);

/**
* @brief Get the current score.
* @return uint32_t The current score.
*/
uint32_t app_scoring_getScore(void);

#endif // APP_SCORING_H
21 changes: 21 additions & 0 deletions field_nodes/shooter_hub/include/hw/hw_motor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef HW_MOTOR_H
#define HW_MOTOR_H

typedef enum {
HW_MOTOR_INSTALLED_MOTOR_LEFT = 0,
HW_MOTOR_INSTALLED_MOTOR_RIGHT,
HW_MOTOR_INSTALLED_MOTOR_COUNT
} hw_motor_configInstalledMotors_E;

/** @brief Initialize the motor hardware */
void hw_motor_init(void);

/**
* @brief Set the motor duty cycle.
* @param motor The motor identifier.
* @param duty_cycle The duty cycle (-1.0 to 1.0).
*/
void hw_motor_setDutyCycle(hw_motor_configInstalledMotors_E motor,
float duty_cycle);

#endif // HW_MOTOR_H
25 changes: 25 additions & 0 deletions field_nodes/shooter_hub/include/hw/hw_scoring.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef HW_SCORING_H
#define HW_SCORING_H
#include <stdbool.h>

typedef enum {
HW_SCORING_BREAK_BEAM_SENSOR_LEFTMOST,
HW_SCORING_BREAK_BEAM_SENSOR_MIDDLE_LEFT,
HW_SCORING_BREAK_BEAM_SENSOR_MIDDLE_RIGHT,
HW_SCORING_BREAK_BEAM_SENSOR_RIGHTMOST,
HW_SCORING_BREAK_BEAM_SENSOR_COUNT
} hw_scoring_breakBeamSensors_E;

/**
* @brief Initialize the hardware scoring module.
*/
void hw_scoring_init(void);

/**
* @brief Get the HW state of the break beam sensor.
* @param sensor The break beam sensor identifier.
* @return true if the break beam sensor is triggered, false otherwise.
*/
bool hw_scoring_getBreakBeamSensorState(hw_scoring_breakBeamSensors_E sensor);

#endif // HW_SCORING_H
28 changes: 28 additions & 0 deletions field_nodes/shooter_hub/include/io/io_comms.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef IO_COMMS_H
#define IO_COMMS_H
#include "hw/hw_motor.hpp"

#include <stdint.h>

typedef enum {
REQUESTED_HUB_STATE_DISABLED,
REQUESTED_HUB_STATE_MATCH_PLAY_SCORING_ACTIVE,
REQUESTED_HUB_STATE_MATCH_PLAY_SCORING_INACTIVE,
REQUESTED_HUB_STATE_DEBUG_MOTOR_SPINUP,
REQUESTED_HUB_STATE_DEBUG_SCORING_TEST,
} RequestedHubState_E;

/**
* @brief Get the requested hub state.
* @return RequestedHubState_E The requested hub state.
*/
RequestedHubState_E io_comms_getRequestedHubState(void);

/**
* @brief Get the motor duty command.
* @param motor The motor identifier.
* @return float The motor duty command (-1.0 -> 1.0).
*/
float io_comms_getConfigMotorDutyCmd(hw_motor_configInstalledMotors_E motor);

#endif // IO_COMMS_H
46 changes: 46 additions & 0 deletions field_nodes/shooter_hub/lib/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.

The source code of each library should be placed in an own separate directory
("lib/your_library_name/[here are source files]").

For example, see a structure of the following two libraries `Foo` and `Bar`:

|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c

and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>

int main (void)
{
...
}

```

PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.

More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
50 changes: 50 additions & 0 deletions field_nodes/shooter_hub/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
default_envs = esp32_s3_devkitm_1

[env:esp32_s3_devkitm_1]
platform = espressif32
board = esp32-s3-devkitm-1
framework = arduino
monitor_speed = 115200
lib_deps =
arduino-libraries/Ethernet@^2.0.2
https://github.com/bblanchon/ArduinoJson.git
ESPAsyncWebServer
fastled/FastLED@^3.10.3
esp32async/AsyncTCP@^3.4.8
madhephaestus/ESP32Servo@^3.1.3
platform_packages =
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.2
framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.2/esp32-arduino-libs-3.0.2.zip
build_flags =
-DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_USB_MODE=1
-DESP32_S3_DEVKITM_1
lib_compat_mode = strict
monitor_port = /dev/ttyACM0
upload_port=/dev/ttyACM0

[env:native]
platform = native
test_build_src = yes
test_filter = test_app*
build_src_filter =
+<app/*>
+<test/*>
build_flags =
-Wall
-Wextra
-Wpedantic
-Werror
-Wswitch-enum
-DUNIT_TEST=1
22 changes: 22 additions & 0 deletions field_nodes/shooter_hub/src/GlobalSettings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef GLOBALSETTINGS_H
#define GLOBALSETTINGS_H

#include <Arduino.h>

// Declare the deviceRole variable
String deviceRole;

// Declare the arenaIP variable
String arenaIP;

// Declare the arenaPort variable
String arenaPort;

// Declare the useDHCP variable
bool useDHCP;

// Declare the deviceIP variable
String deviceIP;
String deviceGWIP;

#endif // GLOBALSETTINGS_H
Loading