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

reset accelerations on setToDefaultValues #2618

Merged
merged 1 commit into from
Dec 19, 2023
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
1 change: 1 addition & 0 deletions moveit_core/robot_state/src/robot_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ void RobotState::setToDefaultValues()
robot_model_->getVariableDefaultPositions(position_); // mimic values are updated
// set velocity & acceleration to 0
std::fill(velocity_.begin(), velocity_.end(), 0);
std::fill(effort_or_acceleration_.begin(), effort_or_acceleration_.end(), 0);
std::fill(dirty_joint_transforms_.begin(), dirty_joint_transforms_.end(), 1);
dirty_link_transforms_ = robot_model_->getRootJoint();
}
Expand Down
28 changes: 28 additions & 0 deletions moveit_core/robot_state/test/robot_state_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,34 @@ class OneRobot : public testing::Test
moveit::core::RobotModelConstPtr robot_model_;
};

TEST_F(OneRobot, setToDefaultValues)
{
moveit::core::RobotState state(robot_model_);
state.setToDefaultValues();

// Get default values for joint_a.
double joint_a_default_position = state.getVariablePosition("joint_a");
double joint_a_default_velocity = state.getVariableVelocity("joint_a");
double joint_a_default_acceleration = state.getVariableAcceleration("joint_a");

// Set joint_a to some values.
state.setVariablePosition("joint_a", 1.0);
state.setVariableVelocity("joint_a", 2.0);
state.setVariableAcceleration("joint_a", 3.0);

// Check that joint_a has the right values.
EXPECT_EQ(state.getVariablePosition("joint_a"), 1.0);
EXPECT_EQ(state.getVariableVelocity("joint_a"), 2.0);
EXPECT_EQ(state.getVariableAcceleration("joint_a"), 3.0);

// Set to default values.
// Check that joint_a is back to the default values.
state.setToDefaultValues();
EXPECT_EQ(state.getVariablePosition("joint_a"), joint_a_default_position);
EXPECT_EQ(state.getVariableVelocity("joint_a"), joint_a_default_velocity);
EXPECT_EQ(state.getVariableAcceleration("joint_a"), joint_a_default_acceleration);
}

TEST_F(OneRobot, FK)
{
moveit::core::RobotModelConstPtr model = robot_model_;
Expand Down
Loading