35 interp_type_(ZERO_ORDER_HOLD)
41 if (
x_.size() == 0 || x >
x_.back()) {
49 "X values must be increasing. (%f <= %f)",
62 if (index <
x_.size()) {
63 return std::pair<double, double>(
x_[index],
y_[index]);
65 ROS_ERROR(
"Invalid index in getPoint (index=%zu, numPoints=%zu)",
67 return std::pair<double, double>(0.0, 0.0);
73 if (index <
x_.size()) {
74 x_.erase(
x_.begin()+index);
75 y_.erase(
y_.begin()+index);
77 ROS_ERROR(
"Invalid index in removePoint (index=%zu, numPoints=%zu)",
96 return "zero_order_hold";
111 const std::string ¶m_name,
112 bool error_if_missing)
114 std::string resolved_name = node_handle.
resolveName(param_name);
117 if (node_handle.
getParam(param_name, curve_param)) {
120 if (error_if_missing) {
121 ROS_ERROR(
"Missing required parameter at '%s'.", resolved_name.c_str());
131 const std::string ¶m_name)
134 ROS_ERROR(
"Parameter '%s' must be a structure.", param_name.c_str());
138 bool error_occurred =
false;
140 if (curve_param.
hasMember(
"interpolation_type")) {
141 std::string interp_type =
static_cast<std::string
>(curve_param[
"interpolation_type"]);
143 if (interp_type ==
"zero_order_hold") {
145 }
else if (interp_type ==
"linear") {
148 error_occurred =
true;
149 ROS_ERROR(
"Invalid interpolation type '%s' at '%s'.",
150 interp_type.c_str(), param_name.c_str());
153 ROS_INFO(
"No 'interpolation_type' found in %s. " 154 "Defaulting to zero_order_hold.",
160 ROS_INFO(
"Missing required parameter '%s/values'.",
168 ROS_ERROR(
"Parameter '%s/values' must be an array.", param_name.c_str());
172 for (
int i = 0; i < param_value.
size(); i++)
178 ROS_ERROR(
"Parameter '%s/values[%d]' must be an array.",
179 param_name.c_str(), i);
180 error_occurred =
true;
184 if (point_value.
size() != 2) {
185 ROS_ERROR(
"Parameter '%s/values[%d]' must be 2 elements.",
186 param_name.c_str(), i);
187 error_occurred =
true;
193 double x_value = std::numeric_limits<double>::quiet_NaN();
194 double y_value = std::numeric_limits<double>::quiet_NaN();
199 ROS_ERROR(
"Parameters '%s/values[%d][0] must be a double or an integer.",
200 param_name.c_str(), i);
201 error_occurred =
true;
203 x_value =
static_cast<double>(x_param);
209 ROS_ERROR(
"Parameters '%s/values[%d][1] must be a double or an integer.",
210 param_name.c_str(), i);
211 error_occurred =
true;
213 y_value =
static_cast<double>(y_param);
216 if (!error_occurred) {
218 ROS_ERROR(
"Failed to add point %s/values[%d].",
219 param_name.c_str(), i);
220 error_occurred =
true;
225 if (error_occurred) {
235 if (
x_.size() == 0) {
244 if (
x_.size() == 0) {
bool appendPoint(double x, double y)
std::string interpolationTypeString() const
void setInterpolationType(InterpolationType type)
Type const & getType() const
InterpolationType interp_type_
bool getParam(const std::string &key, std::string &s) const
std::string resolveName(const std::string &name, bool remap=true) const
std::pair< double, double > getPoint(size_t index) const
void removePoint(size_t index)
bool readFromParameter(const ros::NodeHandle &node_handle, const std::string ¶m_name, bool error_if_missing)
bool hasMember(const std::string &name) const
InterpolationType interpolationType()