26 #define EXT_PORT_DATA_1 "external_port_data_1" 27 #define EXT_PORT_DATA_2 "external_port_data_2" 28 #define EXT_PORT_DATA_3 "external_port_data_3" 29 #define EXT_PORT_DATA_4 "external_port_data_4" 34 : control_cycle_msec_(8),
40 module_name_ =
"thormang3_foot_force_torque_sensor_module";
53 for(
int _idx = 0; _idx < 6; _idx++) {
135 std::string foot_ft_data_path = ros_node.
param<std::string>(
"ft_data_path",
"");
136 std::string ft_calib_data_path = ros_node.
param<std::string>(
"ft_calibration_data_path",
"");
138 r_foot_ft_sensor_.
initialize(foot_ft_data_path,
"ft_right_foot",
"r_foot_ft_link" ,
"/robotis/sensor/ft_right_foot/raw",
"/robotis/sensor/ft_right_foot/scaled");
139 l_foot_ft_sensor_.
initialize(foot_ft_data_path,
"ft_left_foot",
"l_foot_ft_link",
"/robotis/sensor/ft_left_foot/raw",
"/robotis/sensor/ft_left_foot/scaled");
144 doc = YAML::LoadFile(ft_calib_data_path.c_str());
146 std::vector<double> ft;
147 ft = doc[
"ft_right_foot_air"].as<std::vector<double> >();
151 ft = doc[
"ft_right_foot_gnd"].as<std::vector<double> >();
155 ft = doc[
"ft_left_foot_air"].as<std::vector<double> >();
159 ft = doc[
"ft_left_foot_gnd"].as<std::vector<double> >();
162 double scale = (
total_mass_ *
GRAVITY_ACCELERATION) / ( r_foot_ft_gnd_.coeff(2, 0) + l_foot_ft_gnd_.coeff(2, 0) - r_foot_ft_air_.coeff(2, 0) - l_foot_ft_air_.coeff(2, 0) );
175 out << YAML::BeginMap;
178 std::vector<double> ft_calibration;
179 for(
int ix = 0; ix < 6; ix++)
181 out << YAML::Key <<
"ft_right_foot_air" << YAML::Value << ft_calibration;
184 ft_calibration.clear();
185 for(
int ix = 0; ix < 6; ix++)
187 out << YAML::Key <<
"ft_right_foot_gnd" << YAML::Value << ft_calibration;
190 ft_calibration.clear();
191 for(
int ix = 0; ix < 6; ix++)
193 out << YAML::Key <<
"ft_left_foot_air" << YAML::Value << ft_calibration;
196 ft_calibration.clear();
197 for(
int ix = 0; ix < 6; ix++)
199 out << YAML::Key <<
"ft_left_foot_gnd" << YAML::Value << ft_calibration;
204 std::ofstream fout(path.c_str());
207 ROS_INFO(
"Save FT foot calibration data");
208 publishStatusMsg(robotis_controller_msgs::StatusMsg::STATUS_INFO,
"Saved FT Calibration Data");
215 std::string
command = msg->data;
217 if(command ==
"ft_air")
221 publishStatusMsg(robotis_controller_msgs::StatusMsg::STATUS_INFO,
"Start measuring FT_AIR");
227 else if(command ==
"ft_gnd")
231 publishStatusMsg(robotis_controller_msgs::StatusMsg::STATUS_INFO,
"Start measuring FT_GND");
236 else if(command ==
"ft_send")
254 publishStatusMsg(robotis_controller_msgs::StatusMsg::STATUS_INFO,
"Applied FT Calibration");
258 publishStatusMsg(robotis_controller_msgs::StatusMsg::STATUS_ERROR,
"There is no value for calibration");
261 else if(command ==
"ft_save")
264 std::string ft_calib_data_path = ros_node.
param<std::string>(
"ft_calibration_data_path",
"");
274 robotis_controller_msgs::StatusMsg status_msg;
276 status_msg.type = type;
277 status_msg.module_name =
"FeetFT";
278 status_msg.status_msg = msg;
285 thormang3_feet_ft_module_msgs::BothWrench both_wrench_msg;
288 both_wrench_msg.name =
"ft_air";
290 both_wrench_msg.name =
"ft_gnd";
294 both_wrench_msg.right.force.x = ft_right.coeff(0,0);
295 both_wrench_msg.right.force.y = ft_right.coeff(1,0);
296 both_wrench_msg.right.force.z = ft_right.coeff(2,0);
297 both_wrench_msg.right.torque.x = ft_right.coeff(3,0);
298 both_wrench_msg.right.torque.y = ft_right.coeff(4,0);
299 both_wrench_msg.right.torque.z = ft_right.coeff(5,0);
301 both_wrench_msg.left.force.x = ft_left.coeff(0,0);
302 both_wrench_msg.left.force.y = ft_left.coeff(1,0);
303 both_wrench_msg.left.force.z = ft_left.coeff(2,0);
304 both_wrench_msg.left.torque.x = ft_left.coeff(3,0);
305 both_wrench_msg.left.torque.y = ft_left.coeff(4,0);
306 both_wrench_msg.left.torque.z = ft_left.coeff(5,0);
337 std::map<std::string, robotis_framework::Dynamixel*>::iterator dxls_it = dxls.find(
"r_leg_an_r");
340 if(dxls_it != dxls.end())
351 dxls_it = dxls.find(
"r_leg_an_p");
352 if(dxls_it != dxls.end())
361 dxls_it = dxls.find(
"l_leg_an_r");
362 if(dxls_it != dxls.end())
373 dxls_it = dxls.find(
"l_leg_an_p");
374 if(dxls_it != dxls.end())
472 publishStatusMsg(robotis_controller_msgs::StatusMsg::STATUS_INFO,
"Finish measuring FT_AIR");
501 publishStatusMsg(robotis_controller_msgs::StatusMsg::STATUS_INFO,
"Finish measuring FT_GND");
Eigen::MatrixXd r_foot_ft_gnd_
ros::Publisher thormang3_foot_ft_both_ft_pub_
Eigen::MatrixXd getCurrentForceTorqueRaw()
void publish(const boost::shared_ptr< M > &message) const
double l_foot_fx_scaled_N_
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void initialize(const int control_cycle_msec, robotis_framework::Robot *robot)
Eigen::MatrixXd r_foot_ft_air_
double l_foot_ft_current_voltage_[6]
double r_foot_tz_scaled_Nm_
double r_foot_ft_current_voltage_[6]
#define GRAVITY_ACCELERATION
std::map< std::string, double > result_
double r_foot_fy_scaled_N_
double r_foot_fx_scaled_N_
double l_foot_ty_scaled_Nm_
void setScaleParam(double ft_scale_factor, Eigen::MatrixXd ft_null)
ROSLIB_DECL std::string command(const std::string &cmd)
double l_foot_fy_scaled_N_
double r_foot_ty_scaled_Nm_
void setCurrentVoltageOutputPublish(double voltage0, double voltage1, double voltage2, double voltage3, double voltage4, double voltage5)
void process(std::map< std::string, robotis_framework::Dynamixel * > dxls, std::map< std::string, robotis_framework::Sensor * > sensors)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
void setCallbackQueue(CallbackQueueInterface *queue)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
boost::thread queue_thread_
double l_foot_tx_scaled_Nm_
double r_foot_fz_scaled_N_
double l_foot_fz_scaled_N_
double l_foot_tz_scaled_Nm_
KinematicsDynamics * thormang3_kd_
bool initialize(const std::string &ft_data_path, const std::string &ft_data_key, const std::string &ft_frame_id, const std::string &ft_raw_publish_name, const std::string &ft_scaled_publish_name)
void publishBothFTData(int type, Eigen::MatrixXd &ft_right, Eigen::MatrixXd &ft_left)
void ftSensorCalibrationCommandCallback(const std_msgs::String::ConstPtr &msg)
#define ROS_INFO_STREAM(args)
double calcTotalMass(int joint_id)
double r_foot_tx_scaled_Nm_
ATIForceTorqueSensorTWE r_foot_ft_sensor_
Eigen::MatrixXd l_foot_ft_air_
void publishStatusMsg(unsigned int type, std::string msg)
Eigen::MatrixXd getCurrentForceTorqueScaled()
double l_foot_ft_scale_factor_
Eigen::MatrixXd l_foot_ft_gnd_
void saveFTCalibrationData(const std::string &path)
ATIForceTorqueSensorTWE l_foot_ft_sensor_
double r_foot_ft_scale_factor_
void initializeFeetForceTorqueSensor()
ros::Publisher thormang3_foot_ft_status_pub_