5 Node childNode = parentNode[tag];
8 RCLCPP_ERROR(rclcpp::get_logger(
"slam"), (
"Failed loading the map, no " + tag).c_str());
15 int track_size = track.size();
16 track.conservativeResize(track_size + N * 2);
17 for (const_iterator it = list.begin(); it != list.end(); ++it, track_size += 2) {
18 const Node& position = *it;
19 std::vector<double> vi = position[
"position"].as<std::vector<double>>();
20 track.segment(track_size, 2) << vi[0], vi[1];
24void load_initial_state(std::string mapPath, Eigen::Vector3d& start_pose, Eigen::VectorXd& track) {
25 Node map = LoadFile(mapPath);
35 std::vector<double> state_pose_vector = track_node[
"start"][
"pose"].as<std::vector<double>>();
36 if (state_pose_vector.size() != 3) {
37 RCLCPP_ERROR(rclcpp::get_logger(
"slam"),
"Start pose vector size is not 3!");
38 throw std::runtime_error(
"Start pose vector size is not 3!");
40 start_pose = Eigen::Vector3d(state_pose_vector.data());
48 std::string package_prefix = ament_index_cpp::get_package_prefix(
"slam");
49 std::string mapPath = package_prefix +
"/../../src/slam/maps/acceleration.yaml";
55 std::string package_prefix = ament_index_cpp::get_package_prefix(
"slam");
56 std::string mapPath = package_prefix +
"/../../src/slam/maps/skidpad.yaml";
62 double theta = start_pose(2);
63 Eigen::Vector2d translation = start_pose.head<2>();
66 Eigen::Matrix2d rotation_matrix;
67 rotation_matrix << cos(theta), -sin(theta), sin(theta), cos(theta);
68 Eigen::Matrix2d inverse_rotation = rotation_matrix.transpose();
70 for (
int i = 0; i < track.size(); i += 2) {
71 Eigen::Vector2d point(track[i], track[i + 1]);
74 point = inverse_rotation * (point - translation);
77 track[i + 1] = point[1];
79 start_pose = Eigen::Vector3d(0, 0, 0);
void load_initial_state(std::string mapPath, Eigen::Vector3d &start_pose, Eigen::VectorXd &track)
loads the map from the specified path and fills the start pose and track.
void load_acceleration_track(Eigen::Vector3d &start_pose, Eigen::VectorXd &track)
loads the acceleration track from the default path.
void transform_track(Eigen::VectorXd &track, Eigen::Vector3d &start_pose)
Transforms the track as seen from the start pose.
void add_landmarks(Eigen::VectorXd &track, const Node &list)
adds the landmarks in the list to the track.
void load_skidpad_track(Eigen::Vector3d &start_pose, Eigen::VectorXd &track)
loads the skidpad track from the default path.
Node get_child_node(Node parentNode, std::string tag)
Get the child node from a parent node by tag.