Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(autoware_trajectory): change interface of InterpolatedArray #9264

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int main()
Args(crossed.pose.position.x, crossed.pose.position.y),
Kwargs("label"_a = "Crossed on trajectory", "color"_a = "purple"));

trajectory->longitudinal_velocity_mps(*s, trajectory->length()) = 0.0;
trajectory->longitudinal_velocity_mps.range(s.value(), trajectory->length()).set(0.0);

std::vector<double> x;
std::vector<double> y;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class InterpolatedArray
}

public:
auto & operator=(const T & value)
void set(const T & value)
{
std::vector<double> & bases = parent_.bases_;
std::vector<T> & values = parent_.values_;
Expand Down Expand Up @@ -154,7 +154,7 @@ class InterpolatedArray

parent_.interpolator_->build(bases, values);

return *this;
// return *this;
}
};

Expand All @@ -164,7 +164,7 @@ class InterpolatedArray
* @param end End of the range.
* @return RangeSetter object.
*/
Segment operator()(double start, double end)
Segment range(double start, double end)
{
if (start < this->start() || end > this->end()) {
RCLCPP_WARN(
Expand Down
14 changes: 7 additions & 7 deletions common/autoware_trajectory/test/test_trajectory_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
{
double length = trajectory->length();

trajectory->longitudinal_velocity_mps(trajectory->length() / 3.0, trajectory->length()) = 10.0;

trajectory->longitudinal_velocity_mps.range(trajectory->length() / 3.0, trajectory->length())
.set(10.0);
auto point = trajectory->compute(length / 2.0);

EXPECT_LT(0, point.point.pose.position.x);
Expand All @@ -85,8 +85,9 @@
TEST_F(TrajectoryTest, manipulate_velocity)
{
trajectory->longitudinal_velocity_mps = 10.0;
trajectory->longitudinal_velocity_mps(trajectory->length() / 3, 2.0 * trajectory->length() / 3) =
5.0;
trajectory->longitudinal_velocity_mps
.range(trajectory->length() / 3, 2.0 * trajectory->length() / 3)
.set(5.0);
auto point1 = trajectory->compute(0.0);
auto point2 = trajectory->compute(trajectory->length() / 2.0);
auto point3 = trajectory->compute(trajectory->length());
Expand All @@ -105,16 +106,15 @@

TEST_F(TrajectoryTest, curvature)
{
double curv = trajectory->curvature(0.0);

Check warning on line 109 in common/autoware_trajectory/test/test_trajectory_container.cpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (curv)
EXPECT_LT(-1.0, curv);

Check warning on line 110 in common/autoware_trajectory/test/test_trajectory_container.cpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (curv)
EXPECT_LT(curv, 1.0);

Check warning on line 111 in common/autoware_trajectory/test/test_trajectory_container.cpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (curv)
}

TEST_F(TrajectoryTest, restore)
{
using autoware::trajectory::Trajectory; // NOLINT
trajectory->longitudinal_velocity_mps(4.0, trajectory->length()) = 5.0;

using autoware::trajectory::Trajectory;
trajectory->longitudinal_velocity_mps.range(4.0, trajectory->length()).set(5.0);
{
auto points = static_cast<Trajectory<geometry_msgs::msg::Point> &>(*trajectory).restore(0);
EXPECT_EQ(10, points.size());
Expand Down
Loading