Skip to content

Commit

Permalink
updated tests, fixed path preinitialization's heading
Browse files Browse the repository at this point in the history
  • Loading branch information
klaxalk committed Jul 12, 2024
1 parent fb8dec5 commit 459ea3d
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/mrs_trajectory_generation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,13 @@ std::tuple<std::optional<mrs_msgs::TrackerCommand>, bool, int> MrsTrajectoryGene

initial_condition.position = uav_state->pose.position;

try {
initial_condition.heading = mrs_lib::AttitudeConverter(uav_state->pose.orientation).getHeading();
}
catch (...) {
ROS_WARN_THROTTLE(1.0, "[MrsTrajectoryGeneration]: could not obtain heading from the UAV State");
}

initial_condition.position.z += _takeoff_height_;

initial_condition.header = uav_state->header;
Expand Down
7 changes: 7 additions & 0 deletions test/get_path_before_takeoff/config/custom_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mrs_uav_managers:

uav_manager:

takeoff:

takeoff_height: 3.0
1 change: 1 addition & 0 deletions test/get_path_before_takeoff/get_path_before_takeoff.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<include file="$(find mrs_uav_testing)/launch/mrs_uav_system.launch">
<arg name="automatic_start" default="true" />
<arg name="platform_config" default="$(find mrs_multirotor_simulator)/config/mrs_uav_system/$(arg UAV_TYPE).yaml" />
<arg name="custom_config" default="$(dirname)/config/custom_config.yaml" />
<arg name="UAV_NAME" default="$(arg UAV_NAME)" />
</include>

Expand Down
16 changes: 16 additions & 0 deletions test/get_path_before_takeoff/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@ bool Tester::test() {
}
}

// | ---------- add the first waypoint after takeoff ---------- |

{
auto uav_pos = uh_->sh_uav_state_.getMsg()->pose.position;

double heading = mrs_lib::AttitudeConverter(uh_->sh_uav_state_.getMsg()->pose.orientation).getHeading();

mrs_msgs::Reference reference;
reference.position.x = uav_pos.x;
reference.position.y = uav_pos.y;
reference.position.z = uav_pos.z + 3.0;
reference.heading = heading;

path.points.insert(path.points.begin(), reference);
}

// | ------------------ check the trajectory ------------------ |

{
Expand Down
7 changes: 7 additions & 0 deletions test/path_before_takeoff/config/custom_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mrs_uav_managers:

uav_manager:

takeoff:

takeoff_height: 3.0
1 change: 1 addition & 0 deletions test/path_before_takeoff/path_before_takeoff.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<include file="$(find mrs_uav_testing)/launch/mrs_uav_system.launch">
<arg name="automatic_start" default="true" />
<arg name="platform_config" default="$(find mrs_multirotor_simulator)/config/mrs_uav_system/$(arg UAV_TYPE).yaml" />
<arg name="custom_config" default="$(dirname)/config/custom_config.yaml" />
<arg name="UAV_NAME" default="$(arg UAV_NAME)" />
</include>

Expand Down
16 changes: 16 additions & 0 deletions test/path_before_takeoff/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ bool Tester::test() {
}
}

// | ---------- add the first waypoint after takeoff ---------- |

{
auto uav_pos = uh_->sh_uav_state_.getMsg()->pose.position;

double heading = mrs_lib::AttitudeConverter(uh_->sh_uav_state_.getMsg()->pose.orientation).getHeading();

mrs_msgs::Reference reference;
reference.position.x = uav_pos.x;
reference.position.y = uav_pos.y;
reference.position.z = uav_pos.z + 3.0;
reference.heading = heading;

path.points.insert(path.points.begin(), reference);
}

// | ------------------------- takeoff ------------------------ |

{
Expand Down

0 comments on commit 459ea3d

Please sign in to comment.