Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
mocker_node.cpp
Go to the documentation of this file.
2
3#include <yaml-cpp/yaml.h>
4
5#include <filesystem>
6
8
9MockerNode::MockerNode() : rclcpp::Node("mocker_node") {
10 auto mocker_config_path =
11 common_lib::config_load::get_config_yaml_path("mocker_node", "global", "global_config");
12 auto mocker_config = YAML::LoadFile(mocker_config_path);
13
14 auto track_name = mocker_config["global"]["track_name"].as<std::string>();
15 auto sim = mocker_config["global"]["adapter"].as<std::string>();
16
17 std::string planning_gtruth_file = std::string(std::filesystem::current_path()) +
18 "/gtruths/tracks/" + sim + "/" + track_name + "/" +
19 track_name + "_gtruth.csv";
20 std::string se_gtruth_file = std::string(std::filesystem::current_path()) + "/gtruths/tracks/" +
21 sim + "/" + track_name + "/" + track_name + ".csv";
22
25
26 planning_publisher = this->create_publisher<custom_interfaces::msg::PathPointArray>(
27 "/path_planning/mock_path",
28 rclcpp::QoS(10).durability(RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL));
29 se_publisher = this->create_publisher<custom_interfaces::msg::ConeArray>(
30 "/state_estimation/mock_map",
31 rclcpp::QoS(10).durability(RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL));
32
33 planning_visualization_publisher = this->create_publisher<visualization_msgs::msg::Marker>(
34 "/path_planning/smoothed_mock_path", 10);
35
36 this->_map_frame_id_ = sim == "eufs" ? "base_footprint" : "map";
37
38 this->timer_ = this->create_wall_timer(std::chrono::milliseconds(100),
39 std::bind(&MockerNode::publish_data, this));
40}
41
std::string _map_frame_id_
rclcpp::Publisher< custom_interfaces::msg::ConeArray >::SharedPtr se_publisher
void publish_data()
publish the messages
rclcpp::TimerBase::SharedPtr timer_
custom_interfaces::msg::ConeArray gtruth_se
MockerNode()
Constructor for a new Mocker Node object.
rclcpp::Publisher< custom_interfaces::msg::PathPointArray >::SharedPtr planning_publisher
custom_interfaces::msg::PathPointArray gtruth_planning
rclcpp::Publisher< visualization_msgs::msg::Marker >::SharedPtr planning_visualization_publisher
Timer for the periodic publishing.
custom_interfaces::msg::ConeArray se_gtruth_fromfile(std::istream &in)
read state estimation ground truth information from stream and place it in an array of Cone objects
Definition mocks.cpp:45
std::istream & open_file_as_stream(const std::string &filename)
recieve path to a file and return it as an input stream
Definition mocks.cpp:81
custom_interfaces::msg::PathPointArray planning_gtruth_fromfile(std::istream &in)
read planning ground truth information from stream and place it in an array of PathPoint objects
Definition mocks.cpp:11
std::vector< common_lib::structures::PathPoint > path_point_array_from_ci_vector(const custom_interfaces::msg::PathPointArray &path_point_array)
Convert from custom interfaces PathPointArray to vector of common_lib PathPoints.
Definition interfaces.cpp:5
visualization_msgs::msg::Marker line_marker_from_structure_array(const std::vector< T > &structure_array, const std::string &name_space, const std::string &frame_id, const int id, const std::string &color="red", const std::string &shape="line", float scale=0.1f, int action=visualization_msgs::msg::Marker::MODIFY)
Converts a vector of cones to a marker array.
Definition marker.hpp:158
std::string get_config_yaml_path(const std::string &package_name, const std::string &dir, const std::string &filename)