-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swerve final #13
base: dev
Are you sure you want to change the base?
Swerve final #13
Conversation
from https://github.com/ishanm0/ReadIncrementalEncoderPio Co-Authored-By: Ishan Madan <[email protected]>
…i code is currently on the pi)
Co-authored-by: brendanRose1 <[email protected]> Co-authored-by: ananya-manduva <[email protected]>
… fast (only in the negative direction though) Co-authored-by: inkyant <[email protected]>
Co-authored-by: Anthony Furman <[email protected]>
Converted Pi control of motors in python (motor test) to Pico control of motors in c (cooler motor test)
Co-authored-by: brendanRose1 <[email protected]> Co-authored-by: ananya-manduva <[email protected]>
Co-authored-by: inkyant <[email protected]>
Co-authored-by: AriSinervo <[email protected]>
-new finalized branch for swerve module -consolidates code into one folder -try to make code match software map -rewrite i2c-controller into separate classes -remove old files & branches
unfinished 4 am code, hopefully a step forward?
small tweaks to software structure, added small TODO notes changes made with meeting with Ishan on ~5/16/24
moved everything into a new top-level folder to keep consistent with rest of repo
added basic-swerve dev folders
Added message library that encodes/decodes messages in specified format for modbot in c & python
Added processing for specific message ids in compute_module_id.py and swerve-module-id.h Added decoding of payload of 24 bytes -> 6 floats, changes state of robot to read converted floats
moved old swerve-decoder folder into _OLD
Added top level code that might get the swerve drive working (with enough editing to everything else...)
restructured order of PID loop, libraries, etc (add readme of changes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw @brendanRose1 does this compile?
@@ -0,0 +1,36 @@ | |||
|
|||
#include "pid.cpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should never include .c or .cpp files, instead, you use header files. in this case, you'd want to put the class definition with just the function signatures (ex. void Setup();
) in a file called control-library.h
, then in the corresponding cpp file, you define each function like this:
SwerveDrive::Setup() {
//code
}
and so on, not organized/indented into a class structure. If you want an example, look at this .h file paired with this .cpp file
swerve_pico/control-library/pid.cpp
Outdated
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#include "motor-library.cpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same .h/.cpp comments from control-library.cpp
swerve_pico/main.c
Outdated
@@ -0,0 +1,198 @@ | |||
#include <stdio.h> | |||
|
|||
#include "motor-library.cpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same .h/.cpp comments from motor-library.cpp for all of these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, since all of your libraries are cpp code, your main file needs to be cpp as well, not c
* | ||
* @return calculated checksum | ||
*/ | ||
char MessagingBSDChecksum(char* payloadString, unsigned char payloadLen) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok so everything above this line is fine, but actual code in the function definition (everything between the curly braces) should be in the cpp file
STATE_ZERO_MOTORS | ||
}; | ||
|
||
float resultArray[resultArraySize] = {0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iirc you can't do stuff like this (assigning variables) in a header file but I could be wrong
* @returns success/failure to process payload, next state of main state machine | ||
*/ | ||
char MessagingProcessPayload(char* payload, unsigned char id, unsigned char len){ | ||
switch(id){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same thing as messaging-library.h - the function code should be defined in a cpp file, not an h file
#define COUNT_MAX 65535 | ||
|
||
// class to instantiate swerve module | ||
class PWMControl { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same cpp/h organization comments as control-library.cpp
/** | ||
* Motor class that holds PWMControl and quadrature_encoder class, encapsulates functions to set and read values of 1 motor | ||
*/ | ||
class Motor{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same cpp/h organization comments as control-library.cpp
const float PULLEY_RATIO = 0.3185 / 1.528; | ||
const float DEG_PER_ROT = 360.0; | ||
|
||
class Encoder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same cpp/h organization comments
#include <pico/i2c_slave.h> | ||
#include <pico/stdlib.h> | ||
|
||
class ZeroingSensor{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same cpp/h organization comments
(I'm gonna use this to make comments)