diff --git a/include/dynamixel_pan_tilt.h b/include/dynamixel_pan_tilt.h index 3ae73db22a6c67c3aa8b6b769298c0e5bb942754..bc03438844322074deefcd2e0d75dfaf5109132c 100644 --- a/include/dynamixel_pan_tilt.h +++ b/include/dynamixel_pan_tilt.h @@ -66,7 +66,7 @@ typedef struct * - double max_temperature * - double max_voltage * - double min_voltage - * - double max_torque + * - double max_pwm * - unsigned short int punch */ @@ -157,8 +157,12 @@ typedef struct * - tilt * * The control_mode enum has the following possible values: - * - angle_ctrl - * - torque_ctrl + * - current_ctrl + * - velocity_ctrl + * - position_ctrl + * - ext_position_ctrl + * - current_pos_ctrl + * - pwm_ctrl */ typedef struct @@ -167,28 +171,28 @@ typedef struct control_mode tilt; }Control_mode_pan_tilt; -typedef enum {positive_torque = 1, stopped = 0, negative_torque = -1} Torque_moving_state; +typedef enum {positive_pwm = 1, stopped = 0, negative_pwm = -1} Pwm_moving_state; /** - * \struct Torque_pan_tilt_moving_state. + * \struct Pwm_pan_tilt_moving_state. * - * \brief A struct to save the torque moving state of the servos. + * \brief A struct to save the pwm moving state of the servos. * - * It has two members of type Torque_moving_state: + * It has two members of type Pwm_moving_state: * - pan * - tilt * - * The Torque_moving_state enum has the following possible values: - * - positive_torque + * The Pwm_moving_state enum has the following possible values: + * - positive_pwm * - stopped - * - negative_torque + * - negative_pwm */ typedef struct { - Torque_moving_state pan; - Torque_moving_state tilt; -}Torque_pan_tilt_moving_state; + Pwm_moving_state pan; + Pwm_moving_state tilt; +}Pwm_pan_tilt_moving_state; /** * \struct Dynamixel_pan_tilt_xml_limits. @@ -196,18 +200,18 @@ typedef struct * \brief A struct to save the configuration limits readed of a xml file. * * It has three members of type Dynamixel_pan_tilt_data: - * - max_torque + * - max_pwm * - max_angle * - min_angle */ typedef struct { - Dynamixel_pan_tilt_data max_torque; + Dynamixel_pan_tilt_data max_pwm; Dynamixel_pan_tilt_data max_angle; Dynamixel_pan_tilt_data min_angle; - Dynamixel_pan_tilt_data max_angle_torque; - Dynamixel_pan_tilt_data min_angle_torque; + Dynamixel_pan_tilt_data max_angle_pwm; + Dynamixel_pan_tilt_data min_angle_pwm; }Dynamixel_pan_tilt_xml_limits; @@ -218,20 +222,20 @@ typedef struct * * This class is created to control a Pan-Tilt plataform with two servos. It allows you to get the position of both * servos or to get the position of any servo. It also allows you to move the Pan-Tilt to a desired position or - * to a desired position relative to the current position or on torque mode. + * to a desired position relative to the current position or on pwm mode. * * The best way to configure the Pan-Tilt is with a configuration file in XML. You can see the schema of the configuration * file at .../src/xml/dynamixel_pan_tilt_cfg_file.xsd. The optional parameters with their default values are: * * \b - alarm_shtdwn: 5 (Input Voltage error and Overheating error) * \b - temp_limit: 85 - * \b - max_torque: 50 + * \b - max_pwm: 50 * \b - check_hyst_offset: 2.404867 * \b - check_hyst_slope: 0.20688 * * You can also configurate the following parameters specifically for each servo (if not, both servos get the same configuration value): * - * \b - max_torque + * \b - max_pwm * \b - cw_comp_margin * \b - ccw_comp_margin * \b - cw_comp_slope @@ -246,7 +250,7 @@ typedef struct * \b - check_hyst_slope * * It's important to note that the values of min and max angle must be the physical angle limits for the plataform and not - * overpass this angles is checked with another thread during the torque movement. + * overpass this angles is checked with another thread during the pwm movement. */ class CDynamixel_Pan_Tilt @@ -266,12 +270,12 @@ class CDynamixel_Pan_Tilt pthread_t checking_thread; pthread_mutex_t mut; - Torque_pan_tilt_moving_state moving_state; + Pwm_pan_tilt_moving_state moving_state; Dynamixel_pan_tilt_data checking_hysteresis, checking_hysteresis_offset, checking_hysteresis_slope; CEventServer *event_server; std::string exiting; - std::string torque_moving; + std::string pwm_moving; protected: @@ -324,7 +328,7 @@ class CDynamixel_Pan_Tilt void update_info(void); /** - * \brief Function to be called for the thread in charge to check the angle limits on torque movement. + * \brief Function to be called for the thread in charge to check the angle limits on pwm movement. * * \param arg A pointer to the class. */ @@ -334,42 +338,42 @@ class CDynamixel_Pan_Tilt * \brief Function to set the both servos_state to stopped. * */ - void reset_torque_moving_state(void); + void reset_pwm_moving_state(void); /** - * \brief Function that returns if any servo is moving on torque mode. + * \brief Function that returns if any servo is moving on pwm mode. * * \param b The variable where is going to be returned the value. */ - void is_torque_moving(bool &b); + void is_pwm_moving(bool &b); /** * \brief Function to set a value on pan's moving state. * - * \param tms The value desired. + * \param pms The value desired. */ - void set_moving_state_pan(Torque_moving_state tms); + void set_moving_state_pan(Pwm_moving_state pms); /** * \brief Function to get the value of pan's moving state. * - * \param tms The variable to save the value of the pan's moving state. + * \param pms The variable to save the value of the pan's moving state. */ - void get_moving_state_pan(Torque_moving_state &tms); + void get_moving_state_pan(Pwm_moving_state &pms); /** * \brief Function to set a value on tilt's moving state. * - * \param tms The value desired. + * \param pms The value desired. */ - void set_moving_state_tilt(Torque_moving_state tms); + void set_moving_state_tilt(Pwm_moving_state pms); /** * \brief Function to get the value of tilt's moving state. * - * \param tms The variable to save the value of the tilt's moving state. + * \param pms The variable to save the value of the tilt's moving state. */ - void get_moving_state_tilt(Torque_moving_state &tms); + void get_moving_state_tilt(Pwm_moving_state &pms); /** * \brief Function to calculate the angle hysteresis depending on the desired effort for the pan servo. @@ -579,9 +583,9 @@ class CDynamixel_Pan_Tilt * \brief Function to move the pan-tilt on endless mode for both servos. * If some of the values passed are out of range, they'll be changed to the value of the limit. * - * \param speed A struct with the specific speeds for the movemenet. It's a % of the maximum torque. + * \param speed A struct with the specific speeds for the movemenet. It's a % of the maximum pwm. */ - void move_torque(Dynamixel_pan_tilt_data &speed); + void move_pwm(Dynamixel_pan_tilt_data &speed); /** * \brief Function to move the pan servo to a specific position by a specific speed. @@ -606,9 +610,9 @@ class CDynamixel_Pan_Tilt * \brief Function to move the pan servo on endless mode. * If the value passed is out of range, it'll be changed to the value of the limit. * - * \param speed The specific speed for the movemenet. It's a % of the maximum torque. + * \param speed The specific speed for the movemenet. It's a % of the maximum pwm. */ - void move_torque_pan(double &speed); + void move_pwm_pan(double &speed); /** * \brief Function to move the pan servo to a specific position by a specific speed. @@ -633,14 +637,14 @@ class CDynamixel_Pan_Tilt * \brief Function to move the tilt servo on endless mode. * If the value passed is out of range, it'll be changed to the value of the limit. * - * \param speed The specific speed for the movemenet. It's a % of the maximum torque. + * \param speed The specific speed for the movemenet. It's a % of the maximum pwm. */ - void move_torque_tilt(double &speed); + void move_pwm_tilt(double &speed); /** * \brief Function to stop the current movement of the pan-tilt. * - * It always call the torque_movement function with a zero as argument. That's beacuse the servo can be out of range + * It always call the pwm_movement function with a zero as argument. That's beacuse the servo can be out of range * at the moment of the call so it can generate a exception if it's on angle control mode. * */ @@ -658,7 +662,7 @@ class CDynamixel_Pan_Tilt * * \return A struct with the current effort of both servos in %. */ - Dynamixel_pan_tilt_data get_current_effort(void); + Dynamixel_pan_tilt_data get_current_pwm(void); /** * \brief Function to get the compliance configuration of both servos. @@ -689,18 +693,18 @@ class CDynamixel_Pan_Tilt void set_pid_control(Dynamixel_pan_tilt_pid &pid); /** - * \brief Function to set the max torque of both servos. + * \brief Function to set the max pwm of both servos. * - * \param pid The torque value. + * \param pid The pwm value. */ - void set_max_torque(Dynamixel_pan_tilt_data &torque); + void set_max_pwm(Dynamixel_pan_tilt_data &pwm); /** - * \brief Function to get the current limit torque of both servos in %. + * \brief Function to get the current limit pwm of both servos in %. * - * \return A struct with the current limit torque of both servos in %. + * \return A struct with the current limit pwm of both servos in %. */ - Dynamixel_pan_tilt_data get_limit_torque(void); + Dynamixel_pan_tilt_data get_pwm_limit(void); /** * \brief Function to get the current max angle limit of both servos in deg. diff --git a/src/dynamixel_pan_tilt.cpp b/src/dynamixel_pan_tilt.cpp index 33b527f4ce27941a32c033ab4ac1a291ecf4fa1c..99f32ab126270a45dc8d20c2ae92a7a0954f1921 100644 --- a/src/dynamixel_pan_tilt.cpp +++ b/src/dynamixel_pan_tilt.cpp @@ -47,13 +47,13 @@ CDynamixel_Pan_Tilt::CDynamixel_Pan_Tilt(std::string& name_pan_tilt, CDynamixelS this->event_server=CEventServer::instance(); this->exiting = name_pan_tilt + "_exiting"; this->event_server->create_event(this->exiting); - this->torque_moving = name_pan_tilt + "_torque_moving"; - this->event_server->create_event(this->torque_moving); + this->pwm_moving = name_pan_tilt + "_pwm_moving"; + this->event_server->create_event(this->pwm_moving); if (this->event_server->event_is_set(this->exiting)) this->event_server->reset_event(this->exiting); - if (this->event_server->event_is_set(this->torque_moving)) - this->event_server->reset_event(this->torque_moving); + if (this->event_server->event_is_set(this->pwm_moving)) + this->event_server->reset_event(this->pwm_moving); int res; @@ -62,7 +62,7 @@ CDynamixel_Pan_Tilt::CDynamixel_Pan_Tilt(std::string& name_pan_tilt, CDynamixelS perror("Mutex initialization failed"); exit(EXIT_FAILURE); } - reset_torque_moving_state(); + reset_pwm_moving_state(); set_checking_hysteresis_pan(0.0); set_checking_hysteresis_tilt(0.0); res = pthread_create(&(this->checking_thread), NULL, checking_angle_limits, (void *)this); @@ -120,10 +120,10 @@ CDynamixel_Pan_Tilt::~CDynamixel_Pan_Tilt() this->event_server->delete_event(this->exiting); this->exiting = ""; } - if(this->torque_moving != "") + if(this->pwm_moving != "") { - this->event_server->delete_event(this->torque_moving); - this->torque_moving = ""; + this->event_server->delete_event(this->pwm_moving); + this->pwm_moving = ""; } }catch(CException &e){ /* do nothing */ @@ -159,7 +159,7 @@ void CDynamixel_Pan_Tilt::load_config(Dynamixel_pan_tilt_config &config) this->config.pan.max_temperature = config.pan.max_temperature; this->config.pan.max_voltage = config.pan.max_voltage; this->config.pan.min_voltage = config.pan.min_voltage; - this->config.pan.max_torque = config.pan.max_torque; + this->config.pan.max_pwm = config.pan.max_pwm; this->config.pan.punch = config.pan.punch; this->config.tilt.max_angle = config.tilt.max_angle; @@ -167,7 +167,7 @@ void CDynamixel_Pan_Tilt::load_config(Dynamixel_pan_tilt_config &config) this->config.tilt.max_temperature = config.tilt.max_temperature; this->config.tilt.max_voltage = config.tilt.max_voltage; this->config.tilt.min_voltage = config.tilt.min_voltage; - this->config.tilt.max_torque = config.tilt.max_torque; + this->config.tilt.max_pwm = config.tilt.max_pwm; this->config.tilt.punch = config.tilt.punch; update_angle_limits(); } @@ -297,22 +297,22 @@ void CDynamixel_Pan_Tilt::load_config(std::string &filename) punch--; this->tilt->set_punch(*punch); - if (cfg->max_torque().size() > 0) + if (cfg->max_pwm().size() > 0) { - dynamixel_pan_tilt_config_t::max_torque_const_iterator max_torque (cfg->max_torque().begin()); - this->pan->set_max_torque(*max_torque); - this->pan->set_limit_torque(*max_torque); - max_torque = cfg->max_torque().end(); - max_torque--; - this->tilt->set_max_torque(*max_torque); - this->tilt->set_limit_torque(*max_torque); + dynamixel_pan_tilt_config_t::max_pwm_const_iterator max_pwm (cfg->max_pwm().begin()); + this->pan->set_max_pwm(*max_pwm); + this->pan->set_pwm_limit(*max_pwm); + max_pwm = cfg->max_pwm().end(); + max_pwm--; + this->tilt->set_max_pwm(*max_pwm); + this->tilt->set_pwm_limit(*max_pwm); } else { - this->pan->set_max_torque(50.0); - this->pan->set_limit_torque(50.0); - this->tilt->set_max_torque(50.0); - this->tilt->set_limit_torque(50.0); + this->pan->set_max_pwm(50.0); + this->pan->set_pwm_limit(50.0); + this->tilt->set_max_pwm(50.0); + this->tilt->set_pwm_limit(50.0); } if (cfg->check_hyst_offset().size() > 0) @@ -383,18 +383,18 @@ void CDynamixel_Pan_Tilt::read_config(std::string &filename, Dynamixel_pan_tilt_ xml_limits.min_angle.tilt = *min_angle; xml_limits.max_angle.tilt = *max_angle; - if (cfg->max_torque().size() > 0) + if (cfg->max_pwm().size() > 0) { - dynamixel_pan_tilt_config_t::max_torque_const_iterator max_torque (cfg->max_torque().begin()); - xml_limits.max_torque.pan = *max_torque; - max_torque = cfg->max_torque().end(); - max_torque--; - xml_limits.max_torque.tilt = *max_torque; + dynamixel_pan_tilt_config_t::max_pwm_const_iterator max_pwm (cfg->max_pwm().begin()); + xml_limits.max_pwm.pan = *max_pwm; + max_pwm = cfg->max_pwm().end(); + max_pwm--; + xml_limits.max_pwm.tilt = *max_pwm; } else { - xml_limits.max_torque.pan = 50; - xml_limits.max_torque.tilt = 50; + xml_limits.max_pwm.pan = 50; + xml_limits.max_pwm.tilt = 50; } } catch (const xml_schema::exception& e) @@ -456,7 +456,7 @@ void CDynamixel_Pan_Tilt::save_config(std::string &filename) this->config.pan.max_temperature, this->config.pan.max_voltage, this->config.pan.min_voltage, - this->config.pan.max_torque, + this->config.pan.max_pwm, cw_compliance_margin, ccw_compliance_margin, cw_compliance_slope, @@ -507,10 +507,10 @@ void CDynamixel_Pan_Tilt::move_absolute_angle_pan(double &angle, double &speed) { try { - if (this->mode.pan != angle_ctrl) + if (this->mode.pan != position_ctrl) {//It has to update the normal limits and the mode this->pan->set_position_range(this->min_angle.pan, this->max_angle.pan); - this->mode.pan = angle_ctrl; + this->mode.pan = position_ctrl; this->config.pan.min_angle = this->min_angle.pan; this->config.pan.max_angle = this->max_angle.pan; } @@ -526,17 +526,17 @@ void CDynamixel_Pan_Tilt::move_absolute_angle_pan(double &angle, double &speed) angle = this->config.pan.max_angle - ANGLE_LIMIT_CORRECTION;//on the exact limit it gives an error beacuse the conversion between angle and the word } - if (fabs(speed) > this->info.pan.max_speed*this->config.pan.max_torque/100) + if (fabs(speed) > this->info.pan.max_speed*this->config.pan.max_pwm/100) { - std::cout << "\033[33m WARNING: The maximum pan' speed is " << this->info.pan.max_speed*this->config.pan.max_torque/100 << "; Moving pan at this speed. \033[0m" << std::endl; - speed = this->info.pan.max_speed*this->config.pan.max_torque/100; + std::cout << "\033[33m WARNING: The maximum pan' speed is " << this->info.pan.max_speed*this->config.pan.max_pwm/100 << "; Moving pan at this speed. \033[0m" << std::endl; + speed = this->info.pan.max_speed*this->config.pan.max_pwm/100; } set_moving_state_pan(stopped); this->pan->move_absolute_angle(angle, speed); - if (this->event_server->event_is_set(this->torque_moving)) - this->event_server->reset_event(this->torque_moving); + if (this->event_server->event_is_set(this->pwm_moving)) + this->event_server->reset_event(this->pwm_moving); //set_checking_hysteresis_pan(0.0); } catch(CException &e) @@ -562,10 +562,10 @@ void CDynamixel_Pan_Tilt::move_absolute_angle_tilt(double &angle, double &speed) { try { - if (this->mode.tilt != angle_ctrl) + if (this->mode.tilt != position_ctrl) {//It has to update the normal limits and the mode this->tilt->set_position_range(this->min_angle.tilt, this->max_angle.tilt); - this->mode.tilt = angle_ctrl; + this->mode.tilt = position_ctrl; this->config.tilt.min_angle = this->min_angle.tilt; this->config.tilt.max_angle = this->max_angle.tilt; } @@ -581,16 +581,16 @@ void CDynamixel_Pan_Tilt::move_absolute_angle_tilt(double &angle, double &speed) angle = this->config.tilt.max_angle - ANGLE_LIMIT_CORRECTION;//on the exact limit it gives an error beacuse the conversion between angle and the word } - if (fabs(speed) > this->info.tilt.max_speed*this->config.tilt.max_torque/100) + if (fabs(speed) > this->info.tilt.max_speed*this->config.tilt.max_pwm/100) { - std::cout << "\033[33m WARNING: The maximum tilt' speed is " << this->info.tilt.max_speed*this->config.tilt.max_torque/100 << "; Moving tilt at this speed. \033[0m" << std::endl; - speed = this->info.tilt.max_speed*this->config.tilt.max_torque/100; + std::cout << "\033[33m WARNING: The maximum tilt' speed is " << this->info.tilt.max_speed*this->config.tilt.max_pwm/100 << "; Moving tilt at this speed. \033[0m" << std::endl; + speed = this->info.tilt.max_speed*this->config.tilt.max_pwm/100; } set_moving_state_tilt(stopped); this->tilt->move_absolute_angle(angle, speed); - if (this->event_server->event_is_set(this->torque_moving)) - this->event_server->reset_event(this->torque_moving); + if (this->event_server->event_is_set(this->pwm_moving)) + this->event_server->reset_event(this->pwm_moving); //set_checking_hysteresis_tilt(0.0); } catch(CException &e) @@ -657,29 +657,29 @@ void CDynamixel_Pan_Tilt::move_relative_angle_tilt(double &angle, double &speed) } } -void CDynamixel_Pan_Tilt::move_torque(Dynamixel_pan_tilt_data &speed) +void CDynamixel_Pan_Tilt::move_pwm(Dynamixel_pan_tilt_data &speed) { - move_torque_pan(speed.pan); - move_torque_tilt(speed.tilt); + move_pwm_pan(speed.pan); + move_pwm_tilt(speed.tilt); } -void CDynamixel_Pan_Tilt::move_torque_pan(double &speed) +void CDynamixel_Pan_Tilt::move_pwm_pan(double &speed) { if (this->pan!=NULL) { set_moving_state_pan(stopped); - if (fabs(speed) > this->config.pan.max_torque) + if (fabs(speed) > this->config.pan.max_pwm) { - (speed > 0 ? speed = this->config.pan.max_torque : speed = -(this->config.pan.max_torque)); - std::cout << "\033[33m WARNING: The maximum pan' speed is " << this->config.pan.max_torque << "; Moving pan at this speed. \033[0m" << std::endl; + (speed > 0 ? speed = this->config.pan.max_pwm : speed = -(this->config.pan.max_pwm)); + std::cout << "\033[33m WARNING: The maximum pan' speed is " << this->config.pan.max_pwm << "; Moving pan at this speed. \033[0m" << std::endl; } set_checking_hysteresis_pan(calculate_checking_hysteresis_pan(fabs(speed))); // double hyst_aux = 0.0; - // bool change_ctrl_mode = (this->mode.pan == angle_ctrl); - if (this->mode.pan == angle_ctrl) + // bool change_ctrl_mode = (this->mode.pan == position_ctrl); + if (this->mode.pan == position_ctrl) { - this->mode.pan = torque_ctrl; + this->mode.pan = pwm_ctrl; this->config.pan.min_angle = -this->info.pan.center_angle; this->config.pan.max_angle = -this->info.pan.center_angle; } @@ -694,19 +694,19 @@ void CDynamixel_Pan_Tilt::move_torque_pan(double &speed) eff = speed; try { - set_moving_state_pan(positive_torque); - this->pan->move_torque(eff); - if (!this->event_server->event_is_set(this->torque_moving)) - this->event_server->set_event(this->torque_moving); + set_moving_state_pan(positive_pwm); + this->pan->move_pwm(eff); + if (!this->event_server->event_is_set(this->pwm_moving)) + this->event_server->set_event(this->pwm_moving); } catch (CException &e) { - std::cout << "\033[31m move pan torque Exception: " << e.what() << "\033[0m" << std::endl; + std::cout << "\033[31m move pan pwm Exception: " << e.what() << "\033[0m" << std::endl; stop(); this->mode.pan = this->pan->get_control_mode(); this->pan->get_position_range(&this->config.pan.min_angle, &this->config.pan.max_angle); - if (!this->event_server->event_is_set(this->torque_moving)) - this->event_server->set_event(this->torque_moving); + if (!this->event_server->event_is_set(this->pwm_moving)) + this->event_server->set_event(this->pwm_moving); throw; } // get_checking_hysteresis_pan(hyst_aux); @@ -714,19 +714,19 @@ void CDynamixel_Pan_Tilt::move_torque_pan(double &speed) // { // try // { - // set_moving_state_pan(positive_torque); - // this->pan->move_torque(speed); - // if (!this->event_server->event_is_set(this->torque_moving)) - // this->event_server->set_event(this->torque_moving); + // set_moving_state_pan(positive_pwm); + // this->pan->move_pwm(speed); + // if (!this->event_server->event_is_set(this->pwm_moving)) + // this->event_server->set_event(this->pwm_moving); // } // catch (CException &e) // { - // std::cout << "\033[31m move pan torque Exception: " << e.what() << "\033[0m" << std::endl; + // std::cout << "\033[31m move pan pwm Exception: " << e.what() << "\033[0m" << std::endl; // stop(); // this->mode.pan = this->pan->get_control_mode(); // this->pan->get_position_range(&this->config.pan.min_angle, &this->config.pan.max_angle); - // if (!this->event_server->event_is_set(this->torque_moving)) - // this->event_server->set_event(this->torque_moving); + // if (!this->event_server->event_is_set(this->pwm_moving)) + // this->event_server->set_event(this->pwm_moving); // throw; // } // } @@ -734,9 +734,9 @@ void CDynamixel_Pan_Tilt::move_torque_pan(double &speed) // { // set_moving_state_pan(stopped); // double sp = 0; - // this->pan->move_torque(sp); - // if (!this->event_server->event_is_set(this->torque_moving)) - // this->event_server->set_event(this->torque_moving); + // this->pan->move_pwm(sp); + // if (!this->event_server->event_is_set(this->pwm_moving)) + // this->event_server->set_event(this->pwm_moving); // // if (change_ctrl_mode) change_ctrl_mode = !change_ctrl_mode; // // double angle = this->max_angle.pan; // // double aux_speed = speed*this->info.pan.max_speed/100.0; @@ -755,19 +755,19 @@ void CDynamixel_Pan_Tilt::move_torque_pan(double &speed) eff = -eff; try { - set_moving_state_pan(negative_torque); - this->pan->move_torque(eff); - if (!this->event_server->event_is_set(this->torque_moving)) - this->event_server->set_event(this->torque_moving); + set_moving_state_pan(negative_pwm); + this->pan->move_pwm(eff); + if (!this->event_server->event_is_set(this->pwm_moving)) + this->event_server->set_event(this->pwm_moving); } catch (CException &e) { - std::cout << "\033[31m move pan torque Exception: " << e.what() << "\033[0m" << std::endl; + std::cout << "\033[31m move pan pwm Exception: " << e.what() << "\033[0m" << std::endl; stop(); this->mode.pan = this->pan->get_control_mode(); this->pan->get_position_range(&this->config.pan.min_angle, &this->config.pan.max_angle); - if (!this->event_server->event_is_set(this->torque_moving)) - this->event_server->set_event(this->torque_moving); + if (!this->event_server->event_is_set(this->pwm_moving)) + this->event_server->set_event(this->pwm_moving); throw; } // get_checking_hysteresis_pan(hyst_aux); @@ -775,19 +775,19 @@ void CDynamixel_Pan_Tilt::move_torque_pan(double &speed) // { // try // { - // set_moving_state_pan(negative_torque); - // this->pan->move_torque(speed); - // if (!this->event_server->event_is_set(this->torque_moving)) - // this->event_server->set_event(this->torque_moving); + // set_moving_state_pan(negative_pwm); + // this->pan->move_pwm(speed); + // if (!this->event_server->event_is_set(this->pwm_moving)) + // this->event_server->set_event(this->pwm_moving); // } // catch (CException &e) // { - // std::cout << "\033[31m move pan torque Exception: " << e.what() << "\033[0m" << std::endl; + // std::cout << "\033[31m move pan pwm Exception: " << e.what() << "\033[0m" << std::endl; // stop(); // this->mode.pan = this->pan->get_control_mode(); // this->pan->get_position_range(&this->config.pan.min_angle, &this->config.pan.max_angle); - // if (!this->event_server->event_is_set(this->torque_moving)) - // this->event_server->set_event(this->torque_moving); + // if (!this->event_server->event_is_set(this->pwm_moving)) + // this->event_server->set_event(this->pwm_moving); // throw; // } // } @@ -795,9 +795,9 @@ void CDynamixel_Pan_Tilt::move_torque_pan(double &speed) // { // set_moving_state_pan(stopped); // double sp = 0; - // this->pan->move_torque(sp); - // if (!this->event_server->event_is_set(this->torque_moving)) - // this->event_server->set_event(this->torque_moving); + // this->pan->move_pwm(sp); + // if (!this->event_server->event_is_set(this->pwm_moving)) + // this->event_server->set_event(this->pwm_moving); // // if (change_ctrl_mode) change_ctrl_mode = !change_ctrl_mode; // // double angle = this->min_angle.pan; // // double aux_speed = speed*this->info.pan.max_speed/100.0; @@ -810,25 +810,25 @@ void CDynamixel_Pan_Tilt::move_torque_pan(double &speed) try { set_moving_state_pan(stopped); - this->pan->move_torque(speed); - if (!this->event_server->event_is_set(this->torque_moving)) - this->event_server->set_event(this->torque_moving); + this->pan->move_pwm(speed); + if (!this->event_server->event_is_set(this->pwm_moving)) + this->event_server->set_event(this->pwm_moving); } catch (CException &e) { - std::cout << "\033[31m move pan torque Exception: " << e.what() << "\033[0m" << std::endl; + std::cout << "\033[31m move pan pwm Exception: " << e.what() << "\033[0m" << std::endl; stop(); this->mode.pan = this->pan->get_control_mode(); this->pan->get_position_range(&this->config.pan.min_angle, &this->config.pan.max_angle); - if (!this->event_server->event_is_set(this->torque_moving)) - this->event_server->set_event(this->torque_moving); + if (!this->event_server->event_is_set(this->pwm_moving)) + this->event_server->set_event(this->pwm_moving); throw; } } // if (change_ctrl_mode) // { - // this->mode.pan = torque_ctrl; + // this->mode.pan = pwm_ctrl; // this->config.pan.min_angle = -this->info.pan.center_angle; // this->config.pan.max_angle = -this->info.pan.center_angle; // } @@ -840,23 +840,23 @@ void CDynamixel_Pan_Tilt::move_torque_pan(double &speed) } } -void CDynamixel_Pan_Tilt::move_torque_tilt(double &speed) +void CDynamixel_Pan_Tilt::move_pwm_tilt(double &speed) { if (this->tilt!=NULL) { set_moving_state_tilt(stopped); - if (fabs(speed) > this->config.tilt.max_torque) + if (fabs(speed) > this->config.tilt.max_pwm) { - (speed > 0 ? speed = this->config.tilt.max_torque : speed = -(this->config.tilt.max_torque)); - std::cout << "\033[33m WARNING: The maximum tilt' speed is " << this->config.tilt.max_torque << "; Moving tilt at this speed. \033[0m" << std::endl; + (speed > 0 ? speed = this->config.tilt.max_pwm : speed = -(this->config.tilt.max_pwm)); + std::cout << "\033[33m WARNING: The maximum tilt' speed is " << this->config.tilt.max_pwm << "; Moving tilt at this speed. \033[0m" << std::endl; } set_checking_hysteresis_tilt(calculate_checking_hysteresis_tilt(fabs(speed))); //double hyst_aux = 0.0; - //bool change_ctrl_mode = (this->mode.tilt == angle_ctrl); - if (this->mode.tilt == angle_ctrl) + //bool change_ctrl_mode = (this->mode.tilt == position_ctrl); + if (this->mode.tilt == position_ctrl) { - this->mode.tilt = torque_ctrl; + this->mode.tilt = pwm_ctrl; this->config.tilt.min_angle = -this->info.tilt.center_angle; this->config.tilt.max_angle = -this->info.tilt.center_angle; } @@ -872,19 +872,19 @@ void CDynamixel_Pan_Tilt::move_torque_tilt(double &speed) eff = speed; try { - set_moving_state_tilt(positive_torque); - this->tilt->move_torque(eff); - if (!this->event_server->event_is_set(this->torque_moving)) - this->event_server->set_event(this->torque_moving); + set_moving_state_tilt(positive_pwm); + this->tilt->move_pwm(eff); + if (!this->event_server->event_is_set(this->pwm_moving)) + this->event_server->set_event(this->pwm_moving); } catch (CException &e) { - std::cout << "\033[31m move tilt torque Exception: " << e.what() << "\033[0m" << std::endl; + std::cout << "\033[31m move tilt pwm Exception: " << e.what() << "\033[0m" << std::endl; stop(); this->mode.tilt = this->tilt->get_control_mode(); this->tilt->get_position_range(&this->config.tilt.min_angle, &this->config.tilt.max_angle); - if (!this->event_server->event_is_set(this->torque_moving)) - this->event_server->set_event(this->torque_moving); + if (!this->event_server->event_is_set(this->pwm_moving)) + this->event_server->set_event(this->pwm_moving); throw; } @@ -892,19 +892,19 @@ void CDynamixel_Pan_Tilt::move_torque_tilt(double &speed) // { // try // { - // set_moving_state_tilt(positive_torque); - // this->tilt->move_torque(speed); - // if (!this->event_server->event_is_set(this->torque_moving)) - // this->event_server->set_event(this->torque_moving); + // set_moving_state_tilt(positive_pwm); + // this->tilt->move_pwm(speed); + // if (!this->event_server->event_is_set(this->pwm_moving)) + // this->event_server->set_event(this->pwm_moving); // } // catch (CException &e) // { - // std::cout << "\033[31m move tilt torque Exception: " << e.what() << "\033[0m" << std::endl; + // std::cout << "\033[31m move tilt pwm Exception: " << e.what() << "\033[0m" << std::endl; // stop(); // this->mode.tilt = this->tilt->get_control_mode(); // this->tilt->get_position_range(&this->config.tilt.min_angle, &this->config.tilt.max_angle); - // if (!this->event_server->event_is_set(this->torque_moving)) - // this->event_server->set_event(this->torque_moving); + // if (!this->event_server->event_is_set(this->pwm_moving)) + // this->event_server->set_event(this->pwm_moving); // throw; // } // } @@ -912,9 +912,9 @@ void CDynamixel_Pan_Tilt::move_torque_tilt(double &speed) // { // set_moving_state_tilt(stopped); // double sp = 0; - // this->tilt->move_torque(sp); - // if (!this->event_server->event_is_set(this->torque_moving)) - // this->event_server->set_event(this->torque_moving); + // this->tilt->move_pwm(sp); + // if (!this->event_server->event_is_set(this->pwm_moving)) + // this->event_server->set_event(this->pwm_moving); // // if (change_ctrl_mode) change_ctrl_mode = !change_ctrl_mode; // // double angle = this->max_angle.tilt; // // double aux_speed = speed*this->info.tilt.max_speed/100.0; @@ -933,19 +933,19 @@ void CDynamixel_Pan_Tilt::move_torque_tilt(double &speed) eff = -eff; try { - set_moving_state_tilt(negative_torque); - this->tilt->move_torque(eff); - if (!this->event_server->event_is_set(this->torque_moving)) - this->event_server->set_event(this->torque_moving); + set_moving_state_tilt(negative_pwm); + this->tilt->move_pwm(eff); + if (!this->event_server->event_is_set(this->pwm_moving)) + this->event_server->set_event(this->pwm_moving); } catch (CException &e) { - std::cout << "\033[31m move tilt torque Exception: " << e.what() << "\033[0m" << std::endl; + std::cout << "\033[31m move tilt pwm Exception: " << e.what() << "\033[0m" << std::endl; stop(); this->mode.tilt = this->tilt->get_control_mode(); this->tilt->get_position_range(&this->config.tilt.min_angle, &this->config.tilt.max_angle); - if (!this->event_server->event_is_set(this->torque_moving)) - this->event_server->set_event(this->torque_moving); + if (!this->event_server->event_is_set(this->pwm_moving)) + this->event_server->set_event(this->pwm_moving); throw; } // get_checking_hysteresis_tilt(hyst_aux); @@ -953,19 +953,19 @@ void CDynamixel_Pan_Tilt::move_torque_tilt(double &speed) // { // try // { - // set_moving_state_tilt(negative_torque); - // this->tilt->move_torque(speed); - // if (!this->event_server->event_is_set(this->torque_moving)) - // this->event_server->set_event(this->torque_moving); + // set_moving_state_tilt(negative_pwm); + // this->tilt->move_pwm(speed); + // if (!this->event_server->event_is_set(this->pwm_moving)) + // this->event_server->set_event(this->pwm_moving); // } // catch (CException &e) // { - // std::cout << "\033[31m move tilt torque Exception: " << e.what() << "\033[0m" << std::endl; + // std::cout << "\033[31m move tilt pwm Exception: " << e.what() << "\033[0m" << std::endl; // stop(); // this->mode.tilt = this->tilt->get_control_mode(); // this->tilt->get_position_range(&this->config.tilt.min_angle, &this->config.tilt.max_angle); - // if (!this->event_server->event_is_set(this->torque_moving)) - // this->event_server->set_event(this->torque_moving); + // if (!this->event_server->event_is_set(this->pwm_moving)) + // this->event_server->set_event(this->pwm_moving); // throw; // } // } @@ -973,9 +973,9 @@ void CDynamixel_Pan_Tilt::move_torque_tilt(double &speed) // { // set_moving_state_tilt(stopped); // double sp = 0; - // this->tilt->move_torque(sp); - // if (!this->event_server->event_is_set(this->torque_moving)) - // this->event_server->set_event(this->torque_moving); + // this->tilt->move_pwm(sp); + // if (!this->event_server->event_is_set(this->pwm_moving)) + // this->event_server->set_event(this->pwm_moving); // // if (change_ctrl_mode) change_ctrl_mode = !change_ctrl_mode; // // double angle = this->min_angle.tilt; // // double aux_speed = speed*this->info.tilt.max_speed/100.0; @@ -988,24 +988,24 @@ void CDynamixel_Pan_Tilt::move_torque_tilt(double &speed) try { set_moving_state_tilt(stopped); - this->tilt->move_torque(speed); - if (!this->event_server->event_is_set(this->torque_moving)) - this->event_server->set_event(this->torque_moving); + this->tilt->move_pwm(speed); + if (!this->event_server->event_is_set(this->pwm_moving)) + this->event_server->set_event(this->pwm_moving); } catch (CException &e) { - std::cout << "\033[31m move tilt torque Exception: " << e.what() << "\033[0m" << std::endl; + std::cout << "\033[31m move tilt pwm Exception: " << e.what() << "\033[0m" << std::endl; stop(); this->mode.tilt = this->tilt->get_control_mode(); this->tilt->get_position_range(&this->config.tilt.min_angle, &this->config.tilt.max_angle); - if (!this->event_server->event_is_set(this->torque_moving)) - this->event_server->set_event(this->torque_moving); + if (!this->event_server->event_is_set(this->pwm_moving)) + this->event_server->set_event(this->pwm_moving); throw; } } // if (change_ctrl_mode) // { - // this->mode.tilt = torque_ctrl; + // this->mode.tilt = pwm_ctrl; // this->config.tilt.min_angle = -this->info.tilt.center_angle; // this->config.tilt.max_angle = -this->info.tilt.center_angle; // } @@ -1025,7 +1025,7 @@ void *CDynamixel_Pan_Tilt::checking_angle_limits(void *arg) CEventServer *event_server=CEventServer::instance(); event_list.push_back(pan_tilt->exiting); - event_list.push_back(pan_tilt->torque_moving); + event_list.push_back(pan_tilt->pwm_moving); int event_id; @@ -1038,14 +1038,14 @@ void *CDynamixel_Pan_Tilt::checking_angle_limits(void *arg) { pthread_exit(NULL); } - else if (event_id == 1)// ==TORQUE_MOVING + else if (event_id == 1)// ==PWM_MOVING { bool is_moving; Dynamixel_pan_tilt_data pos; - pan_tilt->is_torque_moving(is_moving); - Torque_moving_state pan_state; + pan_tilt->is_pwm_moving(is_moving); + Pwm_moving_state pan_state; pan_tilt->get_moving_state_pan(pan_state); - Torque_moving_state tilt_state; + Pwm_moving_state tilt_state; pan_tilt->get_moving_state_tilt(tilt_state); double hyst_aux = 0.0; @@ -1053,7 +1053,7 @@ void *CDynamixel_Pan_Tilt::checking_angle_limits(void *arg) { pos = pan_tilt->get_position(); pan_tilt->get_checking_hysteresis_pan(hyst_aux); - if ((pan_state == positive_torque) && (pos.pan >= (pan_tilt->max_angle.pan - hyst_aux))) + if ((pan_state == positive_pwm) && (pos.pan >= (pan_tilt->max_angle.pan - hyst_aux))) { double angle_diff = pan_tilt->max_angle.pan - pos.pan; double eff = pan_tilt->max_safe_effort_pan(angle_diff); @@ -1062,11 +1062,11 @@ void *CDynamixel_Pan_Tilt::checking_angle_limits(void *arg) try { - pan_tilt->pan->move_torque(eff); + pan_tilt->pan->move_pwm(eff); } catch (CException &e) { - std::cout << "\033[31m move pan torque Exception on checking_angle_limits: " << e.what() << "\033[0m" << std::endl; + std::cout << "\033[31m move pan pwm Exception on checking_angle_limits: " << e.what() << "\033[0m" << std::endl; pan_tilt->stop(); throw; } @@ -1078,7 +1078,7 @@ void *CDynamixel_Pan_Tilt::checking_angle_limits(void *arg) // std::cout << "pan out!" << std::endl; // pan_tilt->print_pan_tilt_data(pos); } - else if ((pan_state == negative_torque) && (pos.pan <= (pan_tilt->min_angle.pan + hyst_aux))) + else if ((pan_state == negative_pwm) && (pos.pan <= (pan_tilt->min_angle.pan + hyst_aux))) { double angle_diff = pos.pan - pan_tilt->min_angle.pan; double eff = pan_tilt->max_safe_effort_pan(angle_diff); @@ -1087,11 +1087,11 @@ void *CDynamixel_Pan_Tilt::checking_angle_limits(void *arg) try { - pan_tilt->pan->move_torque(eff); + pan_tilt->pan->move_pwm(eff); } catch (CException &e) { - std::cout << "\033[31m move pan torque Exception on checking_angle_limits: " << e.what() << "\033[0m" << std::endl; + std::cout << "\033[31m move pan pwm Exception on checking_angle_limits: " << e.what() << "\033[0m" << std::endl; pan_tilt->stop(); throw; } @@ -1104,7 +1104,7 @@ void *CDynamixel_Pan_Tilt::checking_angle_limits(void *arg) } pan_tilt->get_checking_hysteresis_tilt(hyst_aux); - if ((tilt_state == positive_torque) && (pos.tilt >= (pan_tilt->max_angle.tilt - hyst_aux))) + if ((tilt_state == positive_pwm) && (pos.tilt >= (pan_tilt->max_angle.tilt - hyst_aux))) { double angle_diff = pan_tilt->max_angle.tilt - pos.tilt; double eff = pan_tilt->max_safe_effort_tilt(angle_diff); @@ -1113,11 +1113,11 @@ void *CDynamixel_Pan_Tilt::checking_angle_limits(void *arg) try { - pan_tilt->tilt->move_torque(eff); + pan_tilt->tilt->move_pwm(eff); } catch (CException &e) { - std::cout << "\033[31m move tilt torque Exception on checking_angle_limits: " << e.what() << "\033[0m" << std::endl; + std::cout << "\033[31m move tilt pwm Exception on checking_angle_limits: " << e.what() << "\033[0m" << std::endl; pan_tilt->stop(); throw; } @@ -1128,7 +1128,7 @@ void *CDynamixel_Pan_Tilt::checking_angle_limits(void *arg) // std::cout << "tilt out!" << std::endl; // pan_tilt->print_pan_tilt_data(pos); } - else if ((tilt_state == negative_torque) && (pos.tilt <= (pan_tilt->min_angle.tilt + hyst_aux))) + else if ((tilt_state == negative_pwm) && (pos.tilt <= (pan_tilt->min_angle.tilt + hyst_aux))) { double angle_diff = pos.tilt - pan_tilt->min_angle.tilt; double eff = pan_tilt->max_safe_effort_tilt(angle_diff); @@ -1137,11 +1137,11 @@ void *CDynamixel_Pan_Tilt::checking_angle_limits(void *arg) try { - pan_tilt->tilt->move_torque(eff); + pan_tilt->tilt->move_pwm(eff); } catch (CException &e) { - std::cout << "\033[31m move tilt torque Exception on checking_angle_limits: " << e.what() << "\033[0m" << std::endl; + std::cout << "\033[31m move tilt pwm Exception on checking_angle_limits: " << e.what() << "\033[0m" << std::endl; pan_tilt->stop(); throw; } @@ -1153,7 +1153,7 @@ void *CDynamixel_Pan_Tilt::checking_angle_limits(void *arg) // pan_tilt->print_pan_tilt_data(pos); } usleep(CHECKING_TIME_INTERVAL); - pan_tilt->is_torque_moving(is_moving); + pan_tilt->is_pwm_moving(is_moving); pan_tilt->get_moving_state_pan(pan_state); pan_tilt->get_moving_state_tilt(tilt_state); if (event_server->event_is_set(pan_tilt->exiting)) @@ -1177,7 +1177,7 @@ void CDynamixel_Pan_Tilt::stop(void) { this->pan->stop(); this->tilt->stop(); - reset_torque_moving_state(); + reset_pwm_moving_state(); } catch (CException &e) { @@ -1188,7 +1188,7 @@ void CDynamixel_Pan_Tilt::stop(void) //Dynamixel_pan_tilt_data dat; //dat.pan = 0.0; //dat.tilt = 0.0; - //move_torque(dat); + //move_pwm(dat); //set_checking_hysteresis_pan(0.0); //set_checking_hysteresis_tilt(0.0); @@ -1217,13 +1217,13 @@ void CDynamixel_Pan_Tilt::update_config(void) this->pan->get_position_range(&this->config.pan.min_angle, &this->config.pan.max_angle); this->config.pan.max_temperature = this->pan->get_temperature_limit(); this->pan->get_voltage_limits(&this->config.pan.min_voltage, &this->config.pan.max_voltage); - this->config.pan.max_torque = this->pan->get_max_torque(); + this->config.pan.max_pwm = this->pan->get_max_pwm(); this->config.pan.punch = this->pan->get_punch(); this->tilt->get_position_range(&this->config.tilt.min_angle, &this->config.tilt.max_angle); this->config.tilt.max_temperature = this->tilt->get_temperature_limit(); this->tilt->get_voltage_limits(&this->config.tilt.min_voltage, &this->config.tilt.max_voltage); - this->config.tilt.max_torque = this->tilt->get_max_torque(); + this->config.tilt.max_pwm = this->tilt->get_max_pwm(); this->config.tilt.punch = this->tilt->get_punch(); } catch(CDynamixelAlarmException &e) @@ -1344,7 +1344,7 @@ void CDynamixel_Pan_Tilt::default_parameters(void) this->config.pan.max_temperature=0.0; this->config.pan.max_voltage=0.0; this->config.pan.min_voltage=0.0; - this->config.pan.max_torque=0.0; + this->config.pan.max_pwm=0.0; this->min_angle.pan=0.0; this->max_angle.pan=0.0; @@ -1370,10 +1370,10 @@ void CDynamixel_Pan_Tilt::default_parameters(void) this->config.tilt.max_temperature=0.0; this->config.tilt.max_voltage=0.0; this->config.tilt.min_voltage=0.0; - this->config.tilt.max_torque=0.0; + this->config.tilt.max_pwm=0.0; this->min_angle.tilt=0.0; this->max_angle.tilt=0.0; - reset_torque_moving_state(); + reset_pwm_moving_state(); set_checking_hysteresis_pan(0.0); set_checking_hysteresis_tilt(0.0); this->checking_hysteresis_slope.pan = 0.0; @@ -1514,7 +1514,7 @@ void CDynamixel_Pan_Tilt::get_pan_tilt_config(Dynamixel_pan_tilt_config &config) config.pan.max_temperature = this->config.pan.max_temperature; config.pan.max_voltage = this->config.pan.max_voltage; config.pan.min_voltage = this->config.pan.min_voltage; - config.pan.max_torque = this->config.pan.max_torque; + config.pan.max_pwm = this->config.pan.max_pwm; config.pan.punch = this->config.pan.punch; config.tilt.max_angle = this->config.tilt.max_angle; @@ -1522,7 +1522,7 @@ void CDynamixel_Pan_Tilt::get_pan_tilt_config(Dynamixel_pan_tilt_config &config) config.tilt.max_temperature = this->config.tilt.max_temperature; config.tilt.max_voltage = this->config.tilt.max_voltage; config.tilt.min_voltage = this->config.tilt.min_voltage; - config.tilt.max_torque = this->config.tilt.max_torque; + config.tilt.max_pwm = this->config.tilt.max_pwm; config.tilt.punch = this->config.tilt.punch; } @@ -1551,7 +1551,7 @@ void CDynamixel_Pan_Tilt::get_pan_tilt_info(Dynamixel_pan_tilt_info &info) info.tilt.id = this->info.tilt.id; } -void CDynamixel_Pan_Tilt::reset_torque_moving_state(void) +void CDynamixel_Pan_Tilt::reset_pwm_moving_state(void) { pthread_mutex_lock(&(this->mut)); this->moving_state.pan = stopped; @@ -1559,38 +1559,38 @@ void CDynamixel_Pan_Tilt::reset_torque_moving_state(void) pthread_mutex_unlock(&(this->mut)); } -void CDynamixel_Pan_Tilt::is_torque_moving(bool &b) +void CDynamixel_Pan_Tilt::is_pwm_moving(bool &b) { pthread_mutex_lock(&(this->mut)); b = (this->moving_state.pan != stopped || this->moving_state.tilt != stopped); pthread_mutex_unlock(&(this->mut)); } -void CDynamixel_Pan_Tilt::set_moving_state_pan(Torque_moving_state tms) +void CDynamixel_Pan_Tilt::set_moving_state_pan(Pwm_moving_state pms) { pthread_mutex_lock(&(this->mut)); - this->moving_state.pan = tms; + this->moving_state.pan = pms; pthread_mutex_unlock(&(this->mut)); } -void CDynamixel_Pan_Tilt::set_moving_state_tilt(Torque_moving_state tms) +void CDynamixel_Pan_Tilt::set_moving_state_tilt(Pwm_moving_state pms) { pthread_mutex_lock(&(this->mut)); - this->moving_state.tilt = tms; + this->moving_state.tilt = pms; pthread_mutex_unlock(&(this->mut)); } -void CDynamixel_Pan_Tilt::get_moving_state_pan(Torque_moving_state &tms) +void CDynamixel_Pan_Tilt::get_moving_state_pan(Pwm_moving_state &pms) { pthread_mutex_lock(&(this->mut)); - tms = this->moving_state.pan; + pms = this->moving_state.pan; pthread_mutex_unlock(&(this->mut)); } -void CDynamixel_Pan_Tilt::get_moving_state_tilt(Torque_moving_state &tms) +void CDynamixel_Pan_Tilt::get_moving_state_tilt(Pwm_moving_state &pms) { pthread_mutex_lock(&(this->mut)); - tms = this->moving_state.tilt; + pms = this->moving_state.tilt; pthread_mutex_unlock(&(this->mut)); } @@ -1683,15 +1683,15 @@ Dynamixel_pan_tilt_data CDynamixel_Pan_Tilt::get_current_speed(void) throw CDynamixel_Pan_TiltException(_HERE_,"The dynamixel pan&tilt is not properly configured. Speed not get"); } -Dynamixel_pan_tilt_data CDynamixel_Pan_Tilt::get_current_effort(void) +Dynamixel_pan_tilt_data CDynamixel_Pan_Tilt::get_current_pwm(void) { if (this->pan!=NULL && this->tilt!=NULL) { try { Dynamixel_pan_tilt_data data; - data.pan = this->pan->get_current_effort(); - data.tilt = this->tilt->get_current_effort(); + data.pan = this->pan->get_current_pwm(); + data.tilt = this->tilt->get_current_pwm(); return data; } catch(CException &e) @@ -1704,52 +1704,52 @@ Dynamixel_pan_tilt_data CDynamixel_Pan_Tilt::get_current_effort(void) throw CDynamixel_Pan_TiltException(_HERE_,"The dynamixel pan&tilt is not properly configured. Effort not get"); } - void CDynamixel_Pan_Tilt::set_max_torque(Dynamixel_pan_tilt_data &torque) + void CDynamixel_Pan_Tilt::set_max_pwm(Dynamixel_pan_tilt_data &pwm) { if (this->pan!=NULL && this->tilt!=NULL) { try { - this->pan->set_max_torque(torque.pan); - this->pan->set_limit_torque(torque.pan); - this->tilt->set_max_torque(torque.tilt); - this->tilt->set_limit_torque(torque.tilt); + this->pan->set_max_pwm(pwm.pan); + this->pan->set_pwm_limit(pwm.pan); + this->tilt->set_max_pwm(pwm.tilt); + this->tilt->set_pwm_limit(pwm.tilt); } catch(CException &e) { - std::cout << "\033[31m Set max torque exception: " << e.what() << "\033[0m" << std::endl; - torque.pan = this->pan->get_limit_torque(); - torque.tilt = this->tilt->get_limit_torque(); - throw CDynamixel_Pan_TiltException(_HERE_, "The dynamixel pan&tilt max torque hasn't been set properly."); + std::cout << "\033[31m Set max pwm exception: " << e.what() << "\033[0m" << std::endl; + pwm.pan = this->pan->get_pwm_limit(); + pwm.tilt = this->tilt->get_pwm_limit(); + throw CDynamixel_Pan_TiltException(_HERE_, "The dynamixel pan&tilt max pwm hasn't been set properly."); } } else { - torque.pan = 0; - torque.tilt = 0; - throw CDynamixel_Pan_TiltException(_HERE_,"The dynamixel pan&tilt is not properly configured. Max torque not set"); + pwm.pan = 0; + pwm.tilt = 0; + throw CDynamixel_Pan_TiltException(_HERE_,"The dynamixel pan&tilt is not properly configured. Max pwm not set"); } } -Dynamixel_pan_tilt_data CDynamixel_Pan_Tilt::get_limit_torque(void) +Dynamixel_pan_tilt_data CDynamixel_Pan_Tilt::get_pwm_limit(void) { if (this->pan!=NULL && this->tilt!=NULL) { try { Dynamixel_pan_tilt_data data; - data.pan = this->pan->get_limit_torque(); - data.tilt = this->tilt->get_limit_torque(); + data.pan = this->pan->get_pwm_limit(); + data.tilt = this->tilt->get_pwm_limit(); return data; } catch(CException &e) { - std::cout << "\033[31m Get limit torque exception: " << e.what() << "\033[0m" << std::endl; + std::cout << "\033[31m Get limit pwm exception: " << e.what() << "\033[0m" << std::endl; throw; } } else - throw CDynamixel_Pan_TiltException(_HERE_,"The dynamixel pan&tilt is not properly configured. Torque limit not get"); + throw CDynamixel_Pan_TiltException(_HERE_,"The dynamixel pan&tilt is not properly configured. pwm limit not get"); } Dynamixel_pan_tilt_data CDynamixel_Pan_Tilt::get_max_angle_limit(void) diff --git a/src/examples/test_dynamixel_pan_tilt.cpp b/src/examples/test_dynamixel_pan_tilt.cpp index 9ff7e47be41d06a7ff13df5f79a4986ae84bcf71..dddf053b374ffa49ed74cd95cb5231eee7495187 100644 --- a/src/examples/test_dynamixel_pan_tilt.cpp +++ b/src/examples/test_dynamixel_pan_tilt.cpp @@ -80,7 +80,7 @@ * Done * * - * ------------------------MOVE TORQUE-------------------------- + * ------------------------MOVE pwm-------------------------- * Current angle: (-0.439883 , 0.146628) * Desired effort: (-100 , -100) * Moving... @@ -111,7 +111,7 @@ * Done * * - * ------------------------MOVE TORQUE-------------------------- + * ------------------------MOVE pwm-------------------------- * Current angle: (94.5748 , 59.9707) * Desired effort: (-90 , -90) * Moving... @@ -215,7 +215,7 @@ int main(int argc, char *argv[]) CDynamixel_Pan_Tilt::read_config(config_file, xml_limits); pan_tilt->print_pan_tilt_data(xml_limits.max_angle); pan_tilt->print_pan_tilt_data(xml_limits.min_angle); - pan_tilt->print_pan_tilt_data(xml_limits.max_torque); + pan_tilt->print_pan_tilt_data(xml_limits.max_pwm); //*/ @@ -227,7 +227,7 @@ int main(int argc, char *argv[]) double t; double uperiod = time_interval*1000000.0/2.0; double timeout = max_time_sec/time_interval; - double torque_timeout = 85.0; + double pwm_timeout = 85.0; desired_speed.pan = 354; desired_speed.tilt = 354; @@ -282,11 +282,11 @@ int main(int argc, char *argv[]) //*/ ///////////////////////////////////////////////////////////////////////// - ////MOVE TORQUE + ////MOVE pwm ///////////////////////////////////////////////////////////////////////// ///* std::cout << std::endl << std::endl; - std::cout << "------------------------MOVE TORQUE--------------------------" << std::endl; + std::cout << "------------------------MOVE pwm--------------------------" << std::endl; desired_effort.pan = -100; desired_effort.tilt = -100; @@ -299,19 +299,19 @@ int main(int argc, char *argv[]) //pan_tilt->print_pan_tilt_data(desired_effort); - pan_tilt->move_torque(desired_effort); + pan_tilt->move_pwm(desired_effort); std::cout << "Moving..." << std::endl; std::cout << "Moving effort: "; pan_tilt->print_pan_tilt_data(desired_effort); - //torque_timeout = 2.0; + //pwm_timeout = 2.0; t=0.0; - while(t<torque_timeout) + while(t<pwm_timeout) { //pos = pan_tilt->get_position(); //pan_tilt->print_current_position(); - // pan_tilt->move_torque(desired_effort); + // pan_tilt->move_pwm(desired_effort); // pan_tilt->print_current_position(); usleep(uperiod); t++; @@ -384,11 +384,11 @@ int main(int argc, char *argv[]) //*/ ///////////////////////////////////////////////////////////////////////// - ////MOVE TORQUE + ////MOVE pwm ///////////////////////////////////////////////////////////////////////// ///* std::cout << std::endl << std::endl; - std::cout << "------------------------MOVE TORQUE--------------------------" << std::endl; + std::cout << "------------------------MOVE pwm--------------------------" << std::endl; desired_effort.pan = -80; desired_effort.tilt = -80; @@ -400,16 +400,16 @@ int main(int argc, char *argv[]) std::cout << desired_effort; //pan_tilt->print_pan_tilt_data(desired_effort); - pan_tilt->move_torque(desired_effort); + pan_tilt->move_pwm(desired_effort); std::cout << "Moving..." << std::endl; std::cout << "Moving effort: "; pan_tilt->print_pan_tilt_data(desired_effort); - //torque_timeout = 45.0; + //pwm_timeout = 45.0; t=0.0; - while(t<torque_timeout) + while(t<pwm_timeout) { //pos = pan_tilt->get_position(); //pan_tilt->print_current_position(); @@ -430,7 +430,7 @@ int main(int argc, char *argv[]) //*/ std::cout << std::endl << std::endl; - std::cout << "------------------------MOVE TORQUE--------------------------" << std::endl; + std::cout << "------------------------MOVE pwm--------------------------" << std::endl; desired_effort.pan = 60; desired_effort.tilt = 60; @@ -442,16 +442,16 @@ int main(int argc, char *argv[]) std::cout << desired_effort; //pan_tilt->print_pan_tilt_data(desired_effort); - pan_tilt->move_torque(desired_effort); + pan_tilt->move_pwm(desired_effort); std::cout << "Moving..." << std::endl; std::cout << "Moving effort: "; pan_tilt->print_pan_tilt_data(desired_effort); - //torque_timeout = 45.0; + //pwm_timeout = 45.0; t=0.0; - while(t<torque_timeout) + while(t<pwm_timeout) { //pos = pan_tilt->get_position(); //pan_tilt->print_current_position(); @@ -471,7 +471,7 @@ int main(int argc, char *argv[]) sleep(1); std::cout << std::endl << std::endl; - std::cout << "------------------------MOVE TORQUE--------------------------" << std::endl; + std::cout << "------------------------MOVE pwm--------------------------" << std::endl; desired_effort.pan = -40; desired_effort.tilt = -40; @@ -483,16 +483,16 @@ int main(int argc, char *argv[]) std::cout << desired_effort; //pan_tilt->print_pan_tilt_data(desired_effort); - pan_tilt->move_torque(desired_effort); + pan_tilt->move_pwm(desired_effort); std::cout << "Moving..." << std::endl; std::cout << "Moving effort: "; pan_tilt->print_pan_tilt_data(desired_effort); - //torque_timeout = 45.0; + //pwm_timeout = 45.0; t=0.0; - while(t<torque_timeout) + while(t<pwm_timeout) { //pos = pan_tilt->get_position(); //pan_tilt->print_current_position(); @@ -512,7 +512,7 @@ int main(int argc, char *argv[]) sleep(1); std::cout << std::endl << std::endl; - std::cout << "------------------------MOVE TORQUE--------------------------" << std::endl; + std::cout << "------------------------MOVE pwm--------------------------" << std::endl; desired_effort.pan = 20; desired_effort.tilt = 20; @@ -524,16 +524,16 @@ int main(int argc, char *argv[]) std::cout << desired_effort; //pan_tilt->print_pan_tilt_data(desired_effort); - pan_tilt->move_torque(desired_effort); + pan_tilt->move_pwm(desired_effort); std::cout << "Moving..." << std::endl; std::cout << "Moving effort: "; pan_tilt->print_pan_tilt_data(desired_effort); - //torque_timeout = 45.0; + //pwm_timeout = 45.0; t=0.0; - while(t<torque_timeout) + while(t<pwm_timeout) { //pos = pan_tilt->get_position(); //pan_tilt->print_current_position(); diff --git a/src/xml/dyn_pan_tilt_config_AX12plus.xml b/src/xml/dyn_pan_tilt_config_AX12plus.xml index 08f72b6a0c45133b2f4cf83d18e6068c0d4994fd..2e12a1e0183273db21cf7316bc522ca744754e64 100644 --- a/src/xml/dyn_pan_tilt_config_AX12plus.xml +++ b/src/xml/dyn_pan_tilt_config_AX12plus.xml @@ -7,7 +7,7 @@ <temp_limit>90</temp_limit> <max_voltage>19</max_voltage> <min_voltage>6</min_voltage> - <max_torque>100</max_torque> + <max_pwm>100</max_pwm> <cw_comp_margin>2</cw_comp_margin> <ccw_comp_margin>2</ccw_comp_margin> <cw_comp_slope>64</cw_comp_slope> diff --git a/src/xml/dynamixel_pan_tilt_cfg_file.xsd b/src/xml/dynamixel_pan_tilt_cfg_file.xsd index 7c4a23f54a3aab7ace5bb699e9556ac2905f626e..a35fcbcba94bc8d57d513a071126d76bd254958d 100644 --- a/src/xml/dynamixel_pan_tilt_cfg_file.xsd +++ b/src/xml/dynamixel_pan_tilt_cfg_file.xsd @@ -32,7 +32,7 @@ copyright : not copyrighted - public domain </xsd:element> <xsd:element name="min_voltage" type="xsd:float"> </xsd:element> - <xsd:element name="max_torque" type="xsd:float" minOccurs="0" maxOccurs="2"> + <xsd:element name="max_pwm" type="xsd:float" minOccurs="0" maxOccurs="2"> </xsd:element> <xsd:element name="cw_comp_margin" type="xsd:unsignedByte" maxOccurs="2"> </xsd:element>