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

Bug fix: RobotTrajectory append() (backport #1813) #1821

Merged
merged 4 commits into from
Dec 18, 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
2 changes: 1 addition & 1 deletion moveit_core/robot_trajectory/src/robot_trajectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ RobotTrajectory& RobotTrajectory::append(const RobotTrajectory& source, double d
std::next(source.duration_from_previous_.begin(), start_index),
std::next(source.duration_from_previous_.begin(), end_index));
if (duration_from_previous_.size() > index)
duration_from_previous_[index] += dt;
duration_from_previous_[index] = dt;

return *this;
}
Expand Down
21 changes: 21 additions & 0 deletions moveit_core/robot_trajectory/test/test_robot_trajectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,27 @@ TEST_F(RobotTrajectoryTestFixture, ChainEdits)
EXPECT_EQ(trajectory.getWayPointCount(), initial_trajectory->getWayPointCount() * 2 + 3);
}

TEST_F(RobotTrajectoryTestFixture, Append)
{
robot_trajectory::RobotTrajectoryPtr initial_trajectory;
initTestTrajectory(initial_trajectory);
EXPECT_EQ(initial_trajectory->getWayPointCount(), size_t(5));

// Append to the first
robot_trajectory::RobotTrajectoryPtr traj2;
initTestTrajectory(traj2);
EXPECT_EQ(traj2->getWayPointCount(), size_t(5));

// After append() we should have 10 waypoints, all with 0.1s duration
const double expected_duration = 0.1;
initial_trajectory->append(*traj2, expected_duration, 0, 5);
EXPECT_EQ(initial_trajectory->getWayPointCount(), size_t(10));

EXPECT_EQ(initial_trajectory->getWayPointDurationFromPrevious(4), expected_duration);
EXPECT_EQ(initial_trajectory->getWayPointDurationFromPrevious(5), expected_duration);
EXPECT_EQ(initial_trajectory->getWayPointDurationFromPrevious(6), expected_duration);
}

TEST_F(RobotTrajectoryTestFixture, RobotTrajectoryShallowCopy)
{
bool deepcopy = false;
Expand Down
Loading