9 double target_angle = target_joint_angle * 180.0 /
M_PI;
10 int int_target_angle =
static_cast<int>(std::floor(target_angle));
11 int target_range[2] = {int_target_angle, 1+int_target_angle};
12 double self_joint_range[2];
13 for (
size_t i = 0;
i < 2;
i++) {
17 double tmp_ratio = target_angle - int_target_angle;
18 return (self_joint_range[0] * (1-tmp_ratio) + self_joint_range[1] * tmp_ratio) *
M_PI / 180.0;
23 const std::string& prop_string,
24 const std::string& instance_name)
26 if (prop_string !=
"") {
28 size_t limit_table_size = 6;
29 size_t num_limit_table = limit_tables.size() / limit_table_size;
30 std::cerr <<
"[" << instance_name <<
"] Load joint limit table [" << num_limit_table <<
"]" << std::endl;
31 for (
size_t i = 0;
i < num_limit_table;
i++) {
32 size_t start_idx =
i*limit_table_size;
34 coil::stringTo(target_llimit_angle, limit_tables[start_idx+2].c_str());
35 coil::stringTo(target_ulimit_angle, limit_tables[start_idx+3].c_str());
40 for (
size_t j = 0;
j < m_robot->numJoints();
j++) {
41 if ( m_robot->joint(
j)->name == limit_tables[start_idx+1]) target_jointId = m_robot->joint(
j)->jointId;
43 if ( llimit_str_v.size() != ulimit_str_v.size() || target_jointId == -1 ) {
44 std::cerr <<
"[" << instance_name <<
"] " << limit_tables[start_idx+0] <<
":" << limit_tables[start_idx+1] <<
" fail" << std::endl;
46 std::cerr <<
"[" << instance_name <<
"] " << limit_tables[start_idx+0] <<
":" << limit_tables[start_idx+1] <<
"(" << target_jointId <<
")" << std::endl;
47 std::cerr <<
"[" << instance_name <<
"] target_llimit_angle " << limit_tables[start_idx+2] <<
"[deg], target_ulimit_angle " << limit_tables[start_idx+3] <<
"[deg]" << std::endl;
48 std::cerr <<
"[" << instance_name <<
"] llimit_table[deg] " << limit_tables[start_idx+4] << std::endl;
49 std::cerr <<
"[" << instance_name <<
"] ulimit_table[deg] " << limit_tables[start_idx+5] << std::endl;
54 joint_limit_tables.insert(std::pair<std::string, hrp::JointLimitTable>(limit_tables[start_idx],
59 std::cerr <<
"[" << instance_name <<
"] Do not load joint limit table" << std::endl;
bool stringTo(To &val, const char *str)
vstring split(const std::string &input, const std::string &delimiter, bool ignore_empty)
hrp::dvector llimit_table
hrp::dvector ulimit_table
void readJointLimitTableFromProperties(std::map< std::string, hrp::JointLimitTable > &joint_mm_tables, hrp::BodyPtr m_robot, const std::string &prop_string, const std::string &instance_name)
std::vector< std::string > vstring
double getInterpolatedLimitAngle(const double target_joint_angle, const bool is_llimit_angle) const
def j(str, encoding="cp932")