9 Commits
Author SHA1 Message Date
Oleg Kalachev 37f267ecc9 Change type hints of the most List arguments to Sequence in pyflix
These arguments are effectively immutable, so Sequence makes more sense - the user may use tuples in addition to lists.
2026-08-14 10:36:10 +03:00
Oleg Kalachev 3450932dce Add testing of simulation run 2026-08-14 09:56:04 +03:00
Oleg Kalachev 149c891cfc Put binaries into docs artifact only in master and dev branch of the upstream repo 2026-08-14 04:26:30 +03:00
Oleg Kalachev 0512f5ce68 Add sloc calculator to ci 2026-08-14 04:21:36 +03:00
Oleg Kalachev f12b239af9 Fix simulation run 2026-08-14 04:19:41 +03:00
Oleg Kalachev 0a377cfe6f Fix default windup value in pid
INFINITY makes much more sense, since otherwise i term would be ineffective at all by default
2026-08-14 03:06:34 +03:00
Oleg Kalachev fd8bf03cc7 Update all used actions
Some of them were deprecated.
2026-08-14 02:35:34 +03:00
Oleg Kalachev 3ea680605a Fix typo 2026-08-14 00:59:36 +03:00
Oleg Kalachev 5edac09473 Make arduino-cli commands more clear in Makefile
Move sketch name before other arguments.
2026-08-14 00:21:51 +03:00
8 changed files with 70 additions and 34 deletions
+16 -7
View File
@@ -13,7 +13,7 @@ jobs:
env:
ARDUINO_SKETCH_ALWAYS_EXPORT_BINARIES: 1
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Install Arduino CLI
run: curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/usr/local/bin sh
- name: Build firmware for ESP32
@@ -29,7 +29,7 @@ jobs:
- name: Build firmware for Flix2
run: make BOARD=esp32:esp32:esp32s3:FlashSize=4M,CDCOnBoot=cdc,PSRAM=opi EXTRA='--build-property "compiler.cpp.extra_flags=-DFLIX2" --output-dir=flix/build/esp32.esp32.flix2'
- name: Upload binaries
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: firmware-binary
path: flix/build
@@ -41,7 +41,7 @@ jobs:
build_macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Install Arduino CLI
run: brew install arduino-cli
- name: Build firmware
@@ -52,7 +52,7 @@ jobs:
build_windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Install Arduino CLI
run: choco install arduino-cli
- name: Install Make
@@ -73,7 +73,7 @@ jobs:
DEBIAN_FRONTEND=noninteractive apt-get install -y curl wget build-essential cmake g++ pkg-config gnupg2 lsb-release sudo
- name: Install Arduino CLI
run: curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/usr/local/bin sh
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Install Gazebo
run: |
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
@@ -84,7 +84,16 @@ jobs:
run: sudo apt-get install -y libsdl2-dev
- name: Build simulator
run: make build_simulator
- uses: actions/upload-artifact@v4
- name: Run simulator
env:
GAZEBO_MODEL_PATH: ${{ github.workspace }}/gazebo/models
GAZEBO_PLUGIN_PATH: ${{ github.workspace }}/gazebo/build
run: |
OUT=$(timeout -k 10s 120s gzserver --verbose gazebo/flix.world 2>&1 | tee /dev/stderr)
if echo "$OUT" | grep -Pq "\[Err\](?! \[RenderEngine)"; then
exit 1
fi
- uses: actions/upload-artifact@v7
with:
name: gazebo-plugin-binary
path: gazebo/build/*.so
@@ -96,7 +105,7 @@ jobs:
steps:
- name: Install Arduino CLI
run: brew install arduino-cli
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Clean up python binaries # Workaround for https://github.com/actions/setup-python/issues/577
run: |
rm -f /usr/local/bin/2to3*
+12 -6
View File
@@ -16,7 +16,7 @@ jobs:
markdownlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Install markdownlint
run: npm install -g markdownlint-cli2
- name: Run markdownlint
@@ -25,13 +25,16 @@ jobs:
build_book:
runs-on: ubuntu-latest
needs: markdownlint
env:
BINARIES: ${{ github.event_name == 'push' && (github.ref_name == 'master' || github.ref_name == 'dev') && github.repository == 'okalachev/flix' }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Install mdBook
run: cargo install mdbook --vers 0.4.43 --locked
- name: Build book
run: cd docs && mdbook build
- name: Wait for Build to complete
if: ${{ env.BINARIES }}
uses: lewagon/wait-on-check-action@v1.9.1
with:
ref: ${{ github.sha }}
@@ -39,6 +42,7 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 30
- name: Find firmware binaries
if: ${{ env.BINARIES }}
id: build_run
run: |
RUN_ID=$(gh api "repos/${{ github.repository }}/actions/workflows/build.yml/runs?head_sha=${{ github.sha }}&per_page=1" --jq '.workflow_runs[0].id')
@@ -46,7 +50,8 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download firmware binaries
uses: actions/download-artifact@v4
if: ${{ env.BINARIES }}
uses: actions/download-artifact@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
@@ -54,6 +59,7 @@ jobs:
name: firmware-binary
path: docs/build
- name: Create shortcuts for firmware binaries
if: ${{ env.BINARIES }}
working-directory: docs/build
run: |
for FQBN in esp32.esp32.*; do
@@ -64,12 +70,12 @@ jobs:
ln -s "$FQBN/flix.ino.bootloader.bin" "flix.$BOARD.bootloader.bin"
done
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
uses: actions/upload-pages-artifact@v5
with:
path: docs/build
deploy:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
if: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
concurrency:
group: "pages"
cancel-in-progress: true
@@ -81,4 +87,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v5
+24 -4
View File
@@ -10,7 +10,7 @@ jobs:
csv_to_ulog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Build csv_to_ulog
run: cd tools/csv_to_ulog && mkdir build && cd build && cmake .. && make
- name: Test csv_to_ulog
@@ -22,13 +22,13 @@ jobs:
pyflix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Install Python build tools
run: pip install build
- name: Build pyflix
run: python3 -m build tools
- name: Upload artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: pyflix
path: |
@@ -37,7 +37,7 @@ jobs:
python_tools:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Install Python dependencies
run: pip install -r tools/requirements.txt
- name: Test csv_to_mcap tool
@@ -46,3 +46,23 @@ jobs:
echo -e "t,x,y,z\n0,1,2,3\n1,4,5,6" > log.csv
./csv_to_mcap.py log.csv
test $(stat -c %s log.mcap) -eq 883
sloc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- run: sudo apt-get install -y cloc jq
- name: Print source lines of code
run: cloc --by-file-by-lang flix
- name: Checkout previous revision
uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
path: prev
- name: Annotate total source lines
run: |
SLOC_CURR=$(cloc flix --json | jq -r '.SUM.code')
SLOC_PREV=$(cloc prev/flix --json | jq -r '.SUM.code')
DIFF=$(printf '%+d' "$((SLOC_CURR - SLOC_PREV))")
echo "* Current SLOC: $SLOC_CURR" >> $GITHUB_STEP_SUMMARY
echo "* Previous SLOC: $SLOC_PREV" >> $GITHUB_STEP_SUMMARY
echo "* Diff: $DIFF" >> $GITHUB_STEP_SUMMARY
+4 -4
View File
@@ -4,10 +4,10 @@ PORT := $(strip $(wildcard /dev/serial/by-id/usb-Silicon_Labs_CP21* /dev/serial/
export ARDUINO_NETWORK_CONNECTION_TIMEOUT := 1h
build: .core .libs
arduino-cli compile --fqbn $(BOARD) --build-property "build.core_debug_level=1" flix $(EXTRA)
arduino-cli compile flix --fqbn $(BOARD) --build-property "build.core_debug_level=1" $(EXTRA)
upload: build
arduino-cli upload --fqbn $(BOARD) -p "$(PORT)" flix
arduino-cli upload flix --fqbn $(BOARD) -p "$(PORT)"
erase:
arduino-cli burn-bootloader --fqbn $(BOARD) -p "$(PORT)" -P esptool
@@ -27,8 +27,8 @@ libs .libs:
touch .libs
upload_proxy: .core .libs
arduino-cli compile --fqbn $(BOARD) tools/espnow-proxy
arduino-cli upload --fqbn $(BOARD) -p "$(PORT)" tools/espnow-proxy
arduino-cli compile tools/espnow-proxy --fqbn $(BOARD)
arduino-cli upload tools/espnow-proxy --fqbn $(BOARD) -p "$(PORT)"
gazebo/build cmake: gazebo/CMakeLists.txt
mkdir -p gazebo/build
+4 -4
View File
@@ -22,7 +22,7 @@ struct Parameter {
const char *name; // max length is 15
bool integer;
union { float *f; int *i; }; // pointer to the variable
float inital; // default value
float initial; // default value
float cache; // what's stored in flash
void (*callback)(); // called after parameter change
Parameter(const char *name, float *variable, void (*callback)() = nullptr) : name(name), integer(false), f(variable), callback(callback) {};
@@ -150,7 +150,7 @@ void setupParameters() {
storage.begin("flix");
// Read parameters from storage
for (auto &parameter : parameters) {
parameter.inital = parameter.getValue();
parameter.initial = parameter.getValue();
if (storage.isKey(parameter.name)) {
parameter.setValue(storage.getFloat(parameter.name));
}
@@ -211,10 +211,10 @@ void printParameters(const char *filter) {
for (auto &parameter : parameters) {
if (strncasecmp(parameter.name, filter, strlen(filter))) continue;
if (floatEquals(parameter.getValue(), parameter.inital)) { // parameter changed
if (floatEquals(parameter.getValue(), parameter.initial)) { // parameter changed
print("%-15s %-13g\n", parameter.name, parameter.getValue());
} else {
print("%-15s %-13g [%g]\n", parameter.name, parameter.getValue(), parameter.inital);
print("%-15s %-13g [%g]\n", parameter.name, parameter.getValue(), parameter.initial);
}
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ public:
LowPassFilter<float> lpf; // low pass filter for derivative term
PID(float p, float i = 0, float d = 0, float windup = 0, float dAlpha = 1, float dtMax = 0.1) :
PID(float p, float i = 0, float d = 0, float windup = INFINITY, float dAlpha = 1, float dtMax = 0.1) :
p(p), i(i), d(d), windup(windup), lpf(dAlpha), dtMax(dtMax) {}
float update(float error) {
+1
View File
@@ -14,6 +14,7 @@
// Mocks
int wifiMode = 1;
int wifiLongRange = 0;
int wifiBroadcast = 0;
int espnowChannel = 6;
const int W_DISABLED = 0, W_AP = 1, W_STA = 2, W_ESPNOW = 3;
+8 -8
View File
@@ -243,7 +243,7 @@ class Flix:
time.sleep(1)
@staticmethod
def _mavlink_to_flu(v: List[float]) -> List[float]:
def _mavlink_to_flu(v: Sequence[float]) -> List[float]:
if len(v) == 3: # vector
return [v[0], -v[1], -v[2]]
elif len(v) == 4: # quaternion
@@ -252,8 +252,8 @@ class Flix:
raise ValueError(f'List must have 3 (vector) or 4 (quaternion) elements')
@staticmethod
def _flu_to_mavlink(v: List[float]) -> List[float]:
return Flix._mavlink_to_flu(v)
def _flu_to_mavlink(v: Sequence[float]) -> List[float]:
return Flix._mavlink_to_flu(v) # flu to mavlink is the same as mavlink to flu
def _command_send(self, command: int, params: Sequence[float]):
if len(params) != 7:
@@ -320,13 +320,13 @@ class Flix:
def set_armed(self, armed: bool):
self._command_send(mavlink.MAV_CMD_COMPONENT_ARM_DISARM, (1 if armed else 0, 0, 0, 0, 0, 0, 0))
def set_position(self, position: List[float], yaw: Optional[float] = None, wait: bool = False, tolerance: float = 0.1):
def set_position(self, position: Sequence[float], yaw: Optional[float] = None, wait: bool = False, tolerance: float = 0.1):
raise NotImplementedError('Position control is not implemented yet')
def set_velocity(self, velocity: List[float], yaw: Optional[float] = None):
def set_velocity(self, velocity: Sequence[float], yaw: Optional[float] = None):
raise NotImplementedError('Velocity control is not implemented yet')
def set_attitude(self, attitude: List[float], thrust: float):
def set_attitude(self, attitude: Sequence[float], thrust: float):
if len(attitude) == 3:
attitude = Quaternion([attitude[0], attitude[1], attitude[2]]).q # type: ignore
elif len(attitude) != 4:
@@ -339,7 +339,7 @@ class Flix:
[attitude[0], attitude[1], attitude[2], attitude[3]],
0, 0, 0, thrust)
def set_rates(self, rates: List[float], thrust: float):
def set_rates(self, rates: Sequence[float], thrust: float):
if len(rates) != 3:
raise ValueError('Rates must be [roll_rate, pitch_rate, yaw_rate]')
if not (0 <= thrust <= 1):
@@ -351,7 +351,7 @@ class Flix:
[1, 0, 0, 0],
rates[0], rates[1], rates[2], thrust)
def set_motors(self, motors: List[float]):
def set_motors(self, motors: Sequence[float]):
if len(motors) != 4:
raise ValueError('motors must have 4 values')
if not all(0 <= m <= 1 for m in motors):