Go to the documentation of this file.00001 #include <carl_safety/arm_safety.h>
00002
00003 using namespace std;
00004
00005 arm_safety::arm_safety()
00006 {
00007
00008 ros::NodeHandle private_nh("~");
00009 private_nh.param<bool>("enable_audible_warnings", enable_audible_warnings, false);
00010
00011
00012 joint_sub = node.subscribe<sensor_msgs::JointState>("/jaco_arm/joint_states", 10, &arm_safety::joints_cback, this);
00013 }
00014
00015 void arm_safety::joints_cback(const sensor_msgs::JointState::ConstPtr& joints)
00016 {
00017 bool shouldSpeak = false;
00018
00019 if(abs(joints->effort[0])>J1_THRESHOLD){
00020 ROS_ERROR("Torque on jaco_joint_1 outside threshold (+/-%f Nm) with value %f", J1_THRESHOLD, joints->effort[0]);
00021 shouldSpeak = true;
00022 }
00023 if(abs(joints->effort[1])>J2_THRESHOLD){
00024 ROS_ERROR("Torque on jaco_joint_2 outside threshold (+/-%f Nm) with value %f", J2_THRESHOLD, joints->effort[1]);
00025 shouldSpeak = true;
00026 }
00027 if(abs(joints->effort[2])>J3_THRESHOLD){
00028 ROS_ERROR("Torque on jaco_joint_3 outside threshold (+/-%f Nm) with value %f", J3_THRESHOLD, joints->effort[2]);
00029 shouldSpeak = true;
00030 }
00031 if(abs(joints->effort[3])>J4_THRESHOLD){
00032 ROS_ERROR("Torque on jaco_joint_4 outside threshold (+/-%f Nm) with value %f", J4_THRESHOLD, joints->effort[3]);
00033 shouldSpeak = true;
00034 }
00035 if(abs(joints->effort[4])>J5_THRESHOLD){
00036 ROS_ERROR("Torque on jaco_joint_5 outside threshold (+/-%f Nm) with value %f", J5_THRESHOLD, joints->effort[4]);
00037 shouldSpeak = true;
00038 }
00039 if(abs(joints->effort[5])>J6_THRESHOLD){
00040 ROS_ERROR("Torque on jaco_joint_6 outside threshold (+/-%f Nm) with value %f", J6_THRESHOLD, joints->effort[5]);
00041 shouldSpeak = true;
00042 }
00043 if(abs(joints->effort[6])>F1_THRESHOLD){
00044 ROS_ERROR("Torque on jaco_finger_joint_1 outside threshold (+/-%f Nm) with value %f", F1_THRESHOLD, joints->effort[6]);
00045 shouldSpeak = true;
00046 }
00047 if(abs(joints->effort[7])>F2_THRESHOLD){
00048 ROS_ERROR("Torque on jaco_finger_joint_2 outside threshold (+/-%f Nm) with value %f", F2_THRESHOLD, joints->effort[7]);
00049 shouldSpeak = true;
00050 }
00051 if(abs(joints->effort[8])>F3_THRESHOLD){
00052 ROS_ERROR("Torque on jaco_finger_joint_3 outside threshold (+/-%f Nm) with value %f", F3_THRESHOLD, joints->effort[8]);
00053 shouldSpeak = true;
00054 }
00055
00056 if(shouldSpeak && enable_audible_warnings)
00057 system("espeak \"ouch\"");
00058 }
00059
00060 int main(int argc, char **argv)
00061 {
00062
00063 ros::init(argc, argv, "arm_safety");
00064
00065 arm_safety a;
00066 ros::Rate loop_rate(60);
00067 while (ros::ok())
00068 {
00069 ros::spinOnce();
00070 loop_rate.sleep();
00071 }
00072
00073
00074
00075 return EXIT_SUCCESS;
00076 }