27 #include "asr_robot_model_services/CalculateCameraPose.h" 28 #include "asr_robot_model_services/CalculateCameraPoseCorrection.h" 29 #include "asr_robot_model_services/IsPositionAllowed.h" 30 #include "asr_robot_model_services/RobotStateMessage.h" 31 #include "asr_robot_model_services/GetPose.h" 32 #include "asr_robot_model_services/GetDistance.h" 33 #include <Eigen/Dense> 35 #include <eigen_conversions/eigen_msg.h> 43 bool getDistance(asr_robot_model_services::GetDistance::Request &req, asr_robot_model_services::GetDistance::Response &res)
45 res.distance = basicFunctionRobotModelPtr->getDistance(req.sourcePosition, req.targetPosition);
51 MILDRobotState * sourceRobotState =
new MILDRobotState(req.sourceRobotState.pan, req.sourceRobotState.tilt,req.sourceRobotState.rotation,req.sourceRobotState.x,req.sourceRobotState.y);
53 res.cameraFrame = basicFunctionRobotModelPtr->calculateCameraPose(sourceRobotStatePtr);
59 res.isAllowed = basicFunctionRobotModelPtr->isPositionAllowed(req.targetPosition);
65 res.pose = basicFunctionRobotModelPtr->getRobotPose();
71 res.pose = basicFunctionRobotModelPtr->getCameraPose();
77 MILDRobotState * sourceRobotState =
new MILDRobotState(req.sourceRobotState.pan, req.sourceRobotState.tilt,req.sourceRobotState.rotation,req.sourceRobotState.x,req.sourceRobotState.y);
79 SimpleVector3 position(req.position.x, req.position.y, req.position.z);
80 SimpleQuaternion orientation(req.orientation.w, req.orientation.x, req.orientation.y, req.orientation.z);
81 PTUConfig resultConfig = advancedFunctionRobotModelPtr->calculateCameraPoseCorrection(sourceRobotStatePtr, position, orientation);
82 res.pan = std::get<0>(resultConfig);
83 res.tilt = std::get<1>(resultConfig);
87 int main(
int argc,
char *argv[])
89 ros::init(argc, argv,
"getMovementCosts");
92 double panMin, panMax, tiltMin, tiltMax;
94 n.
param(
"panMin", panMin, -60.);
95 n.
param(
"panMax", panMax, 60.);
96 n.
param(
"tiltMin", tiltMin, -45.);
97 n.
param(
"tiltMax", tiltMax, 45.);
98 n.
param(
"robotModelId", robotModelId, 1);
105 advancedFunctionRobotModelPtr->setTiltAngleLimits(tiltMin, tiltMax);
106 advancedFunctionRobotModelPtr->setPanAngleLimits(panMin, panMax);
107 switch (robotModelId) {
117 basicFunctionRobotModelPtr->setTiltAngleLimits(tiltMin, tiltMax);
118 basicFunctionRobotModelPtr->setPanAngleLimits(panMin, panMax);
121 std::stringstream ss;
122 ss << robotModelId <<
" is not a valid robot model ID";
124 throw std::runtime_error(ss.str());
133 ROS_INFO(
"RobotModel Service started.");
bool processGetCameraPoseServiceCall(asr_robot_model_services::GetPose::Request &req, asr_robot_model_services::GetPose::Response &res)
MILDRobotModelWithExactIKPtr advancedFunctionRobotModelPtr
std::tuple< double, double > PTUConfig
MILDRobotModelWithExactIK implements a model of pan tilt unit robot where the inverse kinematic is ca...
boost::shared_ptr< MILDRobotModelWithApproximatedIK > MILDRobotModelWithApproximatedIKPtr
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool processIsPositionAllowedServiceCall(asr_robot_model_services::IsPositionAllowed::Request &req, asr_robot_model_services::IsPositionAllowed::Response &res)
ROSCPP_DECL const std::string & getName()
Eigen::Matrix< Precision, 3, 1 > SimpleVector3
MILDRobotModelWithApproximatedIK implements a model of pan tilt unit robot where the inverse kinemati...
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
bool getDistance(asr_robot_model_services::GetDistance::Request &req, asr_robot_model_services::GetDistance::Response &res)
int main(int argc, char *argv[])
ROSCPP_DECL void spin(Spinner &spinner)
bool processCalculateCameraPoseServiceCall(asr_robot_model_services::CalculateCameraPose::Request &req, asr_robot_model_services::CalculateCameraPose::Response &res)
bool processCalculateCameraPoseCorrectionServiceCall(asr_robot_model_services::CalculateCameraPoseCorrection::Request &req, asr_robot_model_services::CalculateCameraPoseCorrection::Response &res)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
this namespace contains all generally usable classes.
bool processGetRobotPoseServiceCall(asr_robot_model_services::GetPose::Request &req, asr_robot_model_services::GetPose::Response &res)
#define ROS_INFO_STREAM(args)
boost::shared_ptr< MILDRobotModelWithExactIK > MILDRobotModelWithExactIKPtr
#define ROS_ERROR_STREAM(args)
MILDRobotModelPtr basicFunctionRobotModelPtr
Eigen::Quaternion< Precision > SimpleQuaternion