added more flags to build and run script, clean up
This commit is contained in:
parent
3f73f85c66
commit
5b60f1b821
4 changed files with 31 additions and 70 deletions
|
@ -11,11 +11,19 @@ LOCAL_PROJECT_DIR="/home/niklas/ROS-Dynamic-Executor-Experiments"
|
|||
# --------------------------------------
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 <ros|edf|sem> <single|multi> <timed|direct> [time_in_seconds]"
|
||||
echo "Usage: $0 <ros|edf|sem> <single|multi> <timed|direct> [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 " <ros|edf|sem> : Scheduler type (ros, edf, sem)"
|
||||
echo " <single|multi> : Threading type (single, multi)"
|
||||
echo " <timed|direct> : Fusion type (timed, direct)"
|
||||
echo " <time_in_seconds> : 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 ""
|
||||
|
|
|
@ -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<std::string> 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<std_msgs::msg::String>(\
|
||||
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<std_msgs::msg::String>(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
|
||||
}
|
|
@ -1,12 +1,10 @@
|
|||
// full_topology.cpp
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <random>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
// the order here matters
|
||||
|
||||
#include "tracetools/utils.hpp"
|
||||
|
||||
#include "rclcpp/rclcpp.hpp"
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
#include "tracetools/utils.hpp"
|
||||
#include <rclcpp/rclcpp.hpp>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
rclcpp::init(argc, argv);
|
||||
auto node = std::make_shared<rclcpp::Node>("test_node");
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue