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

Mavsdk update and use std::filesystem #12

Merged
merged 2 commits into from
Mar 6, 2024
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/rpi-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
apt-get update
apt-get install -y libgstreamer1.0-dev libgstrtspserver-1.0-dev build-essential cmake git wget rubygems
gem install fpm
wget https://github.com/mavlink/MAVSDK/releases/download/v2.2.0/libmavsdk-dev_2.2.0_debian11_arm64.deb
dpkg -i libmavsdk-dev_2.2.0_debian11_arm64.deb
rm libmavsdk-dev_2.2.0_debian11_arm64.deb
wget https://github.com/mavlink/MAVSDK/releases/download/v2.4.0/libmavsdk-dev_2.4.0_debian12_arm64.deb
dpkg -i libmavsdk-dev_2.4.0_debian12_arm64.deb
rm libmavsdk-dev_2.4.0_debian12_arm64.deb
git config --global --add safe.directory "$GITHUB_WORKSPACE"
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=install -Bbuild -S.
cmake --build build -j$(nproc) --target install
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ The camera manager is implemented using A small application on top of MAVSDK the
Download the latest MAVSDK release as a .deb. For Raspberry Pi 4 running a 64bit image, this is using the package for the `arm64` architecture:

```
wget https://github.com/mavlink/MAVSDK/releases/download/v2.0.1/libmavsdk-dev_2.0.1_debian11_arm64.deb
sudo dpkg -i libmavsdk-dev_2.0.1_debian11_arm64.deb
wget https://github.com/mavlink/MAVSDK/releases/download/v2.4.0/libmavsdk-dev_2.4.0_debian12_arm64.deb
sudo dpkg -i libmavsdk-dev_2.4.0_debian12_arm64.deb
```

### Build
Expand Down
17 changes: 2 additions & 15 deletions camera-manager/camera_manager.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
#include <iostream>
#include <chrono>
#include <thread>
#include <filesystem>
#include <mavsdk/mavsdk.h>
#include <mavsdk/plugins/camera_server/camera_server.h>
#include <mavsdk/plugins/ftp_server/ftp_server.h>
#include <mavsdk/plugins/param_server/param_server.h>
#include "siyi_protocol.hpp"
#include "siyi_camera.hpp"

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

bool is_dir(const std::string& path)
{
struct stat statbuf;
if (stat(path.c_str(), &statbuf) != 0) {
// Error getting information about the path
return false;
}
return (S_ISDIR(statbuf.st_mode) != 0);
}

int main(int argc, char* argv[])
{
if (argc != 4) {
Expand Down Expand Up @@ -71,7 +58,7 @@ int main(int argc, char* argv[])

// If running locally when built first, otherwise use system-wise:
std::string path = "./camera-manager/mavlink_ftp_root";
if (!is_dir(path)) {
if (!std::filesystem::exists(path)) {
path = "/usr/share/mavlink_ftp_root";
}

Expand Down
Loading