00001 #ifndef ROBOT_STATE_H_ 00002 #define ROBOT_STATE_H_ 00003 00004 #include <inttypes.h> 00005 #include <vector> 00006 #include <stdlib.h> 00007 #include <string.h> 00008 #include <mutex> 00009 #include <netinet/in.h> 00010 #include <condition_variable> 00011 00012 class RobotState{ 00013 private: 00014 std::vector<double> joint_position_actual_; //Actual joint positions 00015 std::vector<double> joint_velocity_actual_; //Actual joint velocity 00016 std::vector<double> tool_position_actual_; //Actual Cartesian coordinates of the tool: (x,y,z) 00017 std::vector<double> tool_orientation_actual_; //Actual Cartesian orientation of the tool: (w,x,y,z) 00018 std::vector<double> joint_temperatures_actual_; //Temperature of each joint in degrees celsius 00019 std::vector<double> joint_current_actual_; //Current of each joint 00020 std::vector<double> joint_voltage_actual_; //Voltage of each joint 00021 std::vector<double> tcp_force_actual_; //Actual tcp force 00022 00023 double end_speed_actual_; //Actual speed of the tool given in Cartesian coordinates 00024 00025 00026 std::mutex val_lock_; // Locks the variables while unpack parses data; 00027 00028 std::condition_variable* pMsg_cond_; //Signals that new vars are available 00029 bool data_published_; //to avoid spurious wakes 00030 bool controller_updated_; //to avoid spurious wakes 00031 00032 public: 00033 RobotState(std::condition_variable& msg_cond); 00034 ~RobotState(); 00035 00036 std::vector<double> getJonitPosition(); 00037 std::vector<double> getJonitVelocity(); 00038 std::vector<double> getTcpForce(); 00039 std::vector<double> getToolPosition(); 00040 std::vector<double> getToolOrientation(); 00041 std::vector<double> getJointTemperatures(); 00042 std::vector<double> getJointCurrent(); 00043 std::vector<double> getJointVoltage(); 00044 00045 double getEndSpeed(); 00046 00047 void setDataPublished(); 00048 bool getDataPublished(); 00049 bool getControllerUpdated(); 00050 void setControllerUpdated(); 00051 void unpack(uint8_t * buf); 00052 }; 00053 00054 #endif /* ROBOT_STATE_H_ */