Go to the documentation of this file.00001
00031
00032
00033 #ifndef PG70_RS232_CONTROL_H
00034 #define PG70_RS232_CONTROL_H
00035
00036 #include <ros/ros.h>
00037 #include <serial/serial.h>
00038 #include <tf/transform_broadcaster.h>
00039 #include <sensor_msgs/JointState.h>
00040
00041
00042 #include <schunk_pg70/reference.h>
00043 #include <schunk_pg70/set_position.h>
00044 #include <schunk_pg70/get_error.h>
00045 #include <schunk_pg70/get_position.h>
00046 #include <schunk_pg70/acknowledge_error.h>
00047 #include <schunk_pg70/stop.h>
00048
00050 namespace schunk_pg70
00051 {
00052
00054 class PG70_serial
00055 {
00056 public:
00057
00059 PG70_serial(ros::NodeHandle *nh);
00060
00061 ~PG70_serial();
00062
00064 bool referenceCallback(schunk_pg70::reference::Request &req,
00065 schunk_pg70::reference::Response &res);
00066
00068 bool getErrorCallback(schunk_pg70::get_error::Request &req,
00069 schunk_pg70::get_error::Response &res);
00070
00072 bool getPositionCallback(schunk_pg70::get_position::Request &req,
00073 schunk_pg70::get_position::Response &res);
00074
00076 bool setPositionCallback(schunk_pg70::set_position::Request &req,
00077 schunk_pg70::set_position::Response &res);
00078
00080 bool acknowledgeErrorCallback(schunk_pg70::acknowledge_error::Request &req,
00081 schunk_pg70::acknowledge_error::Response &res);
00082
00084 bool stopCallback(schunk_pg70::stop::Request &req,
00085 schunk_pg70::stop::Response &res);
00086
00088 void timerCallback(const ros::TimerEvent &event);
00089
00091 ros::Publisher joint_pub;
00092
00094 static const float TF_UPDATE_PERIOD = 0.1;
00095
00096 private:
00097
00099 void reference(serial::Serial *port);
00100
00102 uint8_t getError(serial::Serial *port);
00103
00105 float getPosition(serial::Serial *port);
00106
00108 void setPosition(serial::Serial *port, int goal_position, int velocity, int acceleration);
00109
00111 void acknowledgeError(serial::Serial *port);
00112
00114 void stop(serial::Serial *port);
00115
00117 void getPeriodicPositionUpdate(serial::Serial *port, float update_frequency);
00118
00120 uint16_t CRC16(uint16_t crc, uint16_t data);
00121
00123 float IEEE_754_to_float(uint8_t *raw);
00124
00126 void float_to_IEEE_754(float position, unsigned int *output_array);
00127
00128
00129 int gripper_id_;
00130 std::string port_name_;
00131 int baudrate_;
00132
00133
00134 float act_position_;
00135 uint8_t pg70_error_;
00136 sensor_msgs::JointState pg70_joint_state_;
00137
00138
00139 serial::Serial *com_port_;
00140
00141
00142 static const double MIN_GRIPPER_POS_LIMIT = 0;
00143 static const double MAX_GRIPPER_POS_LIMIT = 69;
00144 static const double MIN_GRIPPER_VEL_LIMIT = 0;
00145 static const double MAX_GRIPPER_VEL_LIMIT = 83;
00146 static const double MIN_GRIPPER_ACC_LIMIT = 0;
00147 static const double MAX_GRIPPER_ACC_LIMIT = 320;
00148 static const double WAIT_FOR_RESPONSE_INTERVAL = 0.5;
00149 static const double INPUT_BUFFER_SIZE = 64;
00150 static const int URDF_SCALE_FACTOR = 2000;
00151
00152 };
00153 }
00154
00155 #endif //PG70_RS232_CONTROL_H