STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
controller_main.cpp File Reference

Standalone C++ controller service. More...

#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <unistd.h>
#include <atomic>
#include <csignal>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <memory>
#include <sstream>
#include <string>
#include <thread>
#include <vector>
#include "config/Config.hpp"
#include "control/ControllerService.hpp"
#include "control/PWMTargets.hpp"
#include "control/RobustDDPController.hpp"
#include "control/StateMachine.hpp"
#include "net/DaqInterface.hpp"
Include dependency graph for controller_main.cpp:

Go to the source code of this file.

Functions

static std::string resolveConfigPath (const std::string &config_path, const std::string &path)
 Resolve path relative to config: paths like output/lut/... are relative to project root.
static void signalHandler (int)
static void handleControlClient (int client_fd, fsw::control::ControllerService *svc)
static void runControlServer (fsw::control::ControllerService *svc, uint16_t port)
int main (int argc, char *argv[])

Variables

static std::atomic< bool > g_running {true}
constexpr size_t kMaxControlClients = 64

Detailed Description

Standalone C++ controller service.

Reads config.toml for actuator board settings, initializes the RobustDDPController, and runs the control loop sending PWM commands to actuator boards over UDP.

Usage: ./controller_service [–config /path/to/config.toml] [–elodin-host HOST] [–elodin-port PORT] [–thrust N]

Default config path: ../../config/config.toml (relative to binary)

Definition in file controller_main.cpp.

Function Documentation

◆ handleControlClient()

void handleControlClient ( int client_fd,
fsw::control::ControllerService * svc )
static

◆ main()

◆ resolveConfigPath()

std::string resolveConfigPath ( const std::string & config_path,
const std::string & path )
static

Resolve path relative to config: paths like output/lut/... are relative to project root.

Definition at line 43 of file controller_main.cpp.

References path::empty(), and path::size().

Referenced by main().

◆ runControlServer()

void runControlServer ( fsw::control::ControllerService * svc,
uint16_t port )
static

Definition at line 127 of file controller_main.cpp.

References g_running, handleControlClient(), kMaxControlClients, port, and send().

Referenced by main().

◆ signalHandler()

void signalHandler ( int )
static

Definition at line 56 of file controller_main.cpp.

References g_running.

Variable Documentation

◆ g_running

std::atomic<bool> g_running {true}
static

Definition at line 54 of file controller_main.cpp.

Referenced by handleControlClient(), main(), runControlServer(), and signalHandler().

◆ kMaxControlClients

size_t kMaxControlClients = 64
constexpr

Definition at line 72 of file controller_main.cpp.

Referenced by runControlServer().