19 int main(
int argc,
char **argv)
22 ros::init(argc, argv,
"netft_utils_node");
34 std::string world_frame;
36 double forceMaxU = 0.0;
37 double torqueMaxU = 0.0;
40 ROS_FATAL(
"You must pass in at least the world and ft frame as command line arguments. Argument options are [world frame, ft frame, max force, max torque]");
45 ROS_FATAL(
"Too many arguments for netft_utils");
49 world_frame = argv[1];
52 forceMaxU = atof(argv[3]);
54 torqueMaxU = atof(argv[4]);
56 utils.
setUserInput(world_frame, ft_frame, forceMaxU, torqueMaxU);
80 isGravityBiased(false),
82 isNewGravityBias(false),
83 cancel_count(MAX_CANCEL),
84 cancel_wait(MAX_WAIT),
189 out.header.stamp = in.header.stamp;
190 out.header.frame_id = in.header.frame_id;
191 out.wrench.force.x = in.wrench.force.x - bias.wrench.force.x;
192 out.wrench.force.y = in.wrench.force.y - bias.wrench.force.y;
193 out.wrench.force.z = in.wrench.force.z - bias.wrench.force.z;
194 out.wrench.torque.x = in.wrench.torque.x - bias.wrench.torque.x;
195 out.wrench.torque.y = in.wrench.torque.y - bias.wrench.torque.y;
196 out.wrench.torque.z = in.wrench.torque.z - bias.wrench.torque.z;
201 if(value <= thresh && value >= -thresh)
211 tempF.
setX(in_data.wrench.force.x);
212 tempF.
setY(in_data.wrench.force.y);
213 tempF.
setZ(in_data.wrench.force.z);
214 tempT.
setX(in_data.wrench.torque.x);
215 tempT.
setY(in_data.wrench.torque.y);
216 tempT.
setZ(in_data.wrench.torque.z);
217 if(target_frame ==
'w')
223 else if(target_frame ==
't')
225 out_data.header.frame_id =
ft_frame;
229 out_data.header.stamp = in_data.header.stamp;
230 out_data.wrench.force.
x = tempF.
getX();
231 out_data.wrench.force.y = tempF.
getY();
232 out_data.wrench.force.z = tempF.
getZ();
233 out_data.wrench.torque.x = tempT.
getX();
234 out_data.wrench.torque.y = tempT.
getY();
235 out_data.wrench.torque.z = tempT.
getZ();
242 std::vector<double> tempData;
244 tempData.at(0) = -data->wrench.force.x;
245 tempData.at(1) = data->wrench.force.y;
246 tempData.at(2) = data->wrench.force.z;
247 tempData.at(3) = -data->wrench.torque.x;
248 tempData.at(4) = data->wrench.torque.y;
249 tempData.at(5) = data->wrench.torque.z;
290 geometry_msgs::WrenchStamped world_bias;
327 if(req.forceMax >= 0.0001)
329 if(req.torqueMax >= 0.0001)
356 ROS_ERROR(
"Cannot compensate for gravity if the sensor has already been biased, i.e. useful data was wiped out");
398 if(req.forceMax >= 0.0001)
400 if(req.torqueMax >= 0.0001)
424 geometry_msgs::WrenchStamped carried_weight;
426 res.weight = pow((pow(carried_weight.wrench.force.x, 2.0) + pow(carried_weight.wrench.force.y, 2.0) + pow(carried_weight.wrench.force.z, 2.0)), 0.5)/9.81*1000;
433 threshold.wrench.force.x = req.data.wrench.force.x;
434 threshold.wrench.force.y = req.data.wrench.force.y;
435 threshold.wrench.force.z = req.data.wrench.force.z;
436 threshold.wrench.torque.x = req.data.wrench.torque.x;
437 threshold.wrench.torque.y = req.data.wrench.torque.y;
438 threshold.wrench.torque.z = req.data.wrench.torque.z;
469 if((fabs(fMag) > fMax || fabs(tMag) > tMax) &&
cancel_count > 0)
483 else if(
cancel_wait == 0 || !(fabs(fMag) > fMax || fabs(tMag) > tMax))
geometry_msgs::WrenchStamped tf_data_world
ros::ServiceServer set_max_service
NetftUtils(ros::NodeHandle nh)
void publish(const boost::shared_ptr< M > &message) const
TFSIMD_FORCE_INLINE void setX(tfScalar x)
bool update(std::vector< double > input, std::vector< double > &output)
TFSIMD_FORCE_INLINE void setY(tfScalar y)
bool setThreshold(netft_utils::SetThreshold::Request &req, netft_utils::SetThreshold::Response &res)
ros::Publisher netft_cancel_pub
geometry_msgs::WrenchStamped raw_data_tool
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
TFSIMD_FORCE_INLINE void setZ(tfScalar z)
void transformFrame(geometry_msgs::WrenchStamped in_data, geometry_msgs::WrenchStamped &out_data, char target_frame)
int main(int argc, char **argv)
bool fixedOrientationBias(netft_utils::SetBias::Request &req, netft_utils::SetBias::Response &res)
TFSIMD_FORCE_INLINE const tfScalar & getY() const
ros::Publisher netft_tool_data_pub
geometry_msgs::WrenchStamped threshold
tf::TransformListener * listener
bool setFilter(netft_utils::SetFilter::Request &req, netft_utils::SetFilter::Response &res)
ros::ServiceServer gravity_comp_service
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
geometry_msgs::WrenchStamped zero_wrench
TFSIMD_FORCE_INLINE const tfScalar & getZ() const
ros::Publisher netft_world_data_pub
void applyThreshold(double &value, double thresh)
TFSIMD_FORCE_INLINE const tfScalar & x() const
geometry_msgs::WrenchStamped tf_data_tool
ros::Publisher netft_raw_world_data_pub
bool getWeight(netft_utils::GetDouble::Request &req, netft_utils::GetDouble::Response &res)
void netftCallback(const geometry_msgs::WrenchStamped::ConstPtr &data)
ros::ServiceServer bias_service
ros::ServiceServer theshold_service
bool setMax(netft_utils::SetMax::Request &req, netft_utils::SetMax::Response &res)
bool compensateForGravity(netft_utils::SetBias::Request &req, netft_utils::SetBias::Response &res)
ros::Subscriber raw_data_sub
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
geometry_msgs::WrenchStamped weight_bias
static const int MAX_CANCEL
ros::ServiceServer weight_bias_service
ros::ServiceServer filter_service
geometry_msgs::WrenchStamped raw_data_world
void copyWrench(geometry_msgs::WrenchStamped &in, geometry_msgs::WrenchStamped &out, geometry_msgs::WrenchStamped &bias)
void setUserInput(std::string world, std::string ft, double force, double torque)
static const int MAX_WAIT
TFSIMD_FORCE_INLINE const tfScalar & getX() const
ros::ServiceServer get_weight_service
tf::StampedTransform ft_to_world
ROSCPP_DECL void spinOnce()
geometry_msgs::WrenchStamped bias
netft_utils::Cancel cancel_msg
bool setWeightBias(netft_utils::SetBias::Request &req, netft_utils::SetBias::Response &res)