20 CommandMap::iterator it = commands_.find(m);
21 if(it == commands_.end())
return false;
27 :
HandleLayerBase(name +
" Handle"), motor_(motor), variables_(storage), jsh_(name, &pos_, &vel_, &eff_), jph_(jsh_, &cmd_pos_), jvh_(jsh_, &cmd_vel_), jeh_(jsh_, &cmd_eff_), jh_(0), forward_command_(false),
28 filter_pos_(
"double"), filter_vel_(
"double"), filter_eff_(
"double"), options_(options), enable_limits_(true)
32 std::string p2d(
"rint(rad2deg(pos)*1000)"), v2d(
"rint(rad2deg(vel)*1000)"), e2d(
"rint(eff)");
33 std::string p2r(
"deg2rad(obj6064)/1000"), v2r(
"deg2rad(obj606C)/1000"), e2r(
"0");
36 const std::string reason(
"*_unit_factor parameters are not supported anymore, please migrate to conversion functions.");
38 throw std::invalid_argument(reason);
41 if(options.
hasMember(
"pos_to_device")) p2d = (
const std::string&) options[
"pos_to_device"];
42 if(options.
hasMember(
"pos_from_device")) p2r = (
const std::string&) options[
"pos_from_device"];
44 if(options.
hasMember(
"vel_to_device")) v2d = (
const std::string&) options[
"vel_to_device"];
45 if(options.
hasMember(
"vel_from_device")) v2r = (
const std::string&) options[
"vel_from_device"];
47 if(options.
hasMember(
"eff_to_device")) e2d = (
const std::string&) options[
"eff_to_device"];
48 if(options.
hasMember(
"eff_from_device")) e2r = (
const std::string&) options[
"eff_from_device"];
62 }
else if(
motor_->getMode() == m){
72 if(
motor_->getMode() != m){
75 if(!
motor_->enterModeAndWait(m)){
86 if(
motor_->getMode() == m){
94 template<
typename T>
void addLimitsHandle(std::vector<LimitsHandleBaseSharedPtr> &limits,
const T &t) {
146 if(current_state ==
Ready){
154 }
else if(jh == &
jvh_){
158 }
else if(jh == &
jeh_){
166 if(jh) status.
warn(
"unsupported mode active");
174 if(!filter.
configure(options[filter_name],joint_name +
"/" + filter_name)){
175 status.
error(
"could not configure " + filter_name+
" for " + joint_name);
206 for(std::vector<LimitsHandleBaseSharedPtr>::iterator it =
limits_.begin(); it !=
limits_.end(); ++it){
207 if(reset) (*it)->reset();
CanSwitchResult canSwitch(const canopen::MotorBase::OperationMode &m)
filters::FilterChain< double > filter_pos_
bool switchMode(const canopen::MotorBase::OperationMode &m)
std::string getName() const
const void warn(const std::string &r)
virtual void handleWrite(canopen::LayerStatus &status, const LayerState ¤t_state)
hardware_interface::JointHandle * addHandle(T &iface, hardware_interface::JointHandle *jh, const std::vector< MotorBase::OperationMode > &modes)
std::vector< LimitsHandleBaseSharedPtr > limits_
void enforceLimits(const ros::Duration &period, bool reset)
void addLimitsHandle(std::vector< LimitsHandleBaseSharedPtr > &limits, const T &t)
boost::scoped_ptr< UnitConverter > conv_vel_
static double * assignVariable(const std::string &name, double *ptr, const std::string &req)
boost::scoped_ptr< UnitConverter > conv_pos_
std::vector< canopen::MotorBase::OperationMode > getInterfaceModes(const std::string &interface)
XmlRpc::XmlRpcValue options_
void registerHandle(hardware_interface::JointStateInterface &iface)
filters::FilterChain< double > filter_vel_
hardware_interface::JointHandle jvh_
virtual void handleRead(canopen::LayerStatus &status, const LayerState ¤t_state)
canopen::MotorBaseSharedPtr motor_
HandleLayer(const std::string &name, const canopen::MotorBaseSharedPtr &motor, const canopen::ObjectStorageSharedPtr storage, XmlRpc::XmlRpcValue &options)
#define ROS_FATAL_STREAM(args)
LimitsHandle(const T &handle)
hardware_interface::JointHandle jph_
boost::scoped_ptr< UnitConverter > conv_target_eff_
boost::shared_ptr< LimitsHandleBase > LimitsHandleBaseSharedPtr
InterfaceMapping g_interface_mapping
boost::scoped_ptr< UnitConverter > conv_eff_
virtual void handleInit(canopen::LayerStatus &status)
boost::atomic< hardware_interface::JointHandle * > jh_
bool prepareFilters(canopen::LayerStatus &status)
bool hasMember(const std::string &name) const
boost::scoped_ptr< UnitConverter > conv_target_vel_
hardware_interface::JointHandle jeh_
boost::atomic< bool > forward_command_
bool update(const T &data_in, T &data_out)
hardware_interface::JointStateHandle jsh_
bool configure(std::string param_name, ros::NodeHandle node=ros::NodeHandle())
const void error(const std::string &r)
void enableLimits(bool enable)
boost::scoped_ptr< UnitConverter > conv_target_pos_
bool select(const canopen::MotorBase::OperationMode &m)
#define ROS_ERROR_STREAM(args)
double * getVariable(const std::string &n)
filters::FilterChain< double > filter_eff_
bool forwardForMode(const canopen::MotorBase::OperationMode &m)
bool prepareFilter(const std::string &joint_name, const std::string &filter_name, filters::FilterChain< double > &filter, XmlRpc::XmlRpcValue &options, canopen::LayerStatus &status)
ObjectVariables variables_
virtual void enforce(const ros::Duration &period)