2626#include " ur_client_library/primary/package_header.h"
2727#include " ur_client_library/primary/robot_state.h"
2828#include " ur_client_library/primary/robot_message.h"
29+ #include " ur_client_library/primary/robot_state/robot_mode_data.h"
30+ #include " ur_client_library/primary/robot_state/joint_data.h"
31+ #include " ur_client_library/primary/robot_state/cartesian_info.h"
2932#include " ur_client_library/primary/robot_state/kinematics_info.h"
33+ #include " ur_client_library/primary/robot_state/force_mode_data.h"
34+ #include " ur_client_library/primary/robot_state/additional_info.h"
35+ #include " ur_client_library/primary/robot_message/key_message.h"
36+ #include " ur_client_library/primary/robot_message/error_code_message.h"
37+ #include " ur_client_library/primary/robot_message/runtime_exception_message.h"
38+ #include " ur_client_library/primary/robot_message/text_message.h"
3039#include " ur_client_library/primary/robot_message/version_message.h"
40+ #include " ur_client_library/primary/program_state_message/global_variables_update_message.h"
41+ #include " ur_client_library/primary/program_state_message/global_variables_setup_message.h"
42+ #include < iomanip>
3143
3244namespace urcl
3345{
@@ -56,6 +68,7 @@ class PrimaryParser : public comm::Parser<PrimaryPackage>
5668 {
5769 int32_t packet_size;
5870 RobotPackageType type;
71+
5972 bp.parse (packet_size);
6073 bp.parse (type);
6174
@@ -115,7 +128,7 @@ class PrimaryParser : public comm::Parser<PrimaryPackage>
115128 case RobotPackageType::ROBOT_MESSAGE:
116129 {
117130 uint64_t timestamp;
118- uint8_t source;
131+ int8_t source;
119132 RobotMessagePackageType message_type;
120133
121134 bp.parse (timestamp);
@@ -134,9 +147,31 @@ class PrimaryParser : public comm::Parser<PrimaryPackage>
134147 break ;
135148 }
136149
150+ case RobotPackageType::PROGRAM_STATE_MESSAGE:
151+ {
152+ uint64_t timestamp;
153+ ProgramStateMessageType state_type;
154+ URCL_LOG_DEBUG (" ProgramStateMessage received" );
155+
156+ bp.parse (timestamp);
157+ bp.parse (state_type);
158+
159+ URCL_LOG_DEBUG (" ProgramStateMessage of type %d received" , static_cast <int >(state_type));
160+
161+ std::unique_ptr<PrimaryPackage> packet (programStateFromType (state_type, timestamp));
162+ if (!packet->parseWith (bp))
163+ {
164+ URCL_LOG_ERROR (" Package parsing of type %d failed!" , static_cast <int >(state_type));
165+ return false ;
166+ }
167+
168+ results.push_back (std::move (packet));
169+ return true ;
170+ }
171+
137172 default :
138173 {
139- URCL_LOG_DEBUG (" Invalid robot package type recieved : %u" , static_cast <uint8_t >(type));
174+ URCL_LOG_DEBUG (" Invalid robot package type received : %u" , static_cast <uint8_t >(type));
140175 bp.consume ();
141176 return true ;
142177 }
@@ -149,14 +184,18 @@ class PrimaryParser : public comm::Parser<PrimaryPackage>
149184 {
150185 switch (type)
151186 {
152- /* case robot_state_type ::ROBOT_MODE_DATA:
153- // SharedRobotModeData* rmd = new SharedRobotModeData( );
154-
155- // return new rmd ;
156- case robot_state_type::MASTERBOARD_DATA :
157- return new MBD; */
187+ case RobotStateType ::ROBOT_MODE_DATA:
188+ return new RobotModeData (type );
189+ case RobotStateType::JOINT_DATA:
190+ return new JointData (type) ;
191+ case RobotStateType::CARTESIAN_INFO :
192+ return new CartesianInfo (type);
158193 case RobotStateType::KINEMATICS_INFO:
159194 return new KinematicsInfo (type);
195+ case RobotStateType::FORCE_MODE_DATA:
196+ return new ForceModeData (type);
197+ case RobotStateType::ADDITIONAL_INFO:
198+ return new AdditionalInfo (type);
160199 default :
161200 return new RobotState (type);
162201 }
@@ -166,16 +205,31 @@ class PrimaryParser : public comm::Parser<PrimaryPackage>
166205 {
167206 switch (type)
168207 {
169- /* case robot_state_type::ROBOT_MODE_DATA:
170- // SharedRobotModeData* rmd = new SharedRobotModeData();
171-
172- //return new rmd;
173- case robot_state_type::MASTERBOARD_DATA:
174- return new MBD;*/
175208 case RobotMessagePackageType::ROBOT_MESSAGE_VERSION:
176209 return new VersionMessage (timestamp, source);
210+ case RobotMessagePackageType::ROBOT_MESSAGE_TEXT:
211+ return new TextMessage (timestamp, source);
212+ case RobotMessagePackageType::ROBOT_MESSAGE_KEY:
213+ return new KeyMessage (timestamp, source);
214+ case RobotMessagePackageType::ROBOT_MESSAGE_ERROR_CODE:
215+ return new ErrorCodeMessage (timestamp, source);
216+ case RobotMessagePackageType::ROBOT_MESSAGE_RUNTIME_EXCEPTION:
217+ return new RuntimeExceptionMessage (timestamp, source);
218+ default :
219+ return new RobotMessage (timestamp, source, type);
220+ }
221+ }
222+
223+ ProgramStateMessage* programStateFromType (ProgramStateMessageType type, uint64_t timestamp)
224+ {
225+ switch (type)
226+ {
227+ case ProgramStateMessageType::GLOBAL_VARIABLES_SETUP:
228+ return new GlobalVariablesSetupMessage (timestamp);
229+ case ProgramStateMessageType::GLOBAL_VARIABLES_UPDATE:
230+ return new GlobalVariablesUpdateMessage (timestamp);
177231 default :
178- return new RobotMessage (timestamp, source );
232+ return new ProgramStateMessage (timestamp, type );
179233 }
180234 }
181235};
0 commit comments