Skip to content

Commit

Permalink
⬆️3.1.0 (#124)
Browse files Browse the repository at this point in the history
* New action for deploying website

* ⬆️ PROS 4 Porting work (#100)

* New action for deploying website (#98)

* PROS 4 Porting work

* Revert gitignore

* Added imu loading animation

---------

Co-authored-by: Jess Zarchi <[email protected]>

* 🐛Fixed unit conversion for exit conditions

* 🐛Fixed derivative kick #99 (#105)

* ✨Added imu scaling #104 (#106)

* ✨Imu velocity exiting #102 

* PID class has secondary sensor velocity support, implemented that with imu accel into exit conditions

* Made names more clear, added missing functions

* 🐛Max text width is wider #112 (#113)

* 🐛Exit condition print error #111 (#114)

* ✨Motion chaining #109 (#115)

* Motion chaining and quick exits are functional #109

* Added reverse constants, okapi units, finalized function names and comments

* 🐛Fixed scaling in drive pid #110 (#116)

* Upgraded example project, cleaned formatting everywhere

Main project builds fine, the example project is giving me strange errors about the LCD.  Not sure how to fix this

* Timers now correctly reset between motions #117

* Added liblvgl to example project, updated template

* Changing max speed works, new (old) default constants, new constructor #118 #119 #120

* Fixed typo in example project

* Cleaned up example project

* Main project updated to example, fixed #122 and #123

* Final 3.1.0 push.  Template and example project finalized

---------

Co-authored-by: Will Xu <[email protected]>
  • Loading branch information
ssejrog and WillXuCodes authored Jun 10, 2024
1 parent bb6775f commit 9699470
Show file tree
Hide file tree
Showing 623 changed files with 94,386 additions and 34,186 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ yarn-error.log*
# Compiled Object files
*.o
*.obj

# Executables
*.bin
*.elf

# PROS
bin/
.vscode/
Expand All @@ -44,4 +42,5 @@ EZ-Template-Example-Project/compile_commands.json
EZ-Template-Example-Project/temp.log
EZ-Template-Example-Project/temp.errors
EZ-Template-Example-Project/*.ini
EZ-Template-Example-Project/.d/
EZ-Template-Example-Project/.d/
.d/
Binary file not shown.
4 changes: 4 additions & 0 deletions EZ-Template-Example-Project/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BasedOnStyle: Google
ColumnLimit: 0
TabWidth: 2
IndentWidth: 2
Binary file removed EZ-Template-Example-Project/[email protected]
Binary file not shown.
Binary file added EZ-Template-Example-Project/[email protected]
Binary file not shown.
17 changes: 15 additions & 2 deletions EZ-Template-Example-Project/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,24 @@ 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 @@ -24,8 +37,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=gnu11
CXXFLAGS=$(MFLAGS) $(CPPFLAGS) $(WARNFLAGS) $(GCCFLAGS) --std=gnu++17
CFLAGS=$(MFLAGS) $(CPPFLAGS) $(WARNFLAGS) $(GCCFLAGS) --std=$(C_STANDARD)
CXXFLAGS=$(MFLAGS) $(CPPFLAGS) $(WARNFLAGS) $(GCCFLAGS) --std=$(CXX_STANDARD)
LDFLAGS=$(MFLAGS) $(WARNFLAGS) -nostdlib $(GCCFLAGS)
SIZEFLAGS=-d --common
NUMFMTFLAGS=--to=iec --format %.2f --suffix=B
Expand Down
Binary file modified EZ-Template-Example-Project/firmware/EZ-Template.a
Binary file not shown.
Binary file added EZ-Template-Example-Project/firmware/liblvgl.a
Binary file not shown.
Binary file modified EZ-Template-Example-Project/firmware/libpros.a
Binary file not shown.
Binary file modified EZ-Template-Example-Project/firmware/okapilib.a
Binary file not shown.
98 changes: 86 additions & 12 deletions EZ-Template-Example-Project/include/EZ-Template/PID.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,21 @@ class PID {
* Computes PID.
*
* \param current
* Current sensor library.
* Current sensor value.
*/
double compute(double current);

/**
* Computes PID, but you set the error yourself. This function ignores target.
* Current is only used here for calculative derivative.
*
* \param err
* Error in PID, you need to calculate this yourself.
* \param current
* Current sensor value.
*/
double compute_error(double err, double current);

/**
* Returns target value.
*/
Expand All @@ -126,6 +137,58 @@ class PID {
*/
exit_condition_ exit;

/**
* Updates a secondary sensor for velocity exiting. Ideal use is IMU during normal drive motions.
*
* \param secondary_sensor
* double for a secondary sensor.
*/
void velocity_sensor_secondary_set(double secondary_sensor);

/**
* Returns the updated secondary sensor for velocity exiting.
*/
double velocity_sensor_secondary_get();

/**
* Boolean for if the secondary sensor will be updated or not. True uses this sensor, false does not.
*
* \param toggle
* True uses this sensor, false does not.
*/
void velocity_sensor_secondary_toggle_set(bool toggle);

/**
* Returns the boolean for if the secondary sensor will be updated or not. True uses this sensor, false does not.
*/
bool velocity_sensor_secondary_toggle_get();

/**
* Sets the threshold that the main sensor will return 0 velocity within
*
* \param zero
* a small double
*/
void velocity_sensor_main_exit_set(double zero);

/**
* Returns the threshold that the main sensor will return 0 velocity within
*/
double velocity_sensor_main_exit_get();

/**
* Sets the threshold that the secondary sensor will return 0 velocity within
*
* \param zero
* a small double
*/
void velocity_sensor_secondary_exit_set(double zero);

/**
* Returns the threshold that the secondary sensor will return 0 velocity within
*/
double velocity_sensor_secondary_exit_get();

/**
* Iterative exit condition for PID.
*
Expand Down Expand Up @@ -180,26 +243,37 @@ class PID {
*/
bool i_reset_get();

/**
* Resets all timers for exit conditions.
*/
void timers_reset();

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

private:
int i = 0, j = 0, k = 0, l = 0;
double velocity_zero_main = 0.05;
double velocity_zero_secondary = 0.1;
int i = 0, j = 0, k = 0, l = 0, m = 0;
bool is_mA = false;
void timers_reset();
double second_sensor = 0.0;

std::string name;
bool name_active = false;
void exit_condition_print(ez::exit_output exit_type);
bool reset_i_sgn = true;
double raw_compute();
bool use_second_sensor = false;
};
}; // namespace ez
Loading

0 comments on commit 9699470

Please sign in to comment.