Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "industrial_robot_client/robot_status_relay_handler.h"
00033 #include "industrial_msgs/RobotStatus.h"
00034 #include "simple_message/log_wrapper.h"
00035
00036 using namespace industrial::shared_types;
00037 using namespace industrial::smpl_msg_connection;
00038 using namespace industrial::simple_message;
00039 using namespace industrial::robot_status;
00040 using namespace industrial::robot_status_message;
00041
00042 namespace industrial_robot_client
00043 {
00044 namespace robot_status_relay_handler
00045 {
00046
00047 bool RobotStatusRelayHandler::init(SmplMsgConnection* connection)
00048 {
00049 this->pub_robot_status_ = this->node_.advertise<industrial_msgs::RobotStatus>("robot_status", 1);
00050 return init((int)StandardMsgTypes::STATUS, connection);
00051 }
00052
00053 bool RobotStatusRelayHandler::internalCB(SimpleMessage& in)
00054 {
00055 RobotStatusMessage status_msg;
00056
00057 if (!status_msg.init(in))
00058 {
00059 LOG_ERROR("Failed to initialize status message");
00060 return false;
00061 }
00062
00063 return internalCB(status_msg);
00064 }
00065
00066 bool RobotStatusRelayHandler::internalCB(RobotStatusMessage & in)
00067 {
00068 industrial_msgs::RobotStatus status;
00069 bool rtn = true;
00070
00071 status.drives_powered.val = TriStates::toROSMsgEnum(in.status_.getDrivesPowered());
00072 status.e_stopped.val = TriStates::toROSMsgEnum(in.status_.getEStopped());
00073 status.error_code = in.status_.getErrorCode();
00074 status.in_error.val = TriStates::toROSMsgEnum(in.status_.getInError());
00075 status.in_motion.val = TriStates::toROSMsgEnum(in.status_.getInMotion());
00076 status.mode.val = RobotModes::toROSMsgEnum(in.status_.getMode());
00077 status.motion_possible.val = TriStates::toROSMsgEnum(in.status_.getMotionPossible());
00078
00079 this->pub_robot_status_.publish(status);
00080
00081
00082 if (CommTypes::SERVICE_REQUEST == in.getMessageType())
00083 {
00084 SimpleMessage reply;
00085 in.toReply(reply, rtn ? ReplyTypes::SUCCESS : ReplyTypes::FAILURE);
00086 this->getConnection()->sendMsg(reply);
00087 }
00088
00089 return rtn;
00090 }
00091
00092 }
00093 }
00094