47 #include "std_msgs/String.h" 48 #include "geometry_msgs/WrenchStamped.h" 50 #include "robotiq_ft_sensor/ft_sensor.h" 51 #include "robotiq_ft_sensor/sensor_accessor.h" 67 robotiq_ft_sensor::sensor_accessor::Response& res)
75 ROS_WARN(
"Unsupported command_id '%i', should be in [%i, %i, %i, %i]",
77 Request::COMMAND_GET_SERIAL_NUMBER,
78 Request::COMMAND_GET_FIRMWARE_VERSION,
79 Request::COMMAND_GET_PRODUCTION_YEAR,
80 Request::COMMAND_SET_ZERO);
97 if(buff == NULL || strlen(buff) != 7)
102 strncpy(get_or_set, &buff[0], 3);
103 strncpy(nom_var, &buff[4], strlen(buff) -3);
105 if(strstr(get_or_set,
"GET"))
109 else if(strstr(get_or_set,
"SET"))
111 if(strstr(nom_var,
"ZRO"))
120 robotiq_ft_sensor::sensor_accessor::Response& res)
123 if (req.command.length())
125 ROS_WARN_ONCE(
"Usage of command-string is deprecated, please use the numeric command_id");
126 ROS_INFO(
"I heard: [%s]",req.command.c_str());
130 ROS_INFO(
"I send: [%s]", res.res.c_str());
159 ROS_INFO(
"Waiting for sensor connection...");
180 robotiq_ft_sensor::ft_sensor msgStream;
192 int main(
int argc,
char **argv)
194 ros::init(argc, argv,
"robotiq_ft_sensor");
196 ros::param::param<int>(
"~max_retries",
max_retries_, 100);
204 ROS_INFO(
"No device filename specified. Will attempt to discover Robotiq force torque sensor.");
207 INT_8 bufStream[512];
208 robotiq_ft_sensor::ft_sensor msgStream;
237 geometry_msgs::WrenchStamped wrenchMsg;
238 ros::param::param<std::string>(
"~frame_id", wrenchMsg.header.frame_id,
"robotiq_ft_frame_id");
251 strcpy(bufStream,
"");
260 wrenchMsg.wrench.force.x = msgStream.Fx;
261 wrenchMsg.wrench.force.y = msgStream.Fy;
262 wrenchMsg.wrench.force.z = msgStream.Fz;
263 wrenchMsg.wrench.torque.x = msgStream.Mx;
264 wrenchMsg.wrench.torque.y = msgStream.My;
265 wrenchMsg.wrench.torque.z = msgStream.Mz;
266 wrench_pub.publish(wrenchMsg);
bool receiverCallback(robotiq_ft_sensor::sensor_accessor::Request &req, robotiq_ft_sensor::sensor_accessor::Response &res)
void publish(const boost::shared_ptr< M > &message) const
void rq_state_get_command(INT_8 const *const name, INT_8 *const value)
float rq_state_get_received_data(UINT_8 i)
robotiq_ft_sensor::sensor_accessor::Request Request
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
int main(int argc, char **argv)
static bool decode_message_and_do(robotiq_ft_sensor::sensor_accessor::Request &req, robotiq_ft_sensor::sensor_accessor::Response &res)
decode_message_and_do Decode the message received and do the associated action
enum rq_sensor_state_values rq_sensor_get_current_state(void)
Returns this module's state machine current state.
static void wait_for_other_connection()
Each second, checks for a sensor that has been connected.
ROSCPP_DECL bool get(const std::string &key, std::string &s)
#define ROS_WARN_ONCE(...)
ros::Publisher sensor_pub_acc
static INT_8 sensor_state_machine()
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
static robotiq_ft_sensor::ft_sensor get_data(void)
Builds the message with the force/torque data.
void rq_state_do_zero_force_flag(void)
Command a zero on the sensor.
bool rq_state_got_new_message(void)
Returns true if a stream message is available.
ROSCPP_DECL void spinOnce()
static int max_retries_(100)
INT_8 rq_sensor_state(unsigned int max_retries)