Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. |
Advanced movement options using asr_flir_ptu_driver.
Description: This tutorial will teach the reader how to use advanced functionalities of the asr_flir_ptu_driver.Tutorial Level: INTERMEDIATE
Next Tutorial: Settings configuration of asr_flir_ptu_driver. Link
Setup
Just as in the previous tutorial.
Again there is no real executable code but code pieces to show how things work.
Tutorial
This tutorial will show you how to use advanced functionalies of the PTU driver illustrated with the problem they solve.
Problem: How to tell if a new pan/tilt point will be rejected?
First (additional) include the following:
#include "asr_flir_ptu_driver/Validate.h"
After this, you can call a service that will tell you whether the point will get rejected or not. The following values are exemplarily.
ros::ServiceClient validatie_client; ros::NodeHandle nh; validate_client= nh.serviceClient<asr_flir_ptu_driver::Validate>(/Asr_flir_ptu_driver/validation_service); asr_flir_ptu_driver::Validate values_for_validation; values_for_validation.request.pan = 30.0; values_for_validation.request.tilt = -10.0; values_for_validation.request.margin = 0.1; //The margin if the point lies outside the pan tilt limits. Will result in setting the point to the limits if it is within the margin. validate_client.call(values_for_validation) if(values_for_validation.is_valid) { //Use the following values to work from here. If they double pan_value = values_for_validation.; double tilt_value = values_for_validation.; }else{ //The point got rejected, you have to choose another one }
Now you know that you have a point that will not be rejected (so to speak the PTU will move) or you know your point would get rejected and you can save time and checks shown in the previous tutorial.
Problem: Prevent passing through forbidden areas
It is assumed that the point you want to prevent from passing through a forbidden area lies within the pan/tilt limits (for example you can use the range-service to see the pan/tilt limits).
To check if a point passes through a forbidden area and to get the last legit point on the path (the point where it hits the forbidden area) the path prediction service is needed. Additionally, you need to include:
#include "asr_flir_ptu_driver/Predict.h"
Having this included you can proceed as the following (pan/tilt values are exemplarily):
ros::NodeHandle nh(""); ros::SeviceClient predict_client = nh.serviceClient<asr_flir_ptu_driver::Predict>("/asr_flir_ptu_driver/path_prediction"); asr_flir_ptu_driver::Predict end_point_prediction; end_point_prediction.request.pan = 42.0; end_point_prediction.request.tilt = -2.0; predict_client.call(end_point_prediction); double new_pan = end_point_prediction.response.new_pan; double new_tilt = end_point_prediction.response.new_tilt;
Use the new_pan and new_tilt values for the further calculations.
BE CAREFUL: When sending the the new values to the PTU, turn the check for forbidden areas off (you already know that the point will have no problems with forbidden areas at this point - keeping it on could cause some unjustified rejections because it might be 0.0001° inside the forbidden area):
asr_flir_ptu_driver::State msg; msg.no_check_forbidden_area = true; ...
Other Problems:
There are other services available (e.g. like the range service) that can be helpful as well. They are all explained in the corresponding documentation of the package, just read what they do and be creative.