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

Feature/param server integration #12

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
eac6547
adding in stub for param_interface / generic protobuf message receivi…
RCMast3r May 12, 2024
7ca9244
semi-working web interface
RCMast3r May 13, 2024
7670fb2
TODO fix the cmd queue
RCMast3r May 13, 2024
0069f27
starting work on the socket interface
RCMast3r May 13, 2024
5e73a91
small updates to python progress-wise and added in diagram for new fl…
RCMast3r May 13, 2024
0ed499c
cranking through more of the features
RCMast3r May 14, 2024
e52fc32
progressing on integration more. added in most of the socket and web …
RCMast3r May 14, 2024
2030dd8
giving up on asyncio and starting on threading
RCMast3r May 15, 2024
498bc91
adding threaded runner
RCMast3r May 15, 2024
212a85c
most of the way through the first two threads of v2. TODO add in the …
RCMast3r May 15, 2024
60505be
working except for web app
RCMast3r May 16, 2024
60bdb9e
seemingly kinda working
RCMast3r May 16, 2024
e18b2c6
working mcap writer start / stop integration with the new web app
RCMast3r May 16, 2024
b9d700d
completely working frontend, file writer, foxglove websocket and para…
RCMast3r May 17, 2024
bbe3087
fixing merge
RCMast3r May 17, 2024
f1fbcbb
working fully integration and tested with test script TODO test on th…
RCMast3r May 17, 2024
7f8fefe
merging in master and removing old frontend
RCMast3r May 18, 2024
d4f0354
removing on PR workflow run
RCMast3r May 18, 2024
e8b7134
fixing schema names
RCMast3r May 18, 2024
af18786
removing print lines, seemingly working on car
RCMast3r May 18, 2024
9d08601
ensuring that args are ints
RCMast3r May 18, 2024
88daa77
working on tcu
RCMast3r May 18, 2024
91746b3
changed interface producer to be more basic. working on local comp
RCMast3r May 18, 2024
7a3e476
working on car
RCMast3r May 18, 2024
0f02fd5
working recording location for on nixos
RCMast3r May 18, 2024
a38291c
removing print statements
RCMast3r May 19, 2024
6e98a6b
working through unfuck NOT WORKING OBVIOUSLY
RCMast3r May 22, 2024
68c210d
current progress
RCMast3r May 25, 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
4 changes: 0 additions & 4 deletions .github/workflows/create_dbc_and_proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

jobs:
build-packages:
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"python.pythonPath": "/nix/store/qp5zys77biz7imbk6yy85q5pdv7qk84j-python3-3.11.6/bin/python"
"python.pythonPath": "/nix/store/qp5zys77biz7imbk6yy85q5pdv7qk84j-python3-3.11.6/bin/python",
"python.analysis.typeCheckingMode": "off"
}
55 changes: 43 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,54 @@ output:
- once both the data writer and the foxglove websocket have finished processing the data delete the data from the container
- a desired workflow is that it all we need to do to add a new input that we will be seeing over the wire is to add a .proto to a specific folder. No code changes should be required.

previous flow:
```mermaid

flowchart TD
CAN[RPI CAN] --> py_async_q[encoded CAN data]
py_async_q --> des[DBC based CAN parser]
des --> pb_pack[protobuf packet creation]

pb_pack --> data_q1[webserver protobuf packet queue]
pb_pack --> data_q2[MCAP file writer protobuf packet queue]
subgraph websocket thread
data_q1 --> enc[serialize into protobuf packet]
enc --> py_foxglove[foxglove server websocket]
end
subgraph file writer thread
data_q2 --> py_mcap[MCAP file writer]
CAN -- raw CAN message --> dec[CAN decode and pb msg encode]
UDP-s[udp socket recv port] --union oneof type msg--> packet_mux[oneof message de-mux]

subgraph web interface


web_interface[frontend website] -- param change ---> pb_msg[param pb msg]
web_interface -- some other command --> pb_msg_other[other command pb msg ...]
web_interface -- recorder commands --> mcap_rec_command_queue
pb_msg_other ---> message_packer[pb message serialization handler]
pb_msg --> message_packer
end

subgraph data acquisition


mcap_rec_command_queue --> mcap_file_writer
packet_mux -- encoded raw pb received msg --> enqueue
enqueue -- decoded param pb message -----> web_interface
%% packet_mux -- decoded pb msg --> mcap_rec_q[mcap recorder queue]

mcap_rec_q --> mcap_file_writer
enqueue --all decoded pb msg--> mcap_rec_q[mcap recorder queue]
enqueue --all encoded pb msg--> live_qlive_q[live pb msg queue]


dec -- encoded pb received CAN msg --> enqueue[enqueue handler]
%% dec --decoded pb msg--> mcap_rec_q
%% dec --encoded pb msg--> live_q


live_qlive_q --> foxglove-websocket

pb_msg -- encoded param pb msg --> enqueue
pb_msg_other -- encoded command pb msg --> enqueue

end
message_packer -- oneof union message --> udp_send[udp send socket port]
mcap_file_writer--> mcap_file[mcap file on car]
foxglove-websocket --> fxglv[user foxglove studio viz]
```



### notes:
- filter journalctl based on service: `journalctl -u nginx.service`

Expand Down
72 changes: 72 additions & 0 deletions V2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
after struggling a lot with the big ass architecture of this boi using co-routines, im gonna try to switch to a threaded architecture as i know that it will give me what I want directly. I should be able to use pretty much the same architecture, just with different tools cuz ive been treating co-routines like they are threads and it hasnt really been working lol.

multi-threaded handling:

1 thread for all input data that handles receiving, parsing streaming and logging
inputs:
- CAN data
- UDP data
- will check for CAN messages and / or UDP messages, parse them into protobuf messages and put them into the output queue
- will append to a SINGLE queue the data
1 thread for handling the streaming of the data into foxglove and the mcap file and output the current parameter / config that gets parsed from the data queue
- will consume the main data queue coming from the interface producers

- will consume another queue coming from the web interface
- will maintain part of the asyncio infrastructure in that the foxglove webserver in that the mcap writer and the foxglove webserver will be in two different tasks
- will look to see if the incoming data is a parameter message (or some other msg that the frontend needs) and will output it to the frontend data queue

1 thread for handling the website and the display state
- will wait for the following to trigger a run of the processes:
- frontend data queue data receive
- user input from the website
- will consume the frontend data queue
- will handle the user interaction
- will handle the serving of the website
- will append to the output data queue data created by the user (config change, etc.)


tools I will use:

`threading.Condition()`

condition will be used in the website handling thread
```python
import threading

class OddEvenPrinter:
def __init__(self):
self.lock = threading.Lock()
self.condition = threading.Condition(self.lock)
self.number = 1

def print_odd(self):
for _ in range(10):
with self.condition:
while self.number % 2 == 0:
self.condition.wait()
print("Odd:", self.number)
self.number += 1
self.condition.notify()

def print_even(self):
for _ in range(10):
with self.condition:
while self.number % 2 != 0:
self.condition.wait()
print("Even:", self.number)
self.number += 1
self.condition.notify()

printer = OddEvenPrinter()

odd_thread = threading.Thread(target=printer.print_odd)
even_thread = threading.Thread(target=printer.print_even)

odd_thread.start()
even_thread.start()

odd_thread.join()
even_thread.join()

print("Printing finished")
```
16 changes: 8 additions & 8 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
, py_mcap_pkg
, py_foxglove_websocket_pkg
, asyncudp_pkg
, hytech_np_proto_py
, proto_gen_pkg
, py_foxglove_protobuf_schemas
, vn_protos_np_proto_py
, hytech_eth_np_proto_py
, hytech_np_proto_py
}:

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

propagatedBuildInputs = [
(python311Packages.cantools.overridePythonAttrs (_: { doCheck = false; }))
#python311Packages.cantools
#python311Packages.systemd #commented out cuz linux only
python311Packages.cantools
python311Packages.systemd
python311Packages.websockets
python311Packages.pprintpp
python311Packages.can
Expand All @@ -30,11 +28,13 @@ 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
python311Packages.quart

python311Packages.asgiref # required for flask async
hytech_eth_np_proto_py
];

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

This file was deleted.

Loading