@@ -117,8 +117,6 @@ class HeadMover {
117117 // load parameters from config
118118 auto param_listener = std::make_shared<move_head::ParamListener>(node_);
119119 params_ = param_listener->get_params ();
120- pan_speed_ = params_.look_at .pan_speed ;
121- tilt_speed_ = params_.look_at .tilt_speed ;
122120
123121 auto moveit_node = std::make_shared<rclcpp::Node>(" moveit_head_mover_node" );
124122
@@ -169,8 +167,8 @@ class HeadMover {
169167 pos_msg_.joint_names = {" HeadPan" , " HeadTilt" };
170168 pos_msg_.positions = {0 , 0 };
171169 pos_msg_.velocities = {0 , 0 };
172- pos_msg_.accelerations = {0 , 0 };
173- pos_msg_.max_currents = {0 , 0 };
170+ pos_msg_.accelerations = {- 1 , - 1 };
171+ pos_msg_.max_currents = {- 1 , - 1 };
174172
175173 // apparently tf_listener is necessary but unused
176174 tf_buffer_ = std::make_shared<tf2_ros::Buffer>(node_->get_clock ());
@@ -266,7 +264,7 @@ action_running_ = false;
266264
267265 double calculate_lower_speed (double delta_fast_joint, double delta_my_joint, double speed) {
268266 double estimated_time = delta_fast_joint / speed;
269- if (estimated_time != 0 ) {
267+ if (estimated_time) {
270268 return delta_my_joint / estimated_time;
271269 } else {
272270 return 0 ;
@@ -393,9 +391,9 @@ action_running_ = false;
393391 double delta_pan = std::abs (goal_pan - current_pan);
394392 double delta_tilt = std::abs (goal_tilt - current_tilt);
395393 if (delta_pan > 0 ) {
396- tilt_speed = calculate_lower_speed (delta_pan, delta_tilt, pan_speed);
394+ tilt_speed = std::min (tilt_speed, calculate_lower_speed (delta_pan, delta_tilt, pan_speed) );
397395 } else {
398- pan_speed = calculate_lower_speed (delta_tilt, delta_pan, tilt_speed);
396+ pan_speed = std::min (pan_speed, calculate_lower_speed (delta_tilt, delta_pan, tilt_speed) );
399397 }
400398 pos_msg_.positions = {goal_pan, goal_tilt};
401399 pos_msg_.velocities = {pan_speed, tilt_speed};
@@ -531,20 +529,20 @@ action_running_ = false;
531529
532530 }
533531
534- bool look_at (geometry_msgs::msg::PointStamped point, double min_pan_delta = 0.01 , double min_tilt_delta = 0.01 ) {
532+ bool look_at (geometry_msgs::msg::PointStamped point, double min_pan_delta = 0.02 , double min_tilt_delta = 0.02 ) {
535533 try {
536534 geometry_msgs::msg::PointStamped
537535 new_point = tf_buffer_->transform (point, planning_scene_->getPlanningFrame (), tf2::durationFromSec (0.9 ));
538536 // todo: change base_link to frame from action
539537
540- std::pair<double , double > pan_tilt = get_motor_goals_from_point (new_point.point );
538+ std::pair<double , double > pan_tilt = get_motor_goals_from_point (new_point.point ); // TODO: do we need to threshold values here?
541539 std::pair<double , double > current_pan_tilt = get_head_position ();
542540
543541 if (std::abs (pan_tilt.first - current_pan_tilt.first ) > min_pan_delta
544542 || std::abs (pan_tilt.second - current_pan_tilt.second )
545543 > min_tilt_delta) // can we just put the min_tilt_delta as radiant into the conrfig?
546544 {
547- send_motor_goals (pan_tilt.first , pan_tilt.second , true );
545+ send_motor_goals (pan_tilt.first , pan_tilt.second , true , params_. look_at . pan_speed , params_. look_at . tilt_speed );
548546 return false ;
549547 }
550548 return true ;
@@ -568,6 +566,7 @@ action_running_ = false;
568566 }
569567
570568 void perform_search_pattern () {
569+ RCLCPP_INFO (node_->get_logger (), " search pattern" );
571570 if (pattern_.size () == 0 ) {
572571 return ;
573572 }
@@ -645,14 +644,13 @@ action_running_ = false;
645644 default :
646645 return ;
647646 }
648-
649- }
650- if (!action_running_ && curr_head_mode != humanoid_league_msgs::msg::HeadMode::DONT_MOVE){
651647 std::pair<double , double > head_position = get_head_position ();
652648
653649 index_ = get_near_pattern_position (pattern_, head_position.first , head_position.second );
650+ }
651+ if (!action_running_ && curr_head_mode != humanoid_league_msgs::msg::HeadMode::DONT_MOVE){
654652 prev_head_mode_ = curr_head_mode;
655- perform_search_pattern ();
653+ perform_search_pattern ();
656654
657655 }
658656 };
0 commit comments