83 rclcpp::Node::SharedPtr node = std::make_shared<rclcpp::Node>(
"AccelerationFilterTest");
87 rclcpp::exceptions::ParameterUninitializedException);
89 node = std::make_shared<rclcpp::Node>(
"AccelerationFilterTest");
91 node->declare_parameter(
"update_period", 0.01);
94 EXPECT_FALSE(filter.
initialize(node, robot_model_, 3u));
101 Eigen::VectorXd acceleration_limits = 1.2 * Eigen::VectorXd::Ones(
PANDA_NUM_JOINTS);
102 setLimits(acceleration_limits);
110 rclcpp::Node::SharedPtr node = std::make_shared<rclcpp::Node>(
"AccelerationFilterTest");
112 const double update_period = 1.0;
113 node->declare_parameter<
double>(
"update_period", update_period);
114 Eigen::VectorXd acceleration_limits = 1.2 * Eigen::VectorXd::Ones(
PANDA_NUM_JOINTS);
115 setLimits(acceleration_limits);
120 Eigen::VectorXd position = Eigen::VectorXd::Zero(5);
121 Eigen::VectorXd velocity = Eigen::VectorXd::Zero(5);
122 Eigen::VectorXd acceleration = Eigen::VectorXd::Zero(5);
123 EXPECT_FALSE(filter.
doSmoothing(position, velocity, acceleration));
129 EXPECT_FALSE(filter.
doSmoothing(position, velocity, acceleration));
134 EXPECT_TRUE(filter.
doSmoothing(position, velocity, acceleration));
139 position.array() = 3.0;
140 EXPECT_TRUE(filter.
doSmoothing(position, velocity, acceleration));
141 EXPECT_TRUE((position.array() - update_period * update_period * acceleration_limits.array()).matrix().norm() < 1E-3);
144 position.array() = 0.9;
145 filter.
reset(position * 0, velocity * 0, acceleration * 0);
146 EXPECT_TRUE(filter.
doSmoothing(position, velocity, acceleration));
147 EXPECT_TRUE((position.array() - 0.9).matrix().norm() < 1E-3);
152 position.array() = 0.01;
153 Eigen::VectorXd expected_offset =
154 velocity.array() * update_period - update_period * update_period * acceleration_limits.array();
155 EXPECT_TRUE(filter.
doSmoothing(position, velocity, acceleration));
156 EXPECT_TRUE((velocity * update_period - expected_offset).norm() < 1E-3);
163 rclcpp::Node::SharedPtr node = std::make_shared<rclcpp::Node>(
"AccelerationFilterTest");
165 const double update_period = 0.1;
166 node->declare_parameter<
double>(
"update_period", update_period);
167 Eigen::VectorXd acceleration_limits = -1.0 * Eigen::VectorXd::Ones(
PANDA_NUM_JOINTS);
168 setLimits(acceleration_limits);
173 EXPECT_TRUE(filter.
reset(position, velocity, acceleration));
174 EXPECT_FALSE(filter.
doSmoothing(position, velocity, acceleration));
180 rclcpp::Node::SharedPtr node = std::make_shared<rclcpp::Node>(
"AccelerationFilterTest");
181 const double update_period = 0.1;
183 node->declare_parameter<
double>(
"update_period", update_period);
184 Eigen::VectorXd acceleration_limits = 1.2 * (1.0 + Eigen::VectorXd::Random(
PANDA_NUM_JOINTS).array());
185 setLimits(acceleration_limits);
188 for (
size_t iter = 0; iter < 64; ++iter)
190 acceleration_limits = 1.2 * (1.0 + Eigen::VectorXd::Random(
PANDA_NUM_JOINTS).array());
191 setLimits(acceleration_limits);
198 EXPECT_TRUE(filter.
doSmoothing(position, velocity, acceleration));
moveit::core::RobotModelPtr loadTestingRobotModel(const std::string &package_name, const std::string &urdf_relative_path, const std::string &srdf_relative_path)
Loads a robot model given a URDF and SRDF file in a package.