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

Improvements of the Development Setup #4

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ if(NO_CANLIB)
add_compile_definitions(NO_CANLIB)
endif()

if(NO_INFLUX)
MESSAGE(STATUS "InfluxDB is not used")
add_compile_definitions(NO_INFLUX)
endif()

if(UNIX AND NOT APPLE)
set(LINUX TRUE)
Expand Down
92 changes: 92 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,97 @@
# Low Level Server for the Engine Control User Interface

# Development Setup
The LLServer is meant to be used in conjuction with a can-bus and an influxdb logging server.
For local development the following setup is recommended:

## can interface
The LLServer still requires a can interface to be present on the system to function.
You can create a dummy can interface with the following commands:
```bash
sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0
```

## Building the LLServer
Use the following cmake variables to run the LLServer in Dev Mode:
```bash
mkdir build && cd build
cmake -D NO_PYTHON=true -D NO_CANLIB=true -D NO_INFLUX=true .. -o ./
make -j
```
This disables the python bindings, the canbus interface and the influxdb logging.

## Running the LLServer
The LLServer requires a `config.json` and a `mapping.json` file to run. You can find examples in the `config` folder.

To run the LLServer with the example config files, use the following command:
```bash
ECUI_CONFIG_PATH=$(dirname "$PWD")/sample_config ./llserver_ecui_houbolt
```

Please note that without the CAN Bus none of the commands will work. You can crudely some for testing like this in the LLInterface::init:

```c++
auto doStuff = [](std::vector<double> &data, bool flag) {
std::string str = [&data] {
std::ostringstream oss;
std::copy(data.begin(), data.end(), std::ostream_iterator<double>(oss, " "));
return oss.str();
}();
Debug::print("doStuff flag: %d values: %s", flag, str.c_str());
};

eventManager->AddCommands({{"doStuff", {doStuff, {}}}});

```



## Emulating the ECUI
The LLServer communicates over a TCP-Socket with the [ECUI](https://github.com/SpaceTeam/web_ecui_houbolt).
To emulate this one can use the [ECUIEmulator.py](scripts/ECUIEmulator.py) script.
You have to set the message `type` and `data` and it will send it to the LLServer.
Responses are logged to the console.

Eg. Starting a sequence:
```bash
python3 scripts/ECUIEmulator.py
Starting JSON socket server.
Enter your message type(one of sequence-start, send-postseq-comment, abort, auto-abort-change, states-load, states-get, states-set, states-start, states-stop, gui-mapping-load, commands-load, commands-set):
sequence-start
Enter your JSON message (send with `END` in a new line):
{
"globals": {
"endTime": 10,
"interpolation": {
"doStuff": "none"
},
"interval": 0.01,
"startTime": -3
},
"data": [
{
"timestamp": "START",
"name": "start",
"desc": "start",
"actions": [
{
"timestamp": 0.0,
"doStuff": [
2
]
}
]
}

]
}
END
Message sent.

```

## Links

Documentation of whole ECUI and Setup Guide
Expand Down
111 changes: 111 additions & 0 deletions sample_config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"version": "1.3.1@Lamarr",
"autoabort": false,
"pyenv": "/home/.local/lib/python3.8/site-packages",
"auto_start": true,
"DEBUG": {
"printWarnings": true,
"printInfos": true
},
"socket_msg_size": 65536,
"LOGGING": {
"post_sequence_script": "scripts/plot.sh"
},
"use_lora": false,
"LORA": {
"ip": "192.168.100.5",
"port": 5001,
"nodeIDsRef": [
33,
31,
32,
29
],
"nodeIDs": [
13,
11,
12,
19
],
"canMsgSizes": [
48,
48,
48,
39
]
},
"CAN": {
"node_count": 0,
"blocking_timeout": 2048,
"BUS": {
"ARBITRATION": {
"bitrate": 1000000,
"time_segment_1": 23,
"time_segment_2": 16,
"sync_jump_width": 1,
"no_sampling_points": 1
},
"DATA": {
"bitrate": 4000000,
"time_segment_1": 7,
"time_segment_2": 2,
"sync_jump_width": 2
}
},
"DRIVER": "SocketCAN",
"DEVICE": [
"vcan0"
],
"BUS_EXTRA": {
"1": {
"ARBITRATION": {
"bitrate": 1000000,
"time_segment_1": 7,
"time_segment_2": 2,
"sync_jump_width": 1,
"no_sampling_points": 1
},
"DATA": {
"bitrate": 8000000,
"time_segment_1": 7,
"time_segment_2": 2,
"sync_jump_width": 1
}
}
},
"canBusChannelIDs": [
0,
1,
2,
3
]
},
"LLSERVER": {
"sensor_state_sampling_rate": 10.0
},
"WEBSERVER": {
"ip": "127.0.0.1",
"port": 8080,
"state_transmission_rate": 10.0,
"timer_sync_rate": 10,
"sensors_smoothing_factor": 0.3
},
"INFLUXDB": {
"database_ip": "192.168.100.2",
"database_port": 8086,
"database_name": "gse",
"debug_measurement": "debug",
"state_measurement": "states",
"fast_sensor_measurement": "sensors",
"buffer_size": 2048,
"fast_sensor_buffer_size": 65536,
"enable_fast_sensor_logging": true
},
"THRUST": {
"alpha": 0.785398,
"beta": 0.785398,
"gamma": 0.785398,
"d": 0.28,
"r": 0.14
}
}
Loading