7 #ifndef SERVICEFUNCTIONS_H 8 #define SERVICEFUNCTIONS_H 13 #include <pses_ucbridge/DeleteGroup.h> 14 #include <pses_ucbridge/GetControllerID.h> 15 #include <pses_ucbridge/GetDAQStatus.h> 16 #include <pses_ucbridge/GetFirmwareVersion.h> 17 #include <pses_ucbridge/GetIMUInfo.h> 18 #include <pses_ucbridge/GetInfoAllGroups.h> 19 #include <pses_ucbridge/GetInfoGroup.h> 20 #include <pses_ucbridge/GetKinectStatus.h> 21 #include <pses_ucbridge/GetMagASA.h> 22 #include <pses_ucbridge/GetMagInfo.h> 23 #include <pses_ucbridge/GetMotorLevel.h> 24 #include <pses_ucbridge/GetSessionID.h> 25 #include <pses_ucbridge/GetSteeringLevel.h> 26 #include <pses_ucbridge/GetUSInfo.h> 27 #include <pses_ucbridge/ResetController.h> 28 #include <pses_ucbridge/ResetDMS.h> 29 #include <pses_ucbridge/SetIMU.h> 30 #include <pses_ucbridge/SetMag.h> 31 #include <pses_ucbridge/SetMotorLevel.h> 32 #include <pses_ucbridge/SetSteering.h> 33 #include <pses_ucbridge/SetSessionID.h> 34 #include <pses_ucbridge/SetUS.h> 35 #include <pses_ucbridge/ToggleBrakes.h> 36 #include <pses_ucbridge/ToggleDAQ.h> 37 #include <pses_ucbridge/ToggleDMS.h> 38 #include <pses_ucbridge/ToggleGroup.h> 39 #include <pses_ucbridge/ToggleKinect.h> 40 #include <pses_ucbridge/ToggleMotor.h> 41 #include <pses_ucbridge/ToggleUS.h> 64 pses_ucbridge::DeleteGroup::Response& res,
Communication* com)
67 std::string cmd =
"Delete Group";
75 catch (std::exception& e)
78 "An error in Service 'Delete Group' occured!\n Description: " 94 pses_ucbridge::GetControllerID::Response& res,
97 res.answer_received =
false;
98 std::string cmd =
"Get Controller ID";
103 res.answer_received = com->
sendCommand(cmd, input, output);
104 if (!res.answer_received)
108 catch (std::exception& e)
111 "An error in Service 'Get Controller ID' occured!\n Description: " 113 res.answer_received =
false;
127 pses_ucbridge::GetDAQStatus::Response& res,
130 res.answer_received =
false;
131 std::string cmd =
"Is DAQ Started";
136 res.answer_received = com->
sendCommand(cmd, input, output);
137 if (!res.answer_received)
141 catch (std::exception& e)
144 "An error in Service 'Is DAQ Started' occured!\n Description: " 146 res.answer_received =
false;
160 pses_ucbridge::GetFirmwareVersion::Response& res,
163 res.answer_received =
false;
164 std::string cmd =
"Get Firmware Version";
169 res.answer_received = com->
sendCommand(cmd, input, output);
170 if (!res.answer_received)
174 catch (std::exception& e)
177 "An error in Service 'Get Firmware Version' occured!\n Description: " 179 res.answer_received =
false;
193 pses_ucbridge::GetIMUInfo::Response& res,
Communication* com)
195 res.answer_received =
false;
196 std::string cmd =
"Get IMU Info";
201 res.answer_received = com->
sendCommand(cmd, input, output);
202 if (!res.answer_received)
206 catch (std::exception& e)
209 "An error in Service 'Get IMU info' occured!\n Description: " 211 res.answer_received =
false;
225 pses_ucbridge::GetInfoAllGroups::Response& res,
228 res.answer_received =
false;
229 std::string cmd =
"All Groups Info";
234 res.answer_received = com->
sendCommand(cmd, input, output);
235 if (!res.answer_received)
239 catch (std::exception& e)
242 "An error in Service 'All Groups Info' occured!\n Description: " 244 res.answer_received =
false;
258 pses_ucbridge::GetInfoGroup::Response& res,
261 res.answer_received =
false;
262 std::string cmd =
"Group Info";
268 res.answer_received = com->
sendCommand(cmd, input, output);
269 if (!res.answer_received)
273 catch (std::exception& e)
275 ROS_WARN_STREAM(
"An error in Service 'Group Info' occured!\n Description: " 277 res.answer_received =
false;
291 pses_ucbridge::GetKinectStatus::Response& res,
294 res.answer_received =
false;
295 std::string cmd =
"Get Kinect Status";
300 res.answer_received = com->
sendCommand(cmd, input, output);
301 if (!res.answer_received)
305 catch (std::exception& e)
308 "An error in Service 'Get Kinect Status' occured!\n Description: " 310 res.answer_received =
false;
326 res.answer_received =
false;
327 std::string cmd =
"Get MAG ASA";
332 res.answer_received = com->
sendCommand(cmd, input, output);
333 if (!res.answer_received)
339 catch (std::exception& e)
341 ROS_WARN_STREAM(
"An error in Service 'Get Mag ASA' occured!\n Description: " 343 res.answer_received =
false;
357 pses_ucbridge::GetMagInfo::Response& res,
Communication* com)
359 res.answer_received =
false;
360 std::string cmd =
"Get MAG Info";
365 res.answer_received = com->
sendCommand(cmd, input, output);
366 if (!res.answer_received)
370 catch (std::exception& e)
373 "An error in Service 'Get Mag info' occured!\n Description: " 375 res.answer_received =
false;
389 pses_ucbridge::GetMotorLevel::Response& res,
392 res.answer_received =
false;
393 std::string cmd =
"Get Motor Level";
398 res.answer_received = com->
sendCommand(cmd, input, output);
399 if (!res.answer_received)
401 std::string direction;
405 if (direction.compare(
"F") != 0)
411 catch (std::exception& e)
414 "An error in Service 'Get Motor Level' occured!\n Description: " 416 res.answer_received =
false;
430 pses_ucbridge::GetSessionID::Response& res,
433 res.answer_received =
false;
434 std::string cmd =
"Get Session ID";
439 res.answer_received = com->
sendCommand(cmd, input, output);
440 if (!res.answer_received)
444 catch (std::exception& e)
447 "An error in Service 'Get Session ID' occured!\n Description: " 449 res.answer_received =
false;
463 pses_ucbridge::GetSteeringLevel::Response& res,
466 res.answer_received =
false;
467 std::string cmd =
"Get Steering Level";
472 res.answer_received = com->
sendCommand(cmd, input, output);
473 if (!res.answer_received)
477 catch (std::exception& e)
480 "An error in Service 'Get Steering Level' occured!\n Description: " 482 res.answer_received =
false;
498 res.answer_received =
false;
499 std::string cmd =
"Get US Info";
504 res.answer_received = com->
sendCommand(cmd, input, output);
505 if (!res.answer_received)
509 catch (std::exception& e)
511 ROS_WARN_STREAM(
"An error in Service 'Get US info' occured!\n Description: " 513 res.answer_received =
false;
527 pses_ucbridge::ResetController::Response& res,
531 std::string cmd =
"Reset Controller";
539 catch (std::exception& e)
542 "An error in Service 'Reset Controller' occured!\n Description: " 557 bool resetDMS(pses_ucbridge::ResetDMS::Request& req,
561 std::string cmd =
"Reset DMS";
566 res.was_set = com->
sendCommand(cmd, input, output);
568 catch (std::exception& e)
571 "An error in Service 'toggleDMS' occured!\n Description: " << e.what());
585 bool setIMU(pses_ucbridge::SetIMU::Request& req,
589 std::string cmd =
"Set IMU";
596 std::vector<std::string> options;
597 options.push_back(
"IMU_AccelRange");
598 options.push_back(
"IMU_AccelFilter");
599 options.push_back(
"IMU_GyroRange");
600 options.push_back(
"IMU_GyroFilter");
601 options.push_back(
"IMU_si_info");
604 res.was_set = com->
sendCommand(cmd, options, input, output);
607 catch (std::exception& e)
610 "An error in Service 'Set IMU' occured!\n Description: " << e.what());
624 bool setMag(pses_ucbridge::SetMag::Request& req,
628 std::string cmd =
"Set MAG";
631 unsigned char use_asa = req.use_asa;
633 std::vector<std::string> options;
634 options.push_back(
"MAG_USEASA");
637 res.was_set = com->
sendCommand(cmd, options, input, output);
639 catch (std::exception& e)
642 "An error in Service 'Set IMU' occured!\n Description: " << e.what());
657 pses_ucbridge::SetMotorLevel::Response& res,
661 std::string cmd =
"Drive Forward";
662 short level = req.level;
665 cmd =
"Drive Backward";
674 res.was_set = com->
sendCommand(cmd, input, output);
676 catch (std::exception& e)
679 "An error in Service 'Set Motor Level' occured!\n Description: " 695 pses_ucbridge::SetSessionID::Response& res,
699 std::string cmd =
"Set Session ID";
705 res.was_set = com->
sendCommand(cmd, input, output);
707 catch (std::exception& e)
710 "An error in Service 'Set Session ID' occured!\n Description: " 726 pses_ucbridge::SetSteering::Response& res,
730 std::string cmd =
"Set Steering Level";
736 res.was_set = com->
sendCommand(cmd, input, output);
738 catch (std::exception& e)
741 "An error in Service 'Set Steering Level' occured!\n Description: " 756 bool setUS(pses_ucbridge::SetUS::Request& req,
760 std::string cmd =
"Set US";
765 std::vector<std::string> options;
766 options.push_back(
"US_Range");
767 options.push_back(
"US_Gain");
768 options.push_back(
"US_si_info");
771 res.was_set = com->
sendCommand(cmd, options, input, output);
774 catch (std::exception& e)
777 "An error in Service 'Set US' occured!\n Description: " << e.what());
792 pses_ucbridge::ToggleBrakes::Response& res,
805 cmd =
"Drive Forward";
811 res.was_set = com->
sendCommand(cmd, input, output);
813 catch (std::exception& e)
816 "An error in Service 'Toggle Brakes' occured!\n Description: " 848 res.was_set = com->
sendCommand(cmd, input, output);
850 catch (std::exception& e)
852 ROS_WARN_STREAM(
"An error in Service 'Toggle DAQ' occured!\n Description: " 871 std::string cmd =
"Set Drv";
872 unsigned int interval = 0;
875 interval = req.dms_interval;
880 std::vector<std::string> options;
881 options.push_back(
"DMS_Interval");
885 res.was_set = com->
sendCommand(cmd, options, input, output);
887 catch (std::exception& e)
890 "An error in Service 'toggleDMS' occured!\n Description: " << e.what());
905 pses_ucbridge::ToggleGroup::Response& res,
Communication* com)
913 cmd =
"Activate Group";
917 cmd =
"Deactivate Group";
922 res.was_set = com->
sendCommand(cmd, input, output);
924 catch (std::exception& e)
927 "An error in Service 'Toggle Group' occured!\n Description: " 943 pses_ucbridge::ToggleKinect::Response& res,
952 cmd =
"Toggle Kinect On";
956 cmd =
"Toggle Kinect Off";
961 res.was_set = com->
sendCommand(cmd, input, output);
963 catch (std::exception& e)
966 "An error in Service 'Toggle Kinect' occured!\n Description: " 982 pses_ucbridge::ToggleMotor::Response& res,
Communication* com)
990 cmd =
"Drive Forward";
1000 res.was_set = com->
sendCommand(cmd, input, output);
1002 catch (std::exception& e)
1005 "An error in Service 'Toggle Motor' occured!\n Description: " 1007 res.was_set =
false;
1023 res.was_set =
false;
1029 cmd =
"Toggle US On";
1033 cmd =
"Toggle US Off";
1038 res.was_set = com->
sendCommand(cmd, input, output);
1040 catch (std::exception& e)
1043 "An error in Service 'Toggle US' occured!\n Description: " << e.what());
1044 res.was_set =
false;
1050 #endif // SERVICEFUNCTIONS_H bool getMagInfo(pses_ucbridge::GetMagInfo::Request &req, pses_ucbridge::GetMagInfo::Response &res, Communication *com)
A call to this Service will send a command to the serial device to transmit info about its magnetic f...
bool getUSInfo(pses_ucbridge::GetUSInfo::Request &req, pses_ucbridge::GetUSInfo::Response &res, Communication *com)
A call to this Service will send a command to the serial device to transmit the calibration of its ul...
Header file for the Communication class.
bool toggleKinect(pses_ucbridge::ToggleKinect::Request &req, pses_ucbridge::ToggleKinect::Response &res, Communication *com)
A call to this Service will send a command to the serial device to activate/deactivate the kinect pow...
bool getIMUInfo(pses_ucbridge::GetIMUInfo::Request &req, pses_ucbridge::GetIMUInfo::Response &res, Communication *com)
A call to this Service will send a command to the serial device to transmit the calibration of its IM...
bool toggleGroup(pses_ucbridge::ToggleGroup::Request &req, pses_ucbridge::ToggleGroup::Response &res, Communication *com)
A call to this Service will send a command to the serial device to activate/deactivate a particular g...
bool setSessionID(pses_ucbridge::SetSessionID::Request &req, pses_ucbridge::SetSessionID::Response &res, Communication *com)
A call to this Service will send a command to the serial device to set the current session id...
bool setUS(pses_ucbridge::SetUS::Request &req, pses_ucbridge::SetUS::Response &res, Communication *com)
A call to this Service will send a command to the serial device to change the calibration of its ultr...
bool deleteGroup(pses_ucbridge::DeleteGroup::Request &req, pses_ucbridge::DeleteGroup::Response &res, Communication *com)
A call to this Service will send a command to the serial device to delete a certain group...
bool getFirmwareVersion(pses_ucbridge::GetFirmwareVersion::Request &req, pses_ucbridge::GetFirmwareVersion::Response &res, Communication *com)
A call to this Service will send a command to the serial device to transmit its firmware version...
bool getInfoGroup(pses_ucbridge::GetInfoGroup::Request &req, pses_ucbridge::GetInfoGroup::Response &res, Communication *com)
A call to this Service will send a command to the serial device to transmit the info about a particul...
The Parameter::ParameterMap class provides a map functionality for Parameter::Parameter objects conta...
bool sendCommand(const std::string &command, const Parameter::ParameterMap &inputParams, Parameter::ParameterMap &outputParams, unsigned int timeout=100000)
Send a command to the servial device.
bool getKinectStatus(pses_ucbridge::GetKinectStatus::Request &req, pses_ucbridge::GetKinectStatus::Response &res, Communication *com)
A call to this Service will send a command to the serial device to transmit the power supply status o...
bool getInfoAllGroups(pses_ucbridge::GetInfoAllGroups::Request &req, pses_ucbridge::GetInfoAllGroups::Response &res, Communication *com)
A call to this Service will send a command to the serial device to transmit info about all registered...
bool setIMU(pses_ucbridge::SetIMU::Request &req, pses_ucbridge::SetIMU::Response &res, Communication *com)
A call to this Service will send a command to the serial device to change the calibration of its IMU...
bool getDAQStatus(pses_ucbridge::GetDAQStatus::Request &req, pses_ucbridge::GetDAQStatus::Response &res, Communication *com)
A call to this Service will send a command to the serial device to transmit the daq status...
bool getControllerID(pses_ucbridge::GetControllerID::Request &req, pses_ucbridge::GetControllerID::Response &res, Communication *com)
A call to this Service will send a command to the serial device to transmit its id.
The Communication class provides access to microcontroller communication.
bool toggleDMS(pses_ucbridge::ToggleDMS::Request &req, pses_ucbridge::ToggleDMS::Response &res, Communication *com)
A call to this Service will send a command to the serial device to activate/deactivate the dead man's...
void insertParameter(const std::string &name, const std::string &type, const T &value, const bool isValid=true)
Insert a new parameter in this map, with the given name, type and value.
bool getMotorLevel(pses_ucbridge::GetMotorLevel::Request &req, pses_ucbridge::GetMotorLevel::Response &res, Communication *com)
A call to this Service will send a command to the serial device to transmit the current motor level...
bool setMag(pses_ucbridge::SetMag::Request &req, pses_ucbridge::SetMag::Response &res, Communication *com)
A call to this Service will send a command to the serial device whether to use the magnetic field sen...
bool resetController(pses_ucbridge::ResetController::Request &req, pses_ucbridge::ResetController::Response &res, Communication *com)
A call to this Service will send a command to the serial device to do perform a soft reset...
Contains all service functions and their respective implementations.
bool resetDMS(pses_ucbridge::ResetDMS::Request &req, pses_ucbridge::ResetDMS::Response &res, Communication *com)
A call to this Service will send a command to the serial device to reset the counter on the dead man'...
bool toggleBrakes(pses_ucbridge::ToggleBrakes::Request &req, pses_ucbridge::ToggleBrakes::Response &res, Communication *com)
A call to this Service will send a command to the serial device to activate/deactivate its motor brak...
bool getSteeringLevel(pses_ucbridge::GetSteeringLevel::Request &req, pses_ucbridge::GetSteeringLevel::Response &res, Communication *com)
A call to this Service will send a command to the serial device to transmit the current steering leve...
bool toggleDAQ(pses_ucbridge::ToggleDAQ::Request &req, pses_ucbridge::ToggleDAQ::Response &res, Communication *com)
A call to this Service will send a command to the serial device to activate/deactivate the daq...
bool setSteeringLevel(pses_ucbridge::SetSteering::Request &req, pses_ucbridge::SetSteering::Response &res, Communication *com)
A call to this Service will send a command to the serial device to change the current steering level...
bool getMagASA(pses_ucbridge::GetMagASA::Request &req, pses_ucbridge::GetMagASA::Response &res, Communication *com)
A call to this Service will send a command to the serial device to transmit the calibration of its ma...
bool setMotorLevel(pses_ucbridge::SetMotorLevel::Request &req, pses_ucbridge::SetMotorLevel::Response &res, Communication *com)
A call to this Service will send a command to the serial device to change the current motor level...
bool getSessionID(pses_ucbridge::GetSessionID::Request &req, pses_ucbridge::GetSessionID::Response &res, Communication *com)
A call to this Service will send a command to the serial device to transmit its current session id...
void getParameterValue(const std::string &name, T &value) const
Get the value of a parameter in this map with the given name.
bool toggleMotor(pses_ucbridge::ToggleMotor::Request &req, pses_ucbridge::ToggleMotor::Response &res, Communication *com)
A call to this Service will send a command to the serial device to activate/deactivate the motor cont...
bool toggleUS(pses_ucbridge::ToggleUS::Request &req, pses_ucbridge::ToggleUS::Response &res, Communication *com)
A call to this Service will send a command to the serial device to activate/deactivate the ultra soni...