@@ -47,7 +47,6 @@ rclcpp::Logger getLogger()
47
47
{
48
48
return moveit::getLogger (" moveit.core.ruckig_filter_plugin" );
49
49
}
50
- inline constexpr double DEFAULT_JERK_BOUND = 300 ; // rad/s^3
51
50
} // namespace
52
51
53
52
bool RuckigFilterPlugin::initialize (rclcpp::Node::SharedPtr node, moveit::core::RobotModelConstPtr robot_model,
@@ -62,15 +61,25 @@ bool RuckigFilterPlugin::initialize(rclcpp::Node::SharedPtr node, moveit::core::
62
61
auto param_listener = online_signal_smoothing::ParamListener (node_);
63
62
params_ = param_listener.get_params ();
64
63
65
- // Ruckig needs the joint vel/accel/ jerk bounds.
64
+ // Ruckig needs the joint vel/accel bounds, jerk bounds are optional
66
65
getVelAccelJerkBounds ();
67
66
ruckig::InputParameter<ruckig::DynamicDOFs> ruckig_input (num_joints_);
68
67
ruckig_input.max_velocity = joint_velocity_bounds_;
69
68
ruckig_input.max_acceleration = joint_acceleration_bounds_;
70
- ruckig_input.max_jerk = joint_jerk_bounds_;
71
69
ruckig_input.current_position = std::vector<double >(num_joints_, 0.0 );
72
70
ruckig_input.current_velocity = std::vector<double >(num_joints_, 0.0 );
73
71
ruckig_input.current_acceleration = std::vector<double >(num_joints_, 0.0 );
72
+
73
+ // These quantities can be omitted if jerk limits are not applied
74
+ if (joint_jerk_bounds_)
75
+ {
76
+ ruckig_input.max_jerk = *joint_jerk_bounds_;
77
+ }
78
+ else
79
+ {
80
+ ruckig_input.max_jerk = std::vector<double >(num_joints_, 0.0 );
81
+ }
82
+
74
83
ruckig_input_ = ruckig_input;
75
84
76
85
ruckig_output_.emplace (ruckig::OutputParameter<ruckig::DynamicDOFs>(num_joints_));
@@ -83,14 +92,33 @@ bool RuckigFilterPlugin::initialize(rclcpp::Node::SharedPtr node, moveit::core::
83
92
bool RuckigFilterPlugin::doSmoothing (Eigen::VectorXd& positions, Eigen::VectorXd& velocities,
84
93
Eigen::VectorXd& accelerations)
85
94
{
86
- if (have_initial_ruckig_output_ && ruckig_input_ && ruckig_output_ )
95
+ if (have_initial_ruckig_output_)
87
96
{
88
- ruckig_output_->pass_to_input (*ruckig_input_);
97
+ if (joint_jerk_bounds_)
98
+ {
99
+ ruckig_output_->pass_to_input (*ruckig_input_);
100
+ }
101
+ else
102
+ {
103
+ ruckig_input_->current_position = ruckig_output_->new_position ;
104
+ ruckig_input_->current_velocity = ruckig_output_->new_velocity ;
105
+ }
106
+ }
107
+ else
108
+ {
109
+ // TODO
110
+ ;
89
111
}
90
112
91
113
// Update Ruckig target state
92
114
// This assumes stationary at the target (zero vel, zero accel)
93
115
ruckig_input_->target_position = std::vector<double >(positions.data (), positions.data () + positions.size ());
116
+ ruckig_input_->target_velocity = std::vector<double >(num_joints_, 0 );
117
+ ruckig_input_->target_acceleration = std::vector<double >(num_joints_, 0 );
118
+ if (!joint_jerk_bounds_)
119
+ {
120
+ ruckig_input_->current_acceleration = std::vector<double >(num_joints_, 0.0 );
121
+ }
94
122
95
123
// Call the Ruckig algorithm
96
124
ruckig::Result ruckig_result = ruckig_->update (*ruckig_input_, *ruckig_output_);
@@ -129,16 +157,21 @@ bool RuckigFilterPlugin::reset(const Eigen::VectorXd& positions, const Eigen::Ve
129
157
// Initialize Ruckig
130
158
ruckig_input_->current_position = std::vector<double >(positions.data (), positions.data () + positions.size ());
131
159
ruckig_input_->current_velocity = std::vector<double >(velocities.data (), velocities.data () + velocities.size ());
132
- ruckig_input_->current_acceleration =
133
- std::vector<double >(accelerations.data (), accelerations.data () + accelerations.size ());
160
+ if (joint_jerk_bounds_)
161
+ {
162
+ ruckig_input_->current_acceleration =
163
+ std::vector<double >(accelerations.data (), accelerations.data () + accelerations.size ());
164
+ }
134
165
135
166
have_initial_ruckig_output_ = false ;
136
167
return true ;
137
168
}
138
169
139
- void RuckigFilterPlugin::getVelAccelJerkBounds ()
170
+ bool RuckigFilterPlugin::getVelAccelJerkBounds ()
140
171
{
141
172
auto joint_model_group = robot_model_->getJointModelGroup (params_.planning_group_name );
173
+ bool have_all_jerk_bounds = true ;
174
+ std::vector<double > jerk_bounds;
142
175
for (const auto & joint : joint_model_group->getActiveJointModels ())
143
176
{
144
177
const auto & bound = joint->getVariableBounds (joint->getName ());
@@ -169,17 +202,26 @@ void RuckigFilterPlugin::getVelAccelJerkBounds()
169
202
if (bound.jerk_bounded_ )
170
203
{
171
204
// Assume symmetric limits
172
- joint_jerk_bounds_ .push_back (bound.max_jerk_ );
205
+ jerk_bounds .push_back (bound.max_jerk_ );
173
206
}
207
+ // else, joint_jerk_bounds_ will be a std::nullopt and Ruckig doesn't apply jerk limits
174
208
else
175
209
{
176
- RCLCPP_ERROR_STREAM (getLogger (), " WARNING: No joint jerk limit defined. A default jerk limit of "
177
- << DEFAULT_JERK_BOUND << " rad/s^3 has been applied." );
178
- joint_jerk_bounds_.push_back (DEFAULT_JERK_BOUND);
210
+ have_all_jerk_bounds = false ;
179
211
}
180
212
}
181
213
182
- assert (joint_jerk_bounds_.size () == num_joints_);
214
+ if (!have_all_jerk_bounds)
215
+ {
216
+ joint_jerk_bounds_ = std::nullopt;
217
+ RCLCPP_WARN (getLogger (), " No joint jerk limit was defined. The output from Ruckig will not be jerk-limited." );
218
+ }
219
+ else
220
+ {
221
+ joint_jerk_bounds_ = jerk_bounds;
222
+ }
223
+
224
+ return true ;
183
225
}
184
226
185
227
void RuckigFilterPlugin::printRuckigState ()
0 commit comments