Skip to content

Commit

Permalink
work
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrxyz committed Jan 6, 2025
1 parent 06dda9e commit 611c7df
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions src/mil_common/mil_tools/src/online_bagger_server.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include <mil_tools/fs/path.h>
#include <time.h>

#include <deque>
#include <filesystem>
#include <rclcpp>
#include <rosbag2_cpp/writer.hpp>
#include <unordered_map>

class OnlineBaggerServer : public rclcpp::Node
{
private:
int successful_subscriptions;
int total_subscriptions;
std::unordered_map<std::string, std::vector<std::string>> groups_;
// topic name to instances of messages received
std::unordered_map<std::string, std::vector<rclcpp::SerializedMessage>> messages_;
std::string bag_dir;

// Gets todays date as YYYY-mm-dd
std::string _today_date()
{
time_t now = time(0);
struct tm tstruct;
char buf[80];
tstruct = *localtime(&now);
strftime(buf, sizeof(buf), "%Y-%m-%d", &tstruct);
return std::string(buf);
}

void _get_params()
{
bag_dir = this->get_parameter_or<std::string>("~bag_dir",
mil_tools::fs::path::expanduser("~/bags") + "/" + _today_date());
if (!std::filesystem::exists(bag_dir))
{
std::filesystem::create_directories(bag_dir);
}
}

public:
OnlineBaggerServer() : Node("online_bagger_server"), successful_subscriptions(0)
{
if (total_subscriptions == 0)
{
RCLCPP_ERROR(this->get_logger(), "No subscriptions requested");
rclcpp::shutdown();
}
}

void add_subscription()

void callback

void prune()
{
}
};

int main(int argc, char *argv[])
{
rclcpp::init(argc, argv);
rclcpp::spin(std::make_shared<OnlineBaggerServer>());
rclcpp::shutdown();
return 0;
}

0 comments on commit 611c7df

Please sign in to comment.