21 #ifndef __PTU_FREE_INCLUDED__ 23 COMstream = open_host_port((
char*)port);
27 char d = reset_PTU_parser(1000);
33 #endif // __PTU_FREE_INCLUDED__ 34 #ifdef __PTU_FREE_INCLUDED__ 36 ROS_DEBUG(
"Free PTU serial connection set with return code: %ld", return_code);
37 #endif // __PTU_FREE_INCLUDED__ 56 ROS_DEBUG(
"port: %s, baud: %d, speed_control: %d", port, baud, speed_control);
61 ROS_DEBUG(
"This constructor is only for the mock!");
70 #ifndef __PTU_FREE_INCLUDED__ 73 #ifdef __PTU_FREE_INCLUDED__ 88 int pan_upper,
int tilt_upper,
int pan_accel,
int tilt_accel,
89 int pan_hold,
int tilt_hold,
int pan_move,
int tilt_move) {
92 bool no_error_occured =
true;
177 if(!no_error_occured)
179 ROS_ERROR(
"Error occured while setting new settings! Old settings will be restored.");
181 setValuesToBackupValues(pan_base, tilt_base, pan_speed, tilt_speed, pan_upper, tilt_upper, pan_accel, tilt_accel, pan_hold, tilt_hold, pan_move, tilt_move);
188 int & pan_upper,
int & tilt_upper,
int & pan_accel,
int & tilt_accel,
189 int & pan_hold,
int & tilt_hold,
int & pan_move,
int & tilt_move)
258 if(return_code ==
PTU_OK)
return true;
279 if(pan_or_tilt ==
'p') {
280 if (upper_or_lower ==
'l') {
283 else if (upper_or_lower ==
'u') {
287 return std::numeric_limits<double>::max();
290 else if (pan_or_tilt ==
't') {
291 if (upper_or_lower ==
'l') {
294 else if (upper_or_lower ==
'u') {
298 return std::numeric_limits<double>::max();
302 return std::numeric_limits<double>::max();
309 std::vector< std::map< std::string, double> > legit_forbidden_areas;
313 double area_pan_min = area[
"pan_min"];
314 double area_pan_max = area[
"pan_max"];
315 double area_tilt_min = area[
"tilt_min"];
316 double area_tilt_max = area[
"tilt_max"];
317 if ( area_pan_min <= area_pan_max &&
318 area_tilt_min <= area_tilt_max)
320 legit_forbidden_areas.push_back(area);
324 ROS_ERROR(
"Forbidden Area with pan_min %f, pan_max %f, tilt_min %f and tilt_max %f is not valid. One of the max values is larger than the related min value.\n", area_pan_min, area_pan_max, area_tilt_min, area_tilt_max);
332 ROS_DEBUG(
"Driver::SetAbsoluteAngleSpeed()");
347 ROS_DEBUG(
"Driver::SetAbsoluteAngleSpeed");
353 ROS_DEBUG_STREAM(
"set_desired(PAN, SPEED, " << pan_speed <<
", ABSOLUTE) returned " 356 ROS_DEBUG_STREAM(
"set_desired(TILT, SPEED, " << tilt_speed <<
", ABSOLUTE) returned " 364 ROS_DEBUG(
"Driver::isInForbiddenArea()");
369 double area_pan_min = area[
"pan_min"];
370 double area_pan_max = area[
"pan_max"];
371 double area_tilt_min = area[
"tilt_min"];
372 double area_tilt_max = area[
"tilt_max"];
373 ROS_DEBUG_STREAM(
"Checking forbidden area " << i <<
" with pan_min " << area_pan_min <<
", pan_max " << area_pan_max <<
", tilt_min " << area_tilt_min <<
", tilt_max " << area_tilt_max);
375 if (area_pan_min < pan_angle && pan_angle < area_pan_max &&
376 area_tilt_min < tilt_angle && tilt_angle < area_tilt_max)
378 ROS_ERROR(
"Value lies in forbidden area: %d", i);
401 ROS_DEBUG(
"Before margin check: PAN: %f, TILT: %f\n", *pan, *tilt);
405 ROS_ERROR(
"Margin in Positions (%ld) (Degree: (%f)) is too big. Bigger than distance between TILT max and TILT min (%ld Positions) or PAN max and PAN min (%ld Positions)",margin_as_position, margin, (
tilt_max -
tilt_min), (
pan_max -
pan_min));
408 double pan_initial = *pan;
409 double tilt_initial = *tilt;
412 if((pan_as_position <
pan_min) && (pan_as_position >= (
pan_min - margin_as_position))) {
415 ROS_WARN(
"PAN was out of limits, but within margin, so instead of the initial value %f the value %f is used", pan_initial, *pan);
417 else if ((pan_as_position >
pan_max) && (pan_as_position <= (
pan_max + margin_as_position))) {
420 ROS_WARN(
"PAN was out of limits, but within margin, so instead of the initial value %f the value %f is used", pan_initial, *pan);
422 if((tilt_as_position <
tilt_min) && (tilt_as_position >= (
tilt_min - margin_as_position))) {
425 ROS_WARN(
"TILT was out of limits, but within margin, so instead of the initial value %f the value %f is used", tilt_initial, *tilt);
427 else if((tilt_as_position >
tilt_max) && (tilt_as_position <= (
tilt_max + margin_as_position))) {
430 ROS_WARN(
"TILT was out of limits, but within margin, so instead of the initial value %f the value %f is used", tilt_initial, *tilt);
434 ROS_DEBUG(
"After margin check: PAN: %f, TILT: %f\n", *pan, *tilt);
438 ROS_ERROR(
"PAN/TILT out of bounds (PAN: %f, TILT: %f)", *pan, *tilt);
458 ROS_DEBUG(
"Driver::SetAbsoluteAngles()");
466 if ((pan_short_angle <
pan_min)
471 ROS_ERROR(
"PAN/TILT angle not within pan/tilt bounds");
477 ROS_DEBUG_STREAM(
"set_desired(PAN, POSITION, " << pan_short_angle <<
", ABSOLUTE) returned " 481 ROS_DEBUG_STREAM(
"set_desired(TILT, POSITION, " << tilt_short_angle <<
", ABSOLUTE) returned " 483 ROS_INFO(
"Successfully set Pan and Tilt. PAN: %f, TILT: %f\n", pan_angle, tilt_angle);
490 this->pan_min = pan_min_candidate;
494 ROS_ERROR(
"Desired PAN_MIN Position was smaller than the hardware limit -> PAN_MIN set to hardware limit");
498 this->pan_max = pan_max_candidate;
502 ROS_ERROR(
"Desired PAN_MAX Position was greater than the hardware limit -> PAN_MAX set to hardware limit");
506 this->tilt_min = tilt_min_candidate;
510 ROS_ERROR(
"Desired TILT_MIN Position was smaller than the hardware limit -> TILT_MIN set to hardware limit");
514 this->tilt_max = tilt_max_candidate;
518 ROS_ERROR(
"Desired TILT_MAX Position was greater than the hardware limit -> TILT_MAX set to hardware limit");
520 ROS_DEBUG(
"Limits set to Virtual Limits: PAN_MINIMUM: %f, PAN_MAXIMUM: %f, TILT_MINIMUM: %f, TILT_MAXIMUM: %f", pan_min, pan_max, tilt_min, tilt_max);
540 else if(type ==
TILT){
544 throw std::exception();
553 else if (type ==
TILT) {
557 throw std::exception();
565 else if (type ==
TILT) {
569 throw std::exception();
591 #ifndef __PTU_FREE_INCLUDED__ 595 return "PTU_OK";
break;
596 case PTU_ILLEGAL_COMMAND:
597 return "PTU_ILLEGAL_COMMAND";
break;
598 case PTU_ILLEGAL_POSITION_ARGUMENT:
599 return "PTU_ILLEGAL_POSITION_ARGUMENT";
break;
600 case PTU_ILLEGAL_SPEED_ARGUMENT:
601 return "PTU_ILLEGAL_SPEED_ARGUMENT";
break;
602 case PTU_ACCEL_TABLE_EXCEEDED:
603 return "PTU_ACCEL_TABLE_EXCEEDED";
break;
604 case PTU_DEFAULTS_EEPROM_FAULT:
605 return "PTU_DEFAULTS_EEPROM_FAULT";
break;
606 case PTU_SAVED_DEFAULTS_CORRUPTED:
607 return "PTU_SAVED_DEFAULTS_CORRUPTED";
break;
609 return "PTU_LIMIT_HIT";
break;
610 case PTU_CABLE_DISCONNECTED:
611 return "PTU_CABLE_DISCONNECTED";
break;
612 case PTU_ILLEGAL_UNIT_ID:
613 return"PTU_ILLEGAL_UNIT_ID";
break;
614 case PTU_ILLEGAL_POWER_MODE:
615 return "PTU_ILLEGAL_POWER_MODE";
break;
616 case PTU_RESET_FAILED:
617 return "PTU_RESET_FAILED";
break;
618 case PTU_ILLEGAL_PARAMETERS:
619 return "PTU_ILLEGAL_PARAMETERS";
break;
620 case PTU_DUART_ERROR:
621 return "PTU_DUART_ERROR";
break;
623 return "PTU_ERROR";
break;
624 case NOT_SUPPORTED_BY_THIS_FIRMWARE_VERSION:
625 return "NOT_SUPPORTED_BY_THIS_FIRMWARE_VERSION";
break;
626 case PTU_TILT_VANE_OUT_OF_RANGE_ERROR:
627 return "PTU_TILT_VANE_OUT_OF_RANGE_ERROR";
break;
629 return "UNDEFINED_RETURN_STATUS_ERROR";
break;
632 #ifdef __PTU_FREE_INCLUDED__ 633 if(status_code ==
PTU_OK) {
649 return (((current_tilt_speed == 0) && (current_pan_speed == 0)));
658 return ((current_tilt == desired_tilt) && (current_pan == desired_pan));
667 std::vector<double> solutions;
669 double second_part_before_root = pow(b, 2) - 4 * a * c;
670 if(second_part_before_root < 0){
673 if(second_part_before_root == 0) {
674 solutions.push_back(-b / (2 * a));
677 double root_part = sqrt(second_part_before_root);
678 solutions.push_back((-b + root_part) / (2 * a));
679 solutions.push_back((-b - root_part) / (2 * a));
688 std::vector<double> solution;
689 if(distance_in_steps == 0.0) {
690 solution.push_back(0.0);
691 solution.push_back(0.0);
695 double speed_to_accelerate = slew_speed - base_speed;
696 double acceleration_time_to_desired_speed = speed_to_accelerate / acceleration;
697 double distance_for_full_acceleration_and_deceleration = 2.0 * (acceleration_time_to_desired_speed * base_speed
698 + 1.0/2.0 * acceleration * pow(acceleration_time_to_desired_speed, 2));
700 if(distance_for_full_acceleration_and_deceleration >= distance_in_steps) {
701 std::vector<double> speed_candidates =
solveSecondDegreePolynomial(1.0 / acceleration, 2.0 * base_speed / acceleration, -distance_in_steps);
702 if(speed_candidates.size() == 0) {
703 ROS_DEBUG(
"PAN ACCELERATION TIME CALCULATION FAILED (getAccelerationTime-Method)");
706 else if(speed_candidates.size() == 1) {
707 solution.push_back(speed_candidates[0]);
711 double new_acceleration_time_to_desired_speed_candidate_one = speed_candidates[0] / acceleration;
712 double new_acceleration_time_to_desired_speed_candidate_two = speed_candidates[1] / acceleration;
713 if(speed_candidates[0] > 0.0) {
714 solution.push_back(new_acceleration_time_to_desired_speed_candidate_one);
715 solution.push_back(0.0);
719 solution.push_back(new_acceleration_time_to_desired_speed_candidate_two);
720 solution.push_back(0.0);
726 solution.push_back(acceleration_time_to_desired_speed);
727 double remaining_distance_at_slew_speed = distance_in_steps - distance_for_full_acceleration_and_deceleration;
728 double time_at_slew_speed = remaining_distance_at_slew_speed / slew_speed;
729 solution.push_back(time_at_slew_speed);
737 double pan_distance = end_point[0] - start_point[0];
738 double tilt_distance = end_point[1] - start_point[1];
745 double pan_complete_time = 2.0 * pan_time[0] + pan_time[1];
746 double tilt_complete_time = 2.0 * tilt_time[0] + tilt_time[1];
747 double max_time = std::max(pan_complete_time, tilt_complete_time);
748 if(max_time <= point_in_time) {
752 std::vector<double> pan_tilt_distance;
753 if(pan_time[0] >= point_in_time) {
754 double acceleration_time = point_in_time;
755 double slew_speed_time = 0.0;
756 double decceleration_time = 0.0;
757 if(pan_distance >= 0) {
764 else if((pan_time[0] + pan_time[1]) >= point_in_time) {
765 double acceleration_time = pan_time[0];
766 double slew_speed_time = point_in_time - pan_time[0];
767 double decceleration_time = 0.0;
768 if(pan_distance >= 0) {
776 else if((2.0 * pan_time[0] + pan_time[1]) >= point_in_time){
777 double acceleration_time = pan_time[0];
778 double slew_speed_time = pan_time[1];
779 double decceleration_time = point_in_time - pan_time[0] - pan_time[1];
780 if(pan_distance >= 0) {
788 pan_tilt_distance.push_back(end_point[0] - start_point[0]);
792 if(tilt_time[0] >= point_in_time) {
793 double acceleration_time = point_in_time;
794 double slew_speed_time = 0.0;
795 double decceleration_time = 0.0;
796 if(tilt_distance >= 0) {
803 else if((tilt_time[0] + tilt_time[1]) >= point_in_time) {
804 double acceleration_time = tilt_time[0];
805 double slew_speed_time = point_in_time - tilt_time[0];
806 double decceleration_time = 0.0;
807 if(tilt_distance >= 0) {
815 else if(((2.0 * tilt_time[0] + tilt_time[1]) >= point_in_time)){
816 double acceleration_time = tilt_time[0];
817 double slew_speed_time = tilt_time[1];
818 double decceleration_time = point_in_time - tilt_time[0] - tilt_time[1];
819 if(tilt_distance >= 0) {
827 pan_tilt_distance.push_back(end_point[1] - start_point[1]);
830 std::vector<double> new_position;
831 new_position.push_back(start_point[0] + pan_tilt_distance[0]);
832 new_position.push_back(start_point[1] + pan_tilt_distance[1]);
842 long prefetched_base;
843 long prefetched_accel;
852 double covered_distance = 0.0;
853 double covered_distance_acceleration = prefetched_base * acceleration_time + 1.0/2.0 * prefetched_accel * pow(acceleration_time, 2);
854 covered_distance += covered_distance_acceleration;
855 if(slew_speed_time != 0.0) {
856 double covered_distance_slew_speed = (prefetched_base + acceleration_time * prefetched_accel) * slew_speed_time;
857 covered_distance += covered_distance_slew_speed;
859 if(decceleration_time != 0) {
860 double covered_distance_decceleration = covered_distance_acceleration - 1.0/2.0 * pow((acceleration_time - decceleration_time),2) * prefetched_accel - (acceleration_time - decceleration_time) * prefetched_base;
861 covered_distance += covered_distance_decceleration;
863 return covered_distance;
877 double distance_from_start = std::numeric_limits<double>::max();
878 std::vector<double> intersection_point;
887 double new_distance_from_start;
888 if((first_intersection_point.size() != 0)
891 new_distance_from_start =
getVectorLength(start_point, first_intersection_point);
892 if(new_distance_from_start < distance_from_start) {
893 distance_from_start = new_distance_from_start;
894 intersection_point = first_intersection_point;
897 if((second_intersection_point.size() != 0)
900 new_distance_from_start =
getVectorLength(start_point, second_intersection_point);
901 if(new_distance_from_start < distance_from_start) {
902 distance_from_start = new_distance_from_start;
903 intersection_point = second_intersection_point;
906 if((third_intersection_point.size() != 0)
909 new_distance_from_start =
getVectorLength(start_point, third_intersection_point);
910 if(new_distance_from_start < distance_from_start) {
911 distance_from_start = new_distance_from_start;
912 intersection_point = third_intersection_point;
915 if((fourth_intersection_point.size() != 0)
918 new_distance_from_start =
getVectorLength(start_point, fourth_intersection_point);
919 if(new_distance_from_start < distance_from_start) {
920 distance_from_start = new_distance_from_start;
921 intersection_point = fourth_intersection_point;
925 if(intersection_point.size() != 0) {
926 printf(
"Start Point: (%f,%f)\n", start_point[0], start_point[1]);
927 printf(
"End Point: (%f,%f)\n", end_point[0], end_point[1]);
928 printf(
"Intersection Point: (%f,%f)\n", intersection_point[0], intersection_point[1]);
930 return intersection_point;
936 std::vector<double> intersection_point;
937 double denominator = first_line_coordiante_form[0] * second_line_coordiante_form[1] - first_line_coordiante_form[1] * second_line_coordiante_form[0];
938 if((denominator >= -0.00001 && denominator <= 0.00001)) {
939 return intersection_point;
941 double pan_intersection_point = first_line_coordiante_form[2] * second_line_coordiante_form[1] - first_line_coordiante_form[1] * second_line_coordiante_form[2];
942 double tilt_intersection_point = first_line_coordiante_form[0] * second_line_coordiante_form[2] - first_line_coordiante_form[2] * second_line_coordiante_form[0];
943 pan_intersection_point /= denominator;
944 tilt_intersection_point /= denominator;
945 intersection_point.push_back(pan_intersection_point);
946 intersection_point.push_back(tilt_intersection_point);
947 return intersection_point;
951 double distance_from_start_point = sqrt(pow((point_to_check[0] - start_point[0]), 2) + pow((point_to_check[1] - start_point[1]), 2));
952 double distance_from_end_point = sqrt(pow((point_to_check[0] - end_point[0]), 2) + pow((point_to_check[1] - end_point[1]), 2));
953 if((distance_from_start_point <= tolerance) || (distance_from_end_point <= tolerance)) {
958 double normal_vector_length = sqrt(pow(line_coordinate_form[0], 2) + pow(line_coordinate_form[1], 2));
961 double distance_from_line = (1/normal_vector_length) * (point_to_check[0] * line_coordinate_form[0] + point_to_check[1] * line_coordinate_form[1] - line_coordinate_form[2]);
963 if(distance_from_line > tolerance) {
974 double max_pan = std::max(start_point[0], end_point[0]);
975 double min_pan = std::min(start_point[0], end_point[0]);
976 double max_tilt = std::max(start_point[1], end_point[1]);
977 double min_tilt = std::min(start_point[1], end_point[1]);
978 max_pan += tolerance;
979 min_pan -= tolerance;
980 max_tilt += tolerance;
981 min_tilt -= tolerance;
983 if((point_to_check[0] > max_pan) || (point_to_check[0] < min_pan) || (point_to_check[1] > max_tilt) || (point_to_check[1] < min_tilt)) {
993 std::vector<double> coordinate_form;
994 if((start_point[0] == end_point[0]) && (start_point[1] == end_point[1])) {
995 return coordinate_form;
997 double a = start_point[1] - end_point[1];
998 double b = end_point[0] - start_point[0];
999 double c = end_point[0] * start_point[1] - start_point[0] * end_point[1];
1000 coordinate_form.push_back(a);
1001 coordinate_form.push_back(b);
1002 coordinate_form.push_back(c);
1003 return coordinate_form;
1009 for(
unsigned int i = 0; i < input_vector.size(); i++) {
1010 length += pow(input_vector[i], 2);
1012 return sqrt(length);
1016 if (start_point.size() != end_point.size()) {
1019 std::vector<double> length_vector(start_point.size());
1020 for (
unsigned int i = 0; i < start_point.size(); i++) {
1021 length_vector[i] = end_point[i] - start_point[i];
1029 if(possible_end_point.size() == 0) {
1030 std::vector<double> end_point;
1031 end_point.push_back(end_point_pan_candidate);
1032 end_point.push_back(end_point_tilt_candidate);
1038 if(new_possible_end_point.size() == 0) {
1039 return possible_end_point;
1044 return new_possible_end_point;
1047 possible_end_point = new_possible_end_point;
1054 std::vector<double> start_point;
1056 start_point.push_back(start_pan_value);
1058 start_point.push_back(start_tilt_value);
1060 std::vector<double> end_point;
1061 end_point.push_back(new_pan_angle);
1062 end_point.push_back(new_tilt_angle);
1068 double time_per_position = 1.0 / max_base_speed;
1074 double counter = 1.0;
1075 std::vector<double> last_point = start_point;
1076 std::vector<double> intersection_point;
1077 std::vector<double> new_point;
1080 if((new_point[0] == last_point[0]) && (new_point[1] == last_point[1])) {
1081 return intersection_point;
1084 if(intersection_point.size() != 0) {
1085 return intersection_point;
1088 last_point = new_point;
1097 std::vector<double> max_pan_max_tilt_point;
1101 std::vector<double> max_pan_min_tilt_point;
1105 std::vector<double> min_pan_max_tilt_point;
1109 std::vector<double> min_pan_min_tilt_point;
1132 #ifdef __PTU_FREE_INCLUDED__ 1134 if(pan_or_tilt ==
PAN) {
1155 ROS_DEBUG(
"bad use of internal get_current method: input combination not legit");
1160 else if(pan_or_tilt ==
TILT) {
1181 ROS_DEBUG(
"bad use of internal get_current method: input combination not legit");
1186 ROS_DEBUG(
"bad use of internal get_current method: input combination not legit");
1193 if(pan_or_tilt ==
PAN) {
1244 else if(*value == PTU_REG_POWER) {
1253 ROS_DEBUG(
"bad use of internal set_desired method: input combination not legit");
1266 else if (*value == PTU_REG_POWER){
1274 else if (*value == PTU_HI_POWER) {
1283 ROS_DEBUG(
"bad use of internal set_desired method: input combination not legit");
1296 ROS_DEBUG(
"bad use of internal set_desired method: input combination not legit");
1300 else if(pan_or_tilt ==
TILT) {
1351 else if (*value == PTU_REG_POWER) {
1360 ROS_DEBUG(
"bad use of internal set_desired method: input combination not legit");
1373 else if (*value == PTU_REG_POWER){
1381 else if (*value == PTU_HI_POWER) {
1390 ROS_DEBUG(
"bad use of internal set_desired method: input combination not legit");
1403 ROS_DEBUG(
"bad use of internal set_desired method: input combination not legit");
1408 ROS_DEBUG(
"bad use of internal set_desired method: input combination not legit");
1417 if(pan_or_tilt ==
PAN) {
1468 else if (pan_or_tilt ==
TILT) {
1520 ROS_DEBUG(
"bad use of internal get_desired method: input combination not legit");
1563 ROS_DEBUG(
"bad use of internal set_mode method: input combination not legit");
1568 #endif // __PTU_FREE_INCLUDED__
void restoreSettingsFromBackup()
virtual void setSpeedControlMode(bool speed_control_mode)
setSpeedControlMode Method to set and disable pure speed control mode
long prefetched_pan_desired_speed
long getCurrentPanSpeed()
getCurrentPanSpeed Method that queries the current pan speed
virtual bool isConnected()
isConnected Method to check if ptu is connected.
double calculateCoveredDistance(double acceleration_time, double slew_speed_time, double decceleration_time, bool is_pan)
bool setDesiredTiltUpperSpeedLimit(short int upper_speed_limit)
setDesiredTiltUpperSpeedLimit Method that sets the upper speed limit for tilt (position/second). WARNING: Takes extremly long or does not work on every ptu
double getVectorLength(std::vector< double > input_vector)
double double_computation_tolerance
virtual bool reachedGoal()
reachedGoal Method to determine if the PTU has reached its goal.
virtual bool isWithinPanTiltLimits(double pan, double tilt)
isWithinPanTiltLimits Method that checks if pan and tilt value are within the chosen pan and tilt lim...
std::vector< std::vector< double > > min_pan_max_tilt_points
bool setDesiredPanSpeedAbsolute(short int speed)
setDesiredPanSpeedAbsolute Method that sets absolute pan speed (position/second)
virtual double getDesiredAngle(char type)
getDesiredAngle Method to get the desired pan/tilt angle (where the ptu moves to) ...
virtual std::vector< double > determineLegitEndPoint(double end_point_pan_candidate, double end_point_tilt_candidate)
determineLegitEndPoint Method to determine an end point which is not inside a forbidden area using pa...
long getCurrentUsedMaximumTiltPositionLimit()
getCurrentUsedMaximumTiltPositionLimit Method to get the currently used maximum tilt position...
long getDesiredTiltSpeed()
getDesiredTiltSpeed Method that queries the desired tilt speed
double getTiltResolution()
getTiltResolution Method that queries the tilt resolution (seconds/arc per position). Divide by 3600 to get Degree.
bool setDesiredTiltPositionAbsolute(short int position)
setDesiredTiltPositionAbsolute Method that sets absolute tilt position
std::vector< double > calculateCoordinateForm(std::vector< double > start_point, std::vector< double > end_point)
virtual void setComputationTolerance(double computation_tolerance)
setComputationTolerance Sets the tolerance value for errors due to the imprecise nature of float...
long get_current(char pan_or_tilt, char what)
#define PTU_PURE_VELOCITY_SPEED_CONTROL_MODE
virtual void setDistanceFactor(long distance_factor)
setDistanceFactor Method to set the factor which determines how much samples are going to be taken fo...
#define OFF_HOLD_POWER_MODE
long get_desired(char pan_or_tilt, char what)
long getCurrentUsedMinimumPanPositionLimit()
getCurrentUsedMinimumPanPositionLimit Method to get the currently used minimum pan position...
long convertTiltFromAngleToPosition(double angle)
virtual bool setAbsoluteAngles(double pan_angle, double tilt_angle, bool no_forbidden_area_check)
setAbsoluteAngles Method to set pan and tilt angle for the PTU
virtual bool isInSpeedControlMode()
isInSpeedControlMode Method to determine if ptu is in pure speed control mode
long getTiltAcceleartion()
getTiltAcceleartion Method that queries the tilt acceleration (no current or desired here) ...
long getPanInMotionPowerMode()
getPanInMotionPowerMode Method to get the move power mode for pan axis.
#define HIGH_MOVE_POWER_MODE
bool isOpen()
isOpen Method to determine if used port is open or closed.
double convertPanFromPositionToAngle(long position)
long prefetched_tilt_desired_speed
long getCurrentTiltSpeed()
getCurrentTiltSpeed Method that queries the current tilt speed
bool setTiltBaseSpeed(short int base_speed)
setTiltBaseSpeed Method that sets the base speed for tilt (position/second)
long getTiltUpperSpeedLimit()
getTiltUpperSpeedLimit Method that queries the tilt upper speed limit WARNING: This Method consumes e...
#define POSITION_LIMITS_MODE
#define INDEPENDENT_SPEED_MODE
#define PTU_INDEPENDENT_SPEED_CONTROL_MODE
virtual bool setValuesOutOfLimitsButWithinMarginToLimit(double *pan, double *tilt, double margin)
setValuesOutOfLimitsButWithinMarginToLimit This method is used to set pan/tilt values that are slighl...
long getCurrentUsedMinimumTiltPositionLimit()
getCurrentUsedMinimumTiltPositionLimit Method to get the currently used minimum tilt position...
virtual long getLimitAngle(char pan_or_tilt, char upper_or_lower)
!!!!!!!!!Müssen nachfolgende public sein? Nach erstellen von mock überprüfen!!!!!!!!!!! ...
long getDesiredPanSpeed()
getDesiredPanSpeed Method that queries the desired pan speed
virtual void setSettings(int pan_base, int tilt_base, int pan_speed, int tilt_speed, int pan_upper, int tilt_upper, int pan_accel, int tilt_accel, int pan_hold, int tilt_hold, int pan_move, int tilt_move)
setSettings Method to configure various settings of the ptu
std::vector< double > calculatePointOfIntersectionWithForbiddenAreas(std::vector< double > start_point, std::vector< double > end_point)
bool setDesiredPanUpperSpeedLimit(short int upper_speed_limit)
setDesiredPanUpperSpeedLimit Method that sets the upper speed limit for pan (position/second). WARNING: Takes extremly long or does not work on every ptu
long prefetched_tilt_current_base
bool setNewSerialConnection(std::string port, int baud)
setNewSerialConnection Establishes a new connection via serial port specified by 'port' to a target d...
bool setPanStationaryPowerMode(long mode)
setPanStationaryPowerMode Method to set the stationary power mode for pan axis.
void createSettingsBackup()
virtual void setLimitAngles(double pan_min, double pan_max, double tilt_min, double tilt_max)
setSettings Method to configure limits for pan and tilt
std::vector< std::vector< double > > forbidden_area_third_line_coordinate_forms
ptu_free::PTUFree free_ptu
long getTiltStationaryPowerMode()
getTiltStationaryPowerMode Method to get the stationary power mode for tilt axis. ...
bool setDesiredPanAccelerationAbsolute(short int acceleration)
setDesiredPanAccelerationAbsolute Method that sets the absolute pan acceleration (position/second^2) ...
std::vector< std::vector< double > > max_pan_min_tilt_points
void setValuesToBackupValues(int &pan_base, int &tilt_base, int &pan_speed, int &tilt_speed, int &pan_upper, int &tilt_upper, int &pan_accel, int &tilt_accel, int &pan_hold, int &tilt_hold, int &pan_move, int &tilt_move)
std::vector< std::vector< double > > forbidden_area_fourth_line_coordinate_forms
~PTUDriver()
~PTUDriver Do not use, necessary because of some compiler issues.
bool setDesiredTiltAccelerationAbsolute(short int acceleration)
setDesiredTiltAccelerationAbsolute Method that sets the absolute tilt acceleration (position/second^2...
long prefetched_tilt_current_position
#define SPEED_CONTROL_MODE
static short int POW_VAL_MOVE[3]
bool setPanBaseSpeed(short int base_speed)
setPanBaseSpeed Method that sets the base speed for pan (position/second)
std::vector< std::vector< double > > forbidden_area_first_line_coordinate_forms
virtual std::string getErrorString(char status_code)
long getTiltInMotionPowerMode()
getTiltInMotionPowerMode Method to get the move power mode for tilt axis.
bool setSpeedControlMode(long mode)
setSpeedControlMode Method to set the sped control mode of the ptu.
long getPanAcceleartion()
getPanAcceleartion Method that queries the pan acceleration (no current or desired here) ...
virtual void setForbiddenAreas(std::vector< std::map< std::string, double > > forbidden_areas)
setForbiddenAreas Method to set all forbidden areas for the PTU. Former forbidden areas will be disca...
void precalculateForbiddenAreaCoodinateForms()
std::vector< double > getAccelerationTimeAndSlewSpeedTime(double distance_in_steps, double base_speed, double acceleration, double slew_speed)
long getPanUpperSpeedLimit()
getPanUpperSpeedLimit Method that queries the pan upper speed limit WARNING: This Method consumes eit...
long getTiltBaseSpeed()
getTiltBaseSpeed Returns the current tilt base speed
#define UPPER_SPEED_LIMIT
long getDesiredPanPosition()
getDesiredPanPosition Method that queries the desired pan position
long getCurrentPanPosition()
getCurrentPanPosition Method that queries the current pan position
bool checkReturnCode(char return_code)
virtual double getAngleSpeed(char type)
getAngleSpeed Method to get the current angle speed of an axisa (deg/s)
PTUDriver()
PTUDriver Do not use, needed for mock.
double getPanResolution()
getPanResolution Method that queries the pan resolution (seconds/arc per position). Divide by 3600 to get Degree.
long prefetched_pan_desired_acceleration
virtual double getCurrentAngle(char type)
getCurrentAngle Method to get the current pan/tilt angle
std::vector< std::vector< double > > forbidden_area_second_line_coordinate_forms
#define ROS_DEBUG_STREAM(args)
long getPanBaseSpeed()
getPanBaseSpeed Returns the current pan base speed
#define LOW_HOLD_POWER_MODE
long prefetched_pan_current_base
static short int POW_VAL_HOLD[3]
virtual bool hasHaltedAndReachedGoal()
hasHaltedAndReachedGoal Method to determine if the PTU has halted and reached its goal ...
virtual void setLimitAnglesToHardwareConstraints()
setLimitAnglesToHardwareConstraints Method that sets the pan and tilt limits to the maximum values th...
std::vector< std::vector< double > > min_pan_min_tilt_points
bool isOnLineSegmentBetweenTwoPoints(std::vector< double > start_point, std::vector< double > end_point, std::vector< double > line_coordinate_form, std::vector< double > point_to_check, double tolerance)
double convertTiltFromPositionToAngle(long position)
long getPanStationaryPowerMode()
getPanStationaryPowerMode Method to get the stationary power mode for pan axis.
std::vector< double > checkForPossibleKollision(double new_pan_angle, double new_tilt_angle)
#define REGULAR_HOLD_POWER_MODE
#define LOW_MOVE_POWER_MODE
long getCurrentUsedMaximumPanPositionLimit()
getCurrentUsedMaximumPanPositionLimit Method to get the currently used maximum pan position...
bool setPositionLimitEnforcementMode(long enable)
setPositionLimitEnforcementMode Method to set the position limit enforcement mode. Warning: USER_DEFINED_LIMITS_ENABLED does not work on older PTUs and setting of this value is not tested.
long prefetched_pan_current_position
bool setDesiredPanPositionAbsolute(short int position)
setDesiredPanPositionAbsolute Method that sets absolute pan position
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
std::vector< double > solveSecondDegreePolynomial(double a, double b, double c)
#define REGULAR_MOVE_POWER_MODE
virtual bool isInForbiddenArea(double pan_angle, double tilt_angle)
isInForbiddenArea method to determine if a pan + tilt value pair lies within a forbidden area...
char set_desired(char pan_or_tilt, char what, short int *value, char type)
#define PURE_VELOCITY_CONTROL_MODE
bool setTiltStationaryPowerMode(long mode)
setTiltStationaryPowerMode Method to set the stationary power mode for tilt axis. ...
long convertPanFromAngleToPosition(double angle)
long prefetched_tilt_desired_acceleration
bool setTiltInMotionPowerMode(long mode)
setTiltInMotionPowerMode Method to set the move power mode for tilt axis.
std::vector< std::map< std::string, double > > forbidden_areas
std::vector< double > calculateIntersectionPoint(std::vector< double > first_line_coordiante_form, std::vector< double > second_line_coordiante_form)
virtual void setAbsoluteAngleSpeeds(double pan_speed, double tilt_speed)
setAbsoluteAngleSpeeds Method to set desired speed for pan/tilt movement absolute in deg/s ...
virtual bool hasHalted()
hasHalted Method to determine if PTU movement has stopped
std::vector< double > predictPositionInTime(std::vector< double > start_point, std::vector< double > end_point, double point_in_time)
long getCurrentTiltPosition()
getCurrentTiltPosition Method that queries the current tilt position
std::vector< std::vector< double > > max_pan_max_tilt_points
bool setDesiredTiltSpeedAbsolute(short int speed)
setDesiredTiltSpeedAbsolute Method that sets absolute tilt speed (position/second) ...
bool setPanInMotionPowerMode(long mode)
setPanInMotionPowerMode Method to set the move power mode for pan axis.
long getDesiredTiltPosition()
getDesiredTiltPosition Method that queries the desired tilt position
char set_mode(char mode_type, char mode)