Skip to content
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

Put frontend on the car #4

Merged
merged 101 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from 100 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
9769461
updating
RCMast3r Mar 16, 2024
f7af210
uh
RCMast3r Mar 17, 2024
70891a8
removed file
RCMast3r Mar 17, 2024
c38d760
removing @kevin 's idea files
RCMast3r Mar 28, 2024
998b65a
getting newest can msgs
RCMast3r Mar 28, 2024
8073029
fixing
RCMast3r Mar 28, 2024
c2cdba1
yup
RCMast3r Mar 28, 2024
bc60aa8
pushing up
RCMast3r Mar 28, 2024
402d4d2
fixing package name
RCMast3r Mar 28, 2024
766ca7d
updating and fixing flake
RCMast3r Mar 28, 2024
f77f931
updating to batch receive msg
RCMast3r Mar 29, 2024
f333ee5
continuing integration of vectornav reading on tcu
RCMast3r Mar 29, 2024
dd434ac
um
RCMast3r Mar 29, 2024
4847882
made react project, and added some basic elements
klou23 Feb 28, 2024
dc97524
created forms for entering metadata
klou23 Mar 1, 2024
ceddba8
Added post requests, and disable button unless form is filled
klou23 Mar 6, 2024
7f30b4b
edit server to use new UI and save metadata
klou23 Mar 10, 2024
d9def98
nix stuff???
klou23 Mar 10, 2024
32d5ffc
added offload button
klou23 Mar 10, 2024
673b83f
added darwin support
BANANAPEEL202 Mar 15, 2024
ce0f48b
Removed car setup from fields
klou23 Mar 15, 2024
2cb83c4
tried using flake-utils to support mac
BANANAPEEL202 Mar 17, 2024
3fc59e9
removed can-utils from flake.nix and python.systemd from default.nix …
BANANAPEEL202 Mar 20, 2024
47d6905
ensured cantools skips checkPhase
BANANAPEEL202 Mar 20, 2024
ca12af7
added allowUnsupportedSystem = true
BANANAPEEL202 Mar 20, 2024
c5979d0
flask + nix stuff
klou23 Mar 20, 2024
ece6068
node2nix magic
BANANAPEEL202 Mar 20, 2024
732142f
Update .gitignore
BANANAPEEL202 Mar 20, 2024
20ca8f5
added tailwindcss and daisyui to package.json
BANANAPEEL202 Mar 24, 2024
28606b8
added import statements
klou23 Mar 24, 2024
b67fac0
added comment
BANANAPEEL202 Mar 27, 2024
03aa16b
progress on nix build of frontend, issue with .cache folder for eslin…
RCMast3r Mar 27, 2024
528121c
kinda fixed build, paths not correct in output
RCMast3r Mar 27, 2024
86b3570
actually working pog
RCMast3r Mar 27, 2024
66aa057
remove carSetupId
klou23 Mar 28, 2024
242bba0
testing
klou23 Mar 28, 2024
915a389
testing
klou23 Mar 28, 2024
428ff8b
test 3
klou23 Mar 28, 2024
3498403
fixed it
klou23 Mar 28, 2024
365a369
adding in docs and new devshell for local development
RCMast3r Mar 28, 2024
7469947
actually fixed
klou23 Mar 28, 2024
22f0d23
test CORS
klou23 Mar 28, 2024
cc0e930
fixed CORS
klou23 Mar 28, 2024
f06fe54
test again
klou23 Mar 28, 2024
f208303
fixed mcap recording
klou23 Mar 28, 2024
417bac9
feat(mcap_server): re-added metadata handling and added some more checks
SreeDan Mar 28, 2024
4498f71
slight frontend changes
klou23 Mar 28, 2024
b08bc5a
fix(runner): ensured server starts first in the tasks
SreeDan Mar 28, 2024
00a6941
disable button until fetch response
klou23 Mar 28, 2024
b39aa2b
fix(startstopbutton): changed webserver url so requests dont hang
SreeDan Mar 29, 2024
aa49669
update git ignore
BANANAPEEL202 Mar 28, 2024
c7f1fe7
fix url
SreeDan Mar 29, 2024
143eec2
changed api url to local pi one
SreeDan Mar 29, 2024
9805c95
removed duplicate frontend_Overlay
BANANAPEEL202 Apr 5, 2024
43a447e
removed duplicate nix protos overlay
BANANAPEEL202 Apr 5, 2024
8f82ea0
added loop for start_stop_mcap_generatoin
BANANAPEEL202 Apr 7, 2024
79b5fe5
added some stuff to dropdown form for testing
klou23 Apr 7, 2024
1722953
added add button to dropdown
klou23 Apr 7, 2024
a1147b8
added routes for saving data to txt
BANANAPEEL202 Apr 7, 2024
8075986
Added fetch for options
klou23 Apr 7, 2024
dc79040
change to kevin local ip
klou23 Apr 7, 2024
8b33a40
added print for debugging
klou23 Apr 7, 2024
98ae227
changes
klou23 Apr 7, 2024
15c0ee1
back to old return type
BANANAPEEL202 Apr 7, 2024
cc8c6d1
another print statement
klou23 Apr 7, 2024
5452d1c
added time to metadata
BANANAPEEL202 Apr 18, 2024
ac3f991
Revert "added time to metadata"
BANANAPEEL202 Apr 18, 2024
66f6f43
change queue size to zero (infinite)
klou23 Apr 18, 2024
e0cd194
remove dropdown menu
klou23 Apr 19, 2024
ba1b096
fixed spacing
klou23 Apr 21, 2024
4d6a59f
remove dropdown menu
klou23 Apr 21, 2024
14072b4
Fix spacing pt1
klou23 Apr 21, 2024
cbbcc8c
Fix spacing pt2
klou23 Apr 21, 2024
28369f3
added return value for stop
klou23 Apr 21, 2024
ee21101
Merge branch 'frontend' of https://github.com/hytech-racing/data_acq …
klou23 Apr 21, 2024
ead285b
changed ip to car ip
BANANAPEEL202 Apr 21, 2024
33a6ac7
changed ip to car ip
BANANAPEEL202 Apr 21, 2024
bb4d5e4
run server in separate thread
klou23 Apr 21, 2024
9777ae6
got meta data writing actually working
RCMast3r Apr 22, 2024
c45c4ef
removed print statements
RCMast3r Apr 22, 2024
d73f1bd
uh sure
BANANAPEEL202 Apr 23, 2024
51a2bb2
yay
klou23 Apr 23, 2024
8a33adb
fixed request body?
BANANAPEEL202 Apr 23, 2024
b1a5799
fixed request body v2
BANANAPEEL202 Apr 23, 2024
09e77d5
removed time from json
BANANAPEEL202 Apr 23, 2024
e1a8383
fixed body v3
BANANAPEEL202 Apr 23, 2024
2d27751
verified please?
BANANAPEEL202 Apr 23, 2024
ea812c7
Merge branch 'frontend-dropdown' of https://github.com/hytech-racing/…
BANANAPEEL202 Apr 23, 2024
b883be0
please verify
BANANAPEEL202 Apr 23, 2024
cc1a38f
Merge pull request #1 from hytech-racing/frontend-verified
BANANAPEEL202 Apr 23, 2024
3afdd37
changed ip from localhost to 0.0.0.0
BANANAPEEL202 Apr 24, 2024
f233298
changed from local to 192 ip address
BANANAPEEL202 Apr 24, 2024
6611c90
fixed kevin's metadata code for him
BANANAPEEL202 Apr 24, 2024
9ddbcc8
Merge pull request #3 from hytech-racing/frontend-dropdown
BANANAPEEL202 Apr 24, 2024
f4ebe73
added toggle button
klou23 Apr 26, 2024
8ad16f2
fixed ssot problems
klou23 Apr 26, 2024
a8d19e1
dropdown form
klou23 Apr 26, 2024
1434b19
remove .idea folders ....
RCMast3r Apr 27, 2024
5293c57
removing stuff
RCMast3r Apr 27, 2024
f6208a5
removing more files
RCMast3r Apr 27, 2024
ad87810
removing even more .DS_Store s
RCMast3r Apr 27, 2024
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
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ result/
.env
.idea/
*.mat
*.log
*.log
.DS_Store
*.mat
py_data_acq/.DS_Store
*.DS_Store
.idea/
**/.idea/
py_data_acq/py_data_acq.egg-info/*
py_data_acq/py_data_acq.egg-info/
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ usage notes:

by default, it uses a fixed version of the hytech CAN library and it must be manually updated. downstream usage of this can update this too via specifying it in the flake input as well if need be.

### for kevin's new frontend

1. in one devshell (call `nix develop`):

```npm run start --prefix $FRONT```

2. in a second devshell:
```runner.py```

### TODO:
- [x] write test script for creating a cantools constructed hytech CAN msg and sends it over a virtual CAN line
Expand Down
3 changes: 2 additions & 1 deletion dbc_proto_gen_script.nix
RCMast3r marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ python311Packages.buildPythonApplication {
version = "1.0.0";


propagatedBuildInputs = [ python311Packages.cantools python311Packages.protobuf python311Packages.requests ];
propagatedBuildInputs = [ (python311Packages.cantools.overridePythonAttrs (_: { doCheck = false; }))
python311Packages.protobuf python311Packages.requests ];

src = ./py_dbc_proto_gen;
}
13 changes: 10 additions & 3 deletions default.nix
RCMast3r marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
, asyncudp_pkg
, hytech_np_proto_py
, proto_gen_pkg
, py_foxglove_protobuf_schemas
, vn_protos_np_proto_py
}:

python311Packages.buildPythonApplication {
pname = "py_data_acq";
version = "1.0.1";

propagatedBuildInputs = [
python311Packages.cantools
python311Packages.systemd

(python311Packages.cantools.overridePythonAttrs (_: { doCheck = false; }))
#python311Packages.cantools
#python311Packages.systemd #commented out cuz linux only
python311Packages.websockets
python311Packages.pprintpp
python311Packages.can
Expand All @@ -28,6 +30,11 @@ python311Packages.buildPythonApplication {
py_mcap_pkg
hytech_np_proto_py
proto_gen_pkg
py_foxglove_protobuf_schemas
vn_protos_np_proto_py
python311Packages.flask
python311Packages.flask-cors
python311Packages.hypercorn
];

src = ./py_data_acq;
Expand Down
36 changes: 36 additions & 0 deletions fix_mcaps.py

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe this script can be removed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we use this file either.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import sys
from mcap.writer import Writer
from mcap.reader import make_reader

def fix_mcap_file(input_file_path, output_file_path):
with open(input_file_path, "rb") as input_file:
reader = make_reader(input_file)

with open(output_file_path, "wb") as output_file:
writer = Writer(output_file)

# Iterate through all schemas and channels in the original file
for schema in reader.schemas.values():
writer.register_schema(schema.name, schema.encoding, schema.data)

for channel in reader.channels.values():
writer.register_channel(channel.id, channel.topic, channel.message_encoding, channel.schema_id)

# Reading and writing all messages
for message in reader.read_messages():
writer.add_message(
log_time=message.log_time,
publish_time=message.publish_time,
channel_id=message.channel_id,
data=message.data
)

print(f"Processed and copied messages to {output_file_path}")

if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python script.py <path_to_input_mcap>")
else:
input_file_path = sys.argv[1]
output_file_path = sys.argv[1] + "_fixed"
fix_mcap_file(input_file_path, output_file_path)
32 changes: 16 additions & 16 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 55 additions & 19 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
mcap.url = "github:RCMast3r/py_mcap_nix";
foxglove-websocket.url = "github:RCMast3r/py_foxglove_webserver_nix";
asyncudp.url = "github:RCMast3r/asyncudp_nix";
ht_can_pkg_flake.url = "github:hytech-racing/ht_can/40";
ht_can_pkg_flake.url = "github:hytech-racing/ht_can/41";
nix-proto = { url = "github:notalltim/nix-proto"; };
};

Expand All @@ -34,7 +34,9 @@
py_dbc_proto_gen_pkg = pkgs.py_dbc_proto_gen_pkg;
proto_gen_pkg = pkgs.proto_gen_pkg;
hytech_np = pkgs.hytech_np;
vn_protos_np = pkgs.vn_protos_np;
hytech_np_proto_py = pkgs.hytech_np_proto_py;
vn_protos_np_proto_py = pkgs.vn_protos_np_proto_py;
default = pkgs.py_data_acq_pkg;
};

Expand All @@ -47,30 +49,54 @@
proto_gen_overlay = final: prev: {
proto_gen_pkg = final.callPackage ./dbc_proto_bin_gen.nix { };
};
py_foxglove_protobuf_schemas_overlay = final: prev: {
py_foxglove_protobuf_schemas = final.callPackage ./py_foxglove_protobuf_schemas.nix { };
};

nix_protos_overlays = nix-proto.generateOverlays' {
hytech_np = { proto_gen_pkg }:
nix-proto.mkProtoDerivation {
name = "hytech_np";
buildInputs = [ proto_gen_pkg ];
src = proto_gen_pkg.out + "/proto";
version = "1.0.0";
};
frontend_overlay = final: prev: {
frontend_pkg = final.callPackage ./frontend.nix { };
};



nix_protos_overlays = nix-proto.generateOverlays'
{
hytech_np = { proto_gen_pkg }:
nix-proto.mkProtoDerivation {
name = "hytech_np";
buildInputs = [ proto_gen_pkg ];
src = proto_gen_pkg.out + "/proto";
version = "1.0.0";
};
vn_protos_np = { hytech_np }:
nix-proto.mkProtoDerivation {
name = "vn_protos_np";
src = nix-proto.lib.srcFromNamespace {
root = ./proto;
namespace = "vectornav_proto";
};
version = "1.0.0";
protoDeps = [ hytech_np ];
};
};
my_overlays = [
(self: super: {
cantools = super.cantools.overridePythonAttrs (old: rec {
version = "39.4.5";
src = old.fetchPypi {
pname = "cantools";
inherit version;
# hash = "sha256-JQn+rtpy/OA2deLszSKEuxyttqBzcAil50H+JDHUdCE=";
};
});
})
cantools = super.cantools.overridePythonAttrs (old: rec {
version = "39.4.5";
src = old.fetchPypi {
pname = "cantools";
inherit version;
# hash = "sha256-JQn+rtpy/OA2deLszSKEuxyttqBzcAil50H+JDHUdCE=";
};
});
})

py_dbc_proto_gen_overlay
py_data_acq_overlay
proto_gen_overlay
py_foxglove_protobuf_schemas_overlay

frontend_overlay
ht_can_pkg_flake.overlays.default
mcap-protobuf.overlays.default
mcap.overlays.default
Expand All @@ -80,6 +106,9 @@
pkgs = import nixpkgs {
overlays = my_overlays;
inherit system;
config = {
allowUnsupportedSystem = true;
};
};

shared_shell = pkgs.mkShell rec {
Expand All @@ -92,7 +121,9 @@
ht_can_pkg
cmake
can-utils
nodejs
python311Packages.scipy
frontend_pkg.frontend
];
# Setting up the environment variables you need during
# development.
Expand All @@ -102,9 +133,10 @@
path=${pkgs.proto_gen_pkg}
bin_path=$path"/bin"
dbc_path=${pkgs.ht_can_pkg}
frontend_path=${pkgs.frontend_pkg.frontend}
export BIN_PATH=$bin_path
export DBC_PATH=$dbc_path

export FRONT=$frontend_path
echo -e "PYTHONPATH=$PYTHONPATH\nBIN_PATH=$bin_path\nDBC_PATH=$dbc_path\n" > .env
export PS1="$(echo -e '\u${icon}') {\[$(tput sgr0)\]\[\033[38;5;228m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]} (${name}) \\$ \[$(tput sgr0)\]"
'';
Expand All @@ -118,6 +150,7 @@
py_dbc_proto_gen_pkg
proto_gen_pkg
ht_can_pkg
frontend_pkg
protobuf
];
shellHook =
Expand All @@ -139,11 +172,14 @@
};

packages = rec {
frontend_pkg = pkgs.frontend_pkg.frontend;
default = pkgs.py_data_acq_pkg;
py_dbc_proto_gen_pkg = pkgs.py_data_acq_pkg;
proto_gen_pkg = pkgs.proto_gen_pkg;
hytech_np = pkgs.hytech_np;
vn_protos_np = pkgs.vn_protos_np;
hytech_np_proto_py = pkgs.hytech_np_proto_py;
vn_protos_np_proto_py = pkgs.vn_protos_np_proto_py;
};

});
Expand Down
45 changes: 45 additions & 0 deletions frontend.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{ pkgs, stdenv, system, callPackage, nodejs, nodePackages, writeShellScriptBin }:
let
# Import & invoke the generated files from node2nix
generated = callPackage ./frontend/nix { inherit pkgs system nodejs; };

# node2nix wrapper to update nix files on npm changes
node2nix = writeShellScriptBin "node2nix" ''
${nodePackages.node2nix}/bin/node2nix \
--development \
-l package-lock.json \
-c ./frontend/nix/default.nix \
-o ./frontend/nix/node-packages.nix \
-e ./frontend/nix/node-env.nix
'';

in
{
inherit (generated) nodeDependencies;
frontend = pkgs.stdenv.mkDerivation
{
name = "frontend";
version = "0.1.0";
src = ./frontend; #gitignore.lib.gitignoreSource ./.; # uses the gitignore in the repo to only copy files git would see
buildInputs = [ pkgs.nodejs ];
buildPhase = ''
export HOME=$TMP

ln -s ${generated.nodeDependencies}/lib/node_modules ./node_modules
export PATH="${generated.nodeDependencies}/bin:$PATH"

npm run build
'';
installPhase = ''
ls
mkdir -p $out/build
cp tailwind.config.js $out/
cp tsconfig.json $out/
cp -r public $out/
cp -r src $out/
cp -r build $out/
cp package.json $out/
ln -sf ${generated.nodeDependencies}/lib/node_modules $out/node_modules
'';
};
}
Loading
Loading