joint_limits_rosparam.h
Go to the documentation of this file.
00001 
00002 // Copyright (C) 2013, PAL Robotics S.L.
00003 //
00004 // Redistribution and use in source and binary forms, with or without
00005 // modification, are permitted provided that the following conditions are met:
00006 //   * Redistributions of source code must retain the above copyright notice,
00007 //     this list of conditions and the following disclaimer.
00008 //   * Redistributions in binary form must reproduce the above copyright
00009 //     notice, this list of conditions and the following disclaimer in the
00010 //     documentation and/or other materials provided with the distribution.
00011 //   * Neither the name of PAL Robotics S.L. nor the names of its
00012 //     contributors may be used to endorse or promote products derived from
00013 //     this software without specific prior written permission.
00014 //
00015 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00016 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00017 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00018 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00019 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00020 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00021 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00022 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00023 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00024 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00025 // POSSIBILITY OF SUCH DAMAGE.
00027 
00029 
00030 #ifndef JOINT_LIMITS_INTERFACE_JOINT_LIMITS_ROSPARAM_H
00031 #define JOINT_LIMITS_INTERFACE_JOINT_LIMITS_ROSPARAM_H
00032 
00033 #include <string>
00034 
00035 #include <ros/ros.h>
00036 #include <joint_limits_interface/joint_limits.h>
00037 
00038 namespace joint_limits_interface
00039 {
00040 
00075 inline bool getJointLimits(const std::string& joint_name, const ros::NodeHandle& nh, JointLimits& limits)
00076 {
00077   // Node handle scoped where the joint limits are defined
00078   ros::NodeHandle limits_nh;
00079   try
00080   {
00081     const std::string limits_namespace = "joint_limits/" + joint_name;
00082     if (!nh.hasParam(limits_namespace))
00083     {
00084       ROS_DEBUG_STREAM("No joint limits specification found for joint '" << joint_name <<
00085                        "' in the parameter server (namespace " << nh.getNamespace() + "/" + limits_namespace << ").");
00086       return false;
00087     }
00088     limits_nh = ros::NodeHandle(nh, limits_namespace);
00089   }
00090   catch(const ros::InvalidNameException& ex)
00091   {
00092     ROS_ERROR_STREAM(ex.what());
00093     return false;
00094   }
00095 
00096   // Position limits
00097   bool has_position_limits = false;
00098   if(limits_nh.getParam("has_position_limits", has_position_limits))
00099   {
00100     if (!has_position_limits) {limits.has_position_limits = false;}
00101     double min_pos, max_pos;
00102     if (has_position_limits && limits_nh.getParam("min_position", min_pos) && limits_nh.getParam("max_position", max_pos))
00103     {
00104       limits.has_position_limits = true;
00105       limits.min_position = min_pos;
00106       limits.max_position = max_pos;
00107     }
00108 
00109     bool angle_wraparound;
00110     if (!has_position_limits && limits_nh.getParam("angle_wraparound", angle_wraparound))
00111     {
00112       limits.angle_wraparound = angle_wraparound;
00113     }
00114   }
00115 
00116   // Velocity limits
00117   bool has_velocity_limits = false;
00118   if(limits_nh.getParam("has_velocity_limits", has_velocity_limits))
00119   {
00120     if (!has_velocity_limits) {limits.has_velocity_limits = false;}
00121     double max_vel;
00122     if (has_velocity_limits && limits_nh.getParam("max_velocity", max_vel))
00123     {
00124       limits.has_velocity_limits = true;
00125       limits.max_velocity = max_vel;
00126     }
00127   }
00128 
00129   // Acceleration limits
00130   bool has_acceleration_limits = false;
00131   if(limits_nh.getParam("has_acceleration_limits", has_acceleration_limits))
00132   {
00133     if (!has_acceleration_limits) {limits.has_acceleration_limits = false;}
00134     double max_acc;
00135     if (has_acceleration_limits && limits_nh.getParam("max_acceleration", max_acc))
00136     {
00137       limits.has_acceleration_limits = true;
00138       limits.max_acceleration = max_acc;
00139     }
00140   }
00141 
00142   // Jerk limits
00143   bool has_jerk_limits = false;
00144   if(limits_nh.getParam("has_jerk_limits", has_jerk_limits))
00145   {
00146     if (!has_jerk_limits) {limits.has_jerk_limits = false;}
00147     double max_jerk;
00148     if (has_jerk_limits && limits_nh.getParam("max_jerk", max_jerk))
00149     {
00150       limits.has_jerk_limits = true;
00151       limits.max_jerk = max_jerk;
00152     }
00153   }
00154 
00155   // Effort limits
00156   bool has_effort_limits = false;
00157   if(limits_nh.getParam("has_effort_limits", has_effort_limits))
00158   {
00159     if (!has_effort_limits) {limits.has_effort_limits = false;}
00160     double max_effort;
00161     if (has_effort_limits && limits_nh.getParam("max_effort", max_effort))
00162     {
00163       limits.has_effort_limits = true;
00164       limits.max_effort = max_effort;
00165     }
00166   }
00167 
00168   return true;
00169 }
00170 
00171 }
00172 
00173 #endif


joint_limits_interface
Author(s): Adolfo Rodriguez Tsouroukdissian
autogenerated on Sat Jun 8 2019 20:09:27