3 #include <std_msgs/Float32.h>
4 #include <std_msgs/String.h>
5 #include <std_msgs/Bool.h>
7 #include <threemxl/C3mxlROS.h>
13 void shutdown(
const std_msgs::Bool::ConstPtr&);
28 int main(
int argc,
char **argv){
30 ros::init(argc, argv,
"gripper_actuator");
31 CDxlConfig *config =
new CDxlConfig();
32 ROS_INFO(
"Using direct connection");
34 LxSerial serial_port_;
35 serial_port_.port_open(
"/dev/ttyUSB0", LxSerial::RS485_FTDI);
36 serial_port_.set_speed(LxSerial::S921600);
37 motor_->setSerialPort(&serial_port_);
39 motor_->setConfig(config->setID(109));
41 motor_->set3MxlMode(CURRENT_MODE);
46 ros::Subscriber controller = n.subscribe(
"gripper_control", 1000,
gripperControl);
47 gripper_state = n.advertise<std_msgs::Float32>(
"gripper_state", 1000);
48 ros::Subscriber sd = n.subscribe(
"shutdown", 1,
shutdown);
64 string cmd = msg->cmd;
65 const char* c_cmd = cmd.c_str();
66 float force = msg->force;
68 ROS_INFO(
"Actuating gripper: %sing %fN -> %fA",c_cmd, force,
current);
69 if(cmd.compare(
"open") == 0){
71 }
else if(cmd.compare(
"relax") == 0){
73 }
else if(cmd.compare(
"close") == 0){
76 ROS_INFO(
"Invalid command supplied");
86 ROS_INFO(
"Opening gripper");
88 std_msgs::Float32 msg;
100 ROS_INFO(
"Closing gripper");
102 std_msgs::Float32 msg;
114 ROS_INFO(
"Relaxing gripper");
116 std_msgs::Float32 msg;