16 ROS_DEBUG(
"Marty Calibration Ready!");
20 ros::param::del(
"/marty");
26 WARN(
"Marty has not been calibrated before!" << std::endl);
34 marty_msgs::ServoMsg joint;
37 joints_.servo_msg.push_back(joint);
42 nh_.param(
NAMES[
id] +
"/zero", val, 0);
43 joints_.servo_msg[id].servo_cmd = val;
49 joint_pub_ =
nh_.advertise<marty_msgs::ServoMsgArray>(
"servo_array", 10);
55 INFO(
" q-a\tw-s\te-d\tr-f\tt-g\ty-h\tz-x\tc-v\tu-j\ti-k\to-l\tENTER to save\n");
56 INFO(
" LHIP\tLTWIST\tLKNEE\tRHIP\tRTWIST\tRKNEE\tLARM\tRARM\tEYES\tAUX1\tAUX2\t");
62 WARN(
"m - Exit" << std::endl);
69 std_msgs::Bool enabled;
80 ROS_INFO_STREAM(
"Char: " <<
c_);
110 joints_.servo_msg[id].servo_cmd =
111 std::min(
int(
joints_.servo_msg[
id].servo_cmd), 126);
112 joints_.servo_msg[id].servo_cmd =
113 std::max(
int(
joints_.servo_msg[
id].servo_cmd), -126);
116 WARN(
"Are you sure you wish to save these values? (y/n) ");
126 WARN(
"Are you sure you want to exit? (y/n) ");
137 std::string path = ros::package::getPath(
"ros_marty");
138 std::ofstream of (path +
"/cfg/joint_calib.cfg");
139 of <<
"# ****************************************************************************\n" 140 <<
"# **WARNING: DO NOT CHANGE ANYTHING BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!**\n" 141 <<
"# ****************************************************************************\n";
142 of <<
"calibrated: true\n\n";
144 std::string name =
NAMES[id];
146 int val = int(
joints_.servo_msg[
id].servo_cmd);
147 if ((name ==
"LHIP") or (name ==
"RHIP")) {off =
HIP_OFFSET;}
148 else if ((name ==
"LTWIST") or (name ==
"RTWIST")) {off =
TWIST_OFFSET;}
149 else if ((name ==
"LKNEE") or (name ==
"RKNEE")) {off =
KNEE_OFFSET;}
150 else if ((name ==
"LARM") or (name ==
"RARM")) {off =
ARM_OFFSET;}
152 else if ((name ==
"AUX1") or (name ==
"AUX2")) {off =
AUX_OFFSET;}
153 else {
WARN(
"No offset found for joint: " << name << std::endl);}
154 of << name <<
": {min: " << std::max(val - off, -126) <<
155 ", zero: " << val <<
", max: " << std::min(val + off, 126) <<
163 struct termios old = {0};
164 if (tcgetattr(0, &old) < 0)
165 perror(
"tcsetattr()");
166 old.c_lflag &= ~ICANON;
167 old.c_lflag &= ~ECHO;
170 if (tcsetattr(0, TCSANOW, &old) < 0)
171 perror(
"tcsetattr ICANON");
172 if (read(0, &buf, 1) < 0)
174 old.c_lflag |= ICANON;
176 if (tcsetattr(0, TCSADRAIN, &old) < 0)
177 perror (
"tcsetattr ~ICANON");
const std::vector< int > JOINT_DIR
ros::Publisher joint_pub_
marty_msgs::ServoMsgArray joints_
marty_msgs::ServoMsgArray cal_vals_
const std::vector< std::string > NAMES
ros::Publisher enable_pub_
const std::vector< int > JOINT_MULT
Calibration class for calibrating Marty's servos.
Calibration(ros::NodeHandle &nh)