Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
285f9fa
reorganize function that runs the job
zrzz-hq Jun 12, 2025
4169aaf
move job running logic to uibase class, remove job.h
zrzz-hq Jun 12, 2025
67d3a7d
add ability to select which config file to load
zrzz-hq Jun 18, 2025
4c9d33c
change some function name to camel case
zrzz-hq Jun 29, 2025
76491ed
move onQuestion virtual function to UIBase class
zrzz-hq Jun 30, 2025
e5e15b3
start the backend at the begining of the program
zrzz-hq Jul 1, 2025
16d14fd
change return value type of the runAction function to return the summ…
zrzz-hq Jul 1, 2025
1d131cd
move create function and error report logic out of UIBase class
zrzz-hq Jul 1, 2025
8bf1a9c
UIBase class is no longer responsible for gathering report
zrzz-hq Jul 1, 2025
8a2b9da
remove the Action::Report class, change parameters of Action::OnFinish
zrzz-hq Jul 1, 2025
06960e6
add a Frontend class, move job handle logic to it
zrzz-hq Jul 1, 2025
4bd88e5
nextAction and nextTest now return shared pointer
zrzz-hq Jul 1, 2025
41817de
move Job, Test and Action to common.h
zrzz-hq Jul 1, 2025
b11db9a
rename ui.h -> frontend.h
zrzz-hq Jul 1, 2025
2a1f844
change function parameter for runAction in PluginBase
zrzz-hq Jul 1, 2025
72cd717
add a PseudoTest class for backend
zrzz-hq Jul 1, 2025
8fdb9c2
move runTest function to PluginBase, add SimplePlugin
zrzz-hq Jul 1, 2025
14a4777
add a Backend class
zrzz-hq Jul 1, 2025
4af3ecc
rename plugin.h->backend.h. Move Backend class to backend.h
zrzz-hq Jul 1, 2025
a36af36
Revert "rename plugin.h->backend.h. Move Backend class to backend.h"
zrzz-hq Jul 1, 2025
146e825
Revert "change function parameter for runAction in PluginBase"
zrzz-hq Jul 6, 2025
ef5cf83
Backend class now derives from rclcpp::executors::SingleThreadedExecutor
zrzz-hq Jul 7, 2025
ad5ac2d
remove redundant namespace declarations
zrzz-hq Jul 7, 2025
f74e95e
remove support for loading ui dynamically
zrzz-hq Jul 13, 2025
e695a5c
remove redundant depends in package.xml, set version to 1.0.0
zrzz-hq Jul 13, 2025
831e38a
use pluginlib to manage plugins
zrzz-hq Jul 14, 2025
1cb2b58
rewrite runAction function of Frontend class
zrzz-hq Jul 14, 2025
04fa31f
frontend is no longer holding args, quit if cannot parse cfg file
zrzz-hq Jul 26, 2025
c2f9fc3
enable async question ask
zrzz-hq Jul 26, 2025
d8461a8
Merge branch 'main' into mil_preflight_v1.0.0
zrzz-hq Oct 25, 2025
a48f063
Merge branch 'main' into mil_preflight_v1.0.0
zrzz-hq Nov 4, 2025
23d099c
Merge branch 'main' into mil_preflight_v1.0.0
zrzz-hq Nov 6, 2025
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
51 changes: 20 additions & 31 deletions src/mil_common/mil_preflight/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,41 @@ endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(subjugator_msgs REQUIRED)
find_package(Boost REQUIRED COMPONENTS thread chrono filesystem system)
find_package(ftxui REQUIRED)
find_package(pluginlib REQUIRED)

add_executable(${PROJECT_NAME} src/frontend.cpp)
add_library(${PROJECT_NAME}_lib SHARED src/frontend.cpp)
add_executable(${PROJECT_NAME} src/mil_preflight.cpp src/tui.cpp)
include_directories(include ${ftxui_SOURCE_DIR}/include ${Boost_INCLUDE_DIRS})

target_link_libraries(${PROJECT_NAME} Boost::system Boost::filesystem)
target_link_libraries(
${PROJECT_NAME}
${PROJECT_NAME}_lib
Boost::system
Boost::filesystem
ftxui::screen
ftxui::dom
ftxui::component)

add_executable(mil_preflight_backend src/backend.cpp)

ament_target_dependencies(mil_preflight_backend rclcpp std_msgs Boost)
ament_target_dependencies(mil_preflight_backend rclcpp Boost pluginlib)

install(TARGETS ${PROJECT_NAME} mil_preflight_backend
DESTINATION bin # Install to install/bin/
)

install(FILES cfg/config.json DESTINATION bin)

add_library(ftx_ui SHARED src/uis/ftxui/ui.cpp src/uis/ftxui/widgets.cpp)

target_link_libraries(
ftx_ui
PRIVATE ftxui::screen
PRIVATE ftxui::dom
PRIVATE ftxui::component Boost::thread Boost::chrono Boost::filesystem
Boost::system)

add_library(topic_plugin SHARED src/plugins/topic_plugin.cpp)

ament_target_dependencies(topic_plugin rclcpp Boost)

add_library(setup_plugin SHARED src/plugins/setup_plugin.cpp)

ament_target_dependencies(setup_plugin rclcpp Boost)

add_library(node_plugin SHARED src/plugins/node_plugin.cpp)

ament_target_dependencies(node_plugin rclcpp Boost)
install(
DIRECTORY cfg/
DESTINATION bin
FILES_MATCHING
PATTERN "*")

add_library(actuator_plugin SHARED src/plugins/actuator_plugin.cpp)
install(DIRECTORY include/ DESTINATION include)

ament_target_dependencies(actuator_plugin rclcpp subjugator_msgs Boost)
ament_export_include_directories(include)

install(TARGETS topic_plugin setup_plugin node_plugin actuator_plugin ftx_ui
LIBRARY DESTINATION lib)
install(TARGETS ${PROJECT_NAME}_lib LIBRARY DESTINATION lib)

ament_package()
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"actuators": {
"plugin": "actuator_plugin",
"plugin": "ActuatorPlugin",
"actions": {
"FLH Thruster": [
"/thruster_efforts",
Expand Down Expand Up @@ -45,7 +45,7 @@
}
},
"setup": {
"plugin": "setup_plugin",
"plugin": "SetupPlugin",
"actions": {
"O-rings": [
"Grease O-rings with Molykote 55 every time a pressure vessel is closed."
Expand All @@ -56,7 +56,7 @@
}
},
"nodes": {
"plugin": "node_plugin",
"plugin": "NodePlugin",
"actions": {
"/odom_estimator": [
"/odom_estimator"
Expand All @@ -79,7 +79,7 @@
}
},
"topics": {
"plugin": "topic_plugin",
"plugin": "TopicPlugin",
"actions": {
"/camera/front/right/image_raw": [
"/camera/front/right/image_raw"
Expand Down
48 changes: 48 additions & 0 deletions src/mil_common/mil_preflight/include/mil_preflight/common.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#pragma once

#include <future>
#include <memory>
#include <string>
#include <vector>

namespace mil_preflight
{
static constexpr char ETX = 0x03;
Expand All @@ -7,4 +14,45 @@ static constexpr char BEL = 0x07;
static constexpr char NCK = 0x15;
static constexpr char GS = 0x1D;
static constexpr char US = 0x1F;

class Action
{
public:
Action() {};
virtual ~Action() {};

virtual std::string const& getName() const = 0;
virtual std::vector<std::string> const& getParameters() const = 0;
virtual void onStart() = 0;
virtual void onFinish(bool success, std::string&& summery) = 0;
virtual std::shared_future<int> onQuestion(std::string&& question, std::vector<std::string>&& options) = 0;

std::vector<std::string> stdouts;
std::vector<std::string> stderrs;

private:
};

class Test
{
public:
Test() {};
virtual ~Test() {};

virtual std::string const& getName() const = 0;
virtual std::string const& getPlugin() const = 0;
virtual std::shared_ptr<Action> nextAction() = 0;
virtual void onFinish() = 0;
};

class Job
{
public:
Job() {};
~Job() {};

virtual std::shared_ptr<Test> nextTest() = 0;
virtual void onFinish() = 0;
};

} // namespace mil_preflight
42 changes: 42 additions & 0 deletions src/mil_common/mil_preflight/include/mil_preflight/frontend.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#pragma once

#include <filesystem>
#include <iostream>
#include <optional>

#include <boost/asio.hpp>
#include <boost/dll.hpp>
#include <boost/process.hpp>

#include "mil_preflight/common.h"

namespace mil_preflight
{

class Frontend
{
public:
Frontend();
~Frontend();

void runJob(std::shared_ptr<Job> job);
void runJobAsync(std::shared_ptr<Job> job);

private:
boost::filesystem::path bin_path_ = boost::process::search_path("mil_preflight_backend");

boost::asio::io_context work_context_;
boost::asio::executor_work_guard<boost::asio::io_context::executor_type> work_guard_;
std::thread work_thread_;

boost::process::ipstream child_out_;
boost::process::ipstream child_err_;
boost::process::opstream child_in_;

boost::process::child backend_;

void runTest(std::shared_ptr<Test> test);
void runAction(std::shared_ptr<Action> action);
};

} // namespace mil_preflight
Loading