diff --git a/build_run_copy.sh b/build_run_copy.sh index fceb04e..6a3003b 100755 --- a/build_run_copy.sh +++ b/build_run_copy.sh @@ -11,11 +11,19 @@ LOCAL_PROJECT_DIR="/home/niklas/ROS-Dynamic-Executor-Experiments" # -------------------------------------- usage() { - echo "Usage: $0 [time_in_seconds]" + echo "Usage: $0 [time_in_seconds] [no_rebuild]" + echo "Example: $0 ros multi timed 10" + echo "This script builds the full_topology package, runs a trace, and copies the results to a remote server." + echo "Parameters:" + echo " : Scheduler type (ros, edf, sem)" + echo " : Threading type (single, multi)" + echo " : Fusion type (timed, direct)" + echo " : Length of the trace (default: 10)" + echo " [no_rebuild] : Optional flag to skip rebuilding the package (true/false, default: false)" exit 1 } -if [[ $# -lt 3 ]]; then +if [[ $# -lt 4 ]]; then usage fi @@ -23,6 +31,7 @@ SCHEDULER_TYPE="$1" THREADING_TYPE="$2" FUSION_TYPE="$3" TRACE_LENGTH="${4:-10}" +NO_REBUILD="${5:-false}" # Determine defines based on parameters CMAKE_ARGS=() @@ -37,13 +46,18 @@ TRACE_NAME="${SCHEDULER_TYPE}_${THREADING_TYPE}_${FUSION_TYPE}_${TRACE_LENGTH}" cd "$LOCAL_PROJECT_DIR" -echo colcon build --packages-select full_topology --cmake-clean-cache --cmake-clean-first --cmake-args "${CMAKE_ARGS[@]}" -colcon build --packages-select full_topology --cmake-clean-cache --cmake-clean-first --cmake-args "${CMAKE_ARGS[@]}" +if [[ "$NO_REBUILD" != "true" ]]; then + echo "[INFO] Rebuilding full_topology package with CMake arguments: ${CMAKE_ARGS[*]}" + colcon build --packages-select full_topology --cmake-clean-cache --cmake-clean-first --cmake-args "${CMAKE_ARGS[@]}" +else + echo "[INFO] Skipping rebuild of full_topology package." +fi source install/setup.bash +echo "[INFO] Launching full_topology with trace length: ${TRACE_LENGTH} seconds" OUTPUT=$(taskset -c 2,3 ros2 launch full_topology trace_full_topology.launch.py "length:=${TRACE_LENGTH}") -#echo ${OUTPUT} +echo "[INFO] Done running full_topology." TRACE_ID=$(echo ${OUTPUT} | \ grep -oP '(?<=Writing tracing session to: /home/niklas/ROS-Dynamic-Executor-Experiments/analysis/tracing/)[^\s]+') @@ -57,13 +71,22 @@ NEW_TRACE_ID="${TRACE_NAME}${TIMESTAMP_SUFFIX}" TRACE_ORIG_PATH="${TRACING_BASE}/${TRACE_ID}" TRACE_NEW_PATH="${TRACING_BASE}/${NEW_TRACE_ID}" -ros2 trace-analysis convert "${TRACE_ORIG_PATH}/ust" +echo "[INFO] Converting trace" +ros2 trace-analysis convert "${TRACE_ORIG_PATH}/ust" 2>&1 \ + | grep -v "UserWarning: " \ + | grep -v "return extension.main" \ + | grep -v "converting trace directory" \ + | grep -v "output written to" if [[ -e "$TRACE_NEW_PATH" ]]; then rm -rf "$TRACE_NEW_PATH" fi +echo "[INFO] Renaming trace from '$TRACE_ORIG_PATH' to '$TRACE_NEW_PATH'" mv "$TRACE_ORIG_PATH" "$TRACE_NEW_PATH" -scp -r "$TRACE_NEW_PATH/" "$REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH/" +scp -qr "$TRACE_NEW_PATH/" "$REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH/" + +echo "$NEW_TRACE_ID" >> ./trace_ids.txt echo "[SUCCESS] Trace analysis '$NEW_TRACE_ID' complete and copied to remote server." +echo "" diff --git a/src/full_topology/src/Untitled-1 b/src/full_topology/src/Untitled-1 deleted file mode 100644 index 7311e7b..0000000 --- a/src/full_topology/src/Untitled-1 +++ /dev/null @@ -1,51 +0,0 @@ -// A generic single-input processing node with a fixed delay +/- jitter -#define DEFINE_MULTI_PROCESSING_NODE_CLASS(NAME) \ -class NAME : public rclcpp::Node\ -{\ -public:\ - NAME(std::string const &name,\ - std::vector const &input_topics,\ - std::string const &output_topic,\ - int delay_ms,\ - double jitter_ms = 0.0) \ - : Node(name)\ - {\ - for (auto &topic : input_topics)\ - {\ - auto sub = create_subscription(\ - topic, 10,\ - [this, name, delay_ms, jitter_ms](std_msgs::msg::String::SharedPtr msg) \ - {\ - /* simple fusion: log each arrival */\ - if (DEBUG)\ - {\ - RCLCPP_INFO(get_logger(), "%s fusing input: %s", name.c_str(), msg->data.c_str());\ - }\ -#ifndef USE_TIMER_IN_FUSION_NODES\ - // Simulate processing delay - std::this_thread::sleep_for(std::chrono::milliseconds(delay_ms)); - auto out = std_msgs::msg::String(); - out.data = msg->data + " -> " + name + std::string(" fused"); - if (DEBUG) { - RCLCPP_INFO(get_logger(), "%s publishes fused message", name.c_str()); - } - publisher_->publish(out); -#endif - }); - subscriptions_.emplace_back(sub); - } - publisher_ = create_publisher(output_topic, 10); - -#ifdef USE_TIMER_IN_FUSION_NODES - // Also publish fused result periodically - timer_ = create_wall_timer(50ms, [this, name, delay_ms]() - { - std::this_thread::sleep_for(std::chrono::milliseconds(delay_ms)); - auto out = std_msgs::msg::String(); - out.data = name + std::string(" fused"); - if (DEBUG) { - RCLCPP_INFO(get_logger(), "%s publishes fused message", name.c_str()); - } - publisher_->publish(out); }); -#endif - } \ No newline at end of file diff --git a/src/full_topology/src/full_topology.cpp b/src/full_topology/src/full_topology.cpp index d876462..dd1f88a 100644 --- a/src/full_topology/src/full_topology.cpp +++ b/src/full_topology/src/full_topology.cpp @@ -1,12 +1,10 @@ -// full_topology.cpp - #include #include #include #include #include #include -// the order here matters + #include "tracetools/utils.hpp" #include "rclcpp/rclcpp.hpp" diff --git a/src/full_topology/src/test.cpp b/src/full_topology/src/test.cpp deleted file mode 100644 index 1a3f3e9..0000000 --- a/src/full_topology/src/test.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "tracetools/utils.hpp" -#include - -int main(int argc, char** argv) { - rclcpp::init(argc, argv); - auto node = std::make_shared("test_node"); - rclcpp::shutdown(); - return 0; -} \ No newline at end of file