Skip to content

Commit

Permalink
Copied Bumblebee
Browse files Browse the repository at this point in the history
  • Loading branch information
nikgajjar51 committed Mar 4, 2024
1 parent 23f7688 commit fd7a242
Show file tree
Hide file tree
Showing 334 changed files with 20,260 additions and 46,669 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Build

# Controls when the workflow will run
on: [push, pull_request, workflow_dispatch]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Builds Code
uses: fishsticks89/pros-build@v1
Binary file added [email protected]
Binary file not shown.
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ EXCLUDE_COLD_LIBRARIES:=

# Set this to 1 to add additional rules to compile your project as a PROS library template
IS_LIBRARY:=0
# TODO: CHANGE THIS!
# Be sure that your header files are in the include directory inside of a folder with the
# same name as what you set LIBNAME to below.
# TODO: CHANGE THIS!
LIBNAME:=libbest
VERSION:=1.0.0
# EXCLUDE_SRC_FROM_LIB= $(SRCDIR)/unpublishedfile.c
Expand All @@ -36,8 +34,8 @@ EXCLUDE_SRC_FROM_LIB+=$(foreach file, $(SRCDIR)/main,$(foreach cext,$(CEXTS),$(f

# files that get distributed to every user (beyond your source archive) - add
# whatever files you want here. This line is configured to add all header files
# that are in the directory include/LIBNAME
TEMPLATE_FILES=$(INCDIR)/$(LIBNAME)/*.h $(INCDIR)/$(LIBNAME)/*.hpp
# that are in the the include directory get exported
TEMPLATE_FILES=$(INCDIR)/**/*.h $(INCDIR)/**/*.hpp

.DEFAULT_GOAL=quick

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[![Build](https://github.com/KSUOwlBots/OPTIMUS-15-MAIN/actions/workflows/main.yml/badge.svg)](https://github.com/KSUOwlBots/OPTIMUS-15-MAIN/actions/workflows/main.yml)
17 changes: 2 additions & 15 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,11 @@ MFLAGS=-mcpu=cortex-a9 -mfpu=neon-fp16 -mfloat-abi=softfp -Os -g
CPPFLAGS=-D_POSIX_THREADS -D_UNIX98_THREAD_MUTEX_ATTRIBUTES -D_POSIX_TIMERS -D_POSIX_MONOTONIC_CLOCK
GCCFLAGS=-ffunction-sections -fdata-sections -fdiagnostics-color -funwind-tables

# Check if the llemu files in libvgl exist. If they do, define macros that the
# llemu headers in the kernel repo can use to conditionally include the libvgl
# versions
ifneq (,$(wildcard ./include/liblvgl/llemu.h))
CPPFLAGS += -D_PROS_INCLUDE_LIBLVGL_LLEMU_H
endif
ifneq (,$(wildcard ./include/liblvgl/llemu.hpp))
CPPFLAGS += -D_PROS_INCLUDE_LIBLVGL_LLEMU_HPP
endif

WARNFLAGS+=-Wno-psabi

SPACE := $() $()
COMMA := ,

C_STANDARD?=gnu11
CXX_STANDARD?=gnu++20

DEPDIR := .d
$(shell mkdir -p $(DEPDIR))
DEPFLAGS = -MT $$@ -MMD -MP -MF $(DEPDIR)/$$*.Td
Expand All @@ -37,8 +24,8 @@ wlprefix=-Wl,$(subst $(SPACE),$(COMMA),$1)
LNK_FLAGS=--gc-sections --start-group $(strip $(LIBRARIES)) -lgcc -lstdc++ --end-group -T$(FWDIR)/v5-common.ld

ASMFLAGS=$(MFLAGS) $(WARNFLAGS)
CFLAGS=$(MFLAGS) $(CPPFLAGS) $(WARNFLAGS) $(GCCFLAGS) --std=$(C_STANDARD)
CXXFLAGS=$(MFLAGS) $(CPPFLAGS) $(WARNFLAGS) $(GCCFLAGS) --std=$(CXX_STANDARD)
CFLAGS=$(MFLAGS) $(CPPFLAGS) $(WARNFLAGS) $(GCCFLAGS) --std=gnu11
CXXFLAGS=$(MFLAGS) $(CPPFLAGS) $(WARNFLAGS) $(GCCFLAGS) --std=gnu++17
LDFLAGS=$(MFLAGS) $(WARNFLAGS) -nostdlib $(GCCFLAGS)
SIZEFLAGS=-d --common
NUMFMTFLAGS=--to=iec --format %.2f --suffix=B
Expand Down
Binary file added firmware/EZ-Template.a
Binary file not shown.
Binary file removed firmware/liblvgl.a
Binary file not shown.
Binary file modified firmware/libpros.a
Binary file not shown.
Binary file modified firmware/okapilib.a
Binary file not shown.
205 changes: 205 additions & 0 deletions include/EZ-Template/PID.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
/*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#pragma once

#include "EZ-Template/util.hpp"
#include "api.h"

namespace ez {
class PID {
public:
/**
* Default constructor.
*/
PID();

/**
* Constructor with constants.
*
* \param p
* kP
* \param i
* ki
* \param d
* kD
* \param p_start_i
* error value that i starts within
* \param name
* std::string of name that prints
*/
PID(double p, double i = 0, double d = 0, double start_i = 0, std::string name = "");

/**
* Set constants for PID.
*
* \param p
* kP
* \param i
* ki
* \param d
* kD
* \param p_start_i
* error value that i starts within
*/
void constants_set(double p, double i = 0, double d = 0, double p_start_i = 0);

/**
* Struct for constants.
*/
struct Constants {
double kp;
double ki;
double kd;
double start_i;
};

/**
* Struct for exit condition.
*/
struct exit_condition_ {
int small_exit_time = 0;
double small_error = 0;
int big_exit_time = 0;
double big_error = 0;
int velocity_exit_time = 0;
int mA_timeout = 0;
};

/**
* Set's constants for exit conditions.
*
* \param p_small_exit_time
* Sets small_exit_time. Timer for to exit within smalL_error.
* \param p_small_error
* Sets smalL_error. Timer will start when error is within this.
* \param p_big_exit_time
* Sets big_exit_time. Timer for to exit within big_error.
* \param p_big_error
* Sets big_error. Timer will start when error is within this.
* \param p_velocity_exit_time
* Sets velocity_exit_time. Timer will start when velocity is 0.
*/
void exit_condition_set(int p_small_exit_time, double p_small_error, int p_big_exit_time = 0, double p_big_error = 0, int p_velocity_exit_time = 0, int p_mA_timeout = 0);

/**
* Sets target.
*
* \param target
* Target for PID.
*/
void target_set(double input);

/**
* Computes PID.
*
* \param current
* Current sensor library.
*/
double compute(double current);

/**
* Returns target value.
*/
double target_get();

/**
* Returns constants.
*/
Constants constants_get();

/**
* Resets all variables to 0. This does not reset constants.
*/
void variables_reset();

/**
* Constants
*/
Constants constants;

/**
* Exit
*/
exit_condition_ exit;

/**
* Iterative exit condition for PID.
*
* \param print = false
* if true, prints when complete.
*/
ez::exit_output exit_condition(bool print = false);

/**
* Iterative exit condition for PID.
*
* \param sensor
* A pros motor on your mechanism.
* \param print = false
* if true, prints when complete.
*/
ez::exit_output exit_condition(pros::Motor sensor, bool print = false);

/**
* Iterative exit condition for PID.
*
* \param sensor
* Pros motors on your mechanism.
* \param print = false
* if true, prints when complete.
*/
ez::exit_output exit_condition(std::vector<pros::Motor> sensor, bool print = false);

/**
* Sets the name of the PID that prints during exit conditions.
*
* \param name
* a string that is the name you want to print
*/
void name_set(std::string name);

/**
* Returns the name of the PID that prints during exit conditions.
*/
std::string name_get();

/**
* Enables / disables i resetting when sgn of error changes. True resets, false doesn't.
*
* \param toggle
* true resets, false doesn't
*/
void i_reset_toggle(bool toggle);

/**
* Returns if i will reset when sgn of error changes. True resets, false doesn't.
*/
bool i_reset_get();

/**
* PID variables.
*/
double output;
double cur;
double error;
double target;
double prev_error;
double integral;
double derivative;
long time;
long prev_time;

private:
int i = 0, j = 0, k = 0, l = 0;
bool is_mA = false;
void timers_reset();
std::string name;
bool name_active = false;
void exit_condition_print(ez::exit_output exit_type);
bool reset_i_sgn = true;
};
}; // namespace ez
16 changes: 16 additions & 0 deletions include/EZ-Template/api.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#pragma once

#include "EZ-Template/PID.hpp"
#include "EZ-Template/auton.hpp"
#include "EZ-Template/auton_selector.hpp"
#include "EZ-Template/drive/drive.hpp"
#include "EZ-Template/piston.hpp"
#include "EZ-Template/sdcard.hpp"
#include "EZ-Template/slew.hpp"
#include "EZ-Template/util.hpp"
21 changes: 21 additions & 0 deletions include/EZ-Template/auton.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#pragma once
#include <functional>
#include <iostream>

namespace ez {
class Auton {
public:
Auton();
Auton(std::string, std::function<void()>);
std::string Name;
std::function<void()> auton_call;

private:
};
} // namespace ez
26 changes: 26 additions & 0 deletions include/EZ-Template/auton_selector.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#pragma once
#include <tuple>

#include "EZ-Template/auton.hpp"

using namespace std;

namespace ez {
class AutonSelector {
public:
std::vector<Auton> Autons;
int auton_page_current;
int auton_count;
AutonSelector();
AutonSelector(std::vector<Auton> autons);
void selected_auton_call();
void selected_auton_print();
void autons_add(std::vector<Auton> autons);
};
} // namespace ez
Loading

0 comments on commit fd7a242

Please sign in to comment.