EGM Not Executing Movements - Issue with Protobuf Messages in ABB RobotStudio
Hi everyone,
I’m currently working on a project involving ABB RobotStudio where I’m using External Guided Motion (EGM) to control a robot through UDP messages. The robot should move based on the joint positions I send from Simulink, but it’s not executing the movements as expected. Here’s a detailed breakdown of what I’ve done so far:
Setup:
I’m using Simulink to generate the joint position data, which is then serialized using Protobuf. The serialized data is sent via UDP to the robot.
`/* Includes_BEGIN /
#include <math.h>
#include <iostream>
#include <fstream>
#include "egm.pb.h"
#include <Windows.h>
#include <sysinfoapi.h>
/ Includes_END */
/* Externs_BEGIN /
/ extern double func(double a); /
/ Externs_END */
void sensor_proto_Start_wrapper(SimStruct S)
{
/ Start_BEGIN /
/
- Custom Start code goes here.
/
/ Start_END */
}
void sensor_proto_Outputs_wrapper(const real_T *J1,
const real_T *J2,
const real_T *J3,
const real_T *J4,
const real_T *J5,
const real_T *J6,
uint8_T *serialized_sensor_message,
int32_T *sensor_message_byte_len,
SimStruct S)
{
/ Output_BEGIN */
static unsigned int sequenceNumber = 0;
abb::egm::EgmHeader *header = new abb::egm::EgmHeader();
header->set_seqno(sequenceNumber++);
header->set_tm(GetTickCount());
header->set_mtype(::abb::egm::EgmHeader_MessageType_MSGTYPE_CORRECTION);
abb::egm::EgmJoints *joint_var = new abb::egm::EgmJoints();
joint_var->add_joints(J1[0]);
joint_var->add_joints(J2[0]);
joint_var->add_joints(J3[0]);
joint_var->add_joints(J4[0]);
joint_var->add_joints(J5[0]);
joint_var->add_joints(J6[0]);
abb::egm::EgmPlanned *planned = new abb::egm::EgmPlanned();
//planned.mutable_joints()->CopyFrom(joint_var);
planned->set_allocated_joints(joint_var);
abb::egm::EgmSensor *sensor_message = new abb::egm::EgmSensor ();
sensor_message->set_allocated_header(header);
sensor_message->set_allocated_planned(planned);
*sensor_message_byte_len = sensor_message->ByteSizeLong();
sensor_message->SerializeToArray(serialized_sensor_message,sensor_message_byte_len);
/ Output_END */
}
void sensor_proto_Terminate_wrapper(SimStruct S)
{
/ Terminate_BEGIN /
/
- Custom Terminate code goes here.
/
/ Terminate_END */
}`
Protobuf Setup:
I’ve defined the Protobuf messages in a .proto file, which includes EgmSensor, EgmHeader, and EgmPlanned messages. These messages are built correctly in C++ and serialized before sending.
RobotStudio Configuration:
I’ve configured the Transmission Protocol in RobotStudio to receive messages on the correct IP address and port (127.0.0.1:5514).
The robot appears to receive the messages (no errors in the UDP communication), but it doesn’t execute the movement.
made on local host cause i'm working on the same computer
Problem:
Despite everything seeming correct, the robot does not move to the new joint positions. I’ve confirmed that the messages are being sent, but the robot stays in its initial position.
What I’ve Tried:
Ensured that the values of the joint positions are within valid limits.
Checked the serialization process to ensure that the data is correctly formatted.
Monitored the logs in RobotStudio, but haven’t found any clear indications of what might be wrong.
ROBOT STUDIO SETTINGS ARE
rapid program
`MODULE TestyEGM
VAR egmident egmID1;
VAR egmstate egmSt1;
CONST egm_minmax egm_minmax_joint:=[-1,1]; CONST robtarget p10:=[[364.35,0,594],[0.5,0,0.866025,0],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]; CONST robtarget p30:=[[374,0,630],[0.707112,0,0.707102,0],[0,0,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]; PROC main() !procedura EGM_JOINT_MOVEMENT; ENDPROC PROC EGM_JOINT_MOVEMENT() IF egmSt1=EGM_STATE_DISCONNECTED THEN TPWrite "preparing controller for egm"; ENDIF ! Ottieni un ID per l'EGM EGMGetId egmID1; ! Ottieni lo stato dell'EGM egmSt1:=EGMGetState(egmID1); TPWrite "EGM state: "\num:=egmSt1; ! Verifica se l'EGM connesso IF egmSt1<=EGM_STATE_CONNECTED THEN EGMSetupUC ROB_1,egmID1,"default","TestyEGM"\Joint; TPWrite "EGM is connected, now link to UDP"; ELSE TPWrite "EGM not connected"; ENDIF EGMStreamStart egmID1\SampleRate:=4; ! Muovi il robot alle posizioni iniziali MoveJ p10,v100,fine,tool0; !WaitTime 5; MoveJ p30,v100,fine,tool0; ! Avvia lo streaming, deseriallizzando i messaggi dal device esterno EGMActJoint egmID1,\StreamStart,\Tool:=tool0,\WObj:=wobj0, \J1:=egm_minmax_joint, \J2:=egm_minmax_joint, \J3:=egm_minmax_joint, \J4:=egm_minmax_joint, \J5:=egm_minmax_joint, \J6:=egm_minmax_joint; WaitTime 3; WHILE egmSt1<>EGM_STATE_RUNNING DO egmSt1:=EGMGetState(egmID1); TPWrite "Waiting for EGM to be ready. Current state: "\num:=egmSt1; WaitTime 0.5; ENDWHILE WaitTime 3; ! Verifica se l'EGM è pronto a partire IF egmSt1=EGM_STATE_RUNNING THEN TPWrite "EGM is ready to run. Starting EGMRunJoint."; ELSE TPWrite "EGM not ready. State: "\num:=egmSt1; EXIT; ENDIF WaitTime 3; WHILE TRUE DO !Avvia la corsa EGM in modalità joint EGMRunJoint egmID1,EGM_STOP_RAMP_DOWN,\NoWaitCond,\J1,\J2,\J3,\J4,\J5,\J6; ENDWHILE ! Controlla di nuovo lo stato dell'EGM IF egmSt1=EGM_STATE_CONNECTED THEN TPWrite "waiting movement"; ENDIF ! Verifica se l'EGM in esecuzione IF egmSt1=EGM_STATE_RUNNING THEN TPWrite "EGM is running in Position Guidance mode."; ELSE TPWrite "EGM state: "\num:=egmSt1; ENDIF ! Ferma l'EGM e resettalo IF egmSt1<=EGM_STATE_RUNNING THEN TPWrite "resetting EGM..."; EGMReset egmID1; TPWrite "EGM reset complete."; ENDIF !in caso esce dal while check dell'errore ERROR IF ERRNO=ERR_UDPUC_COMM THEN TPWrite "egm has no external device"; ENDIF ENDPROC
ENDMODULE`
Is there something specific I need to configure in RobotStudio to handle these EGM messages correctly?
or something it's wrong? i can't figure out
Comments
-
dario_mus said:
Hi everyone,
I’m currently working on a project involving ABB RobotStudio where I’m using External Guided Motion (EGM) to control a robot through UDP messages. The robot should move based on the joint positions I send from Simulink, but it’s not executing the movements as expected. Here’s a detailed breakdown of what I’ve done so far:
Setup:
I’m using Simulink to generate the joint position data, which is then serialized using Protobuf. The serialized data is sent via UDP to the robot.
`/* Includes_BEGIN /#include <math.h>
#include <iostream>
#include <fstream>
#include "egm.pb.h"
#include <Windows.h>
#include <sysinfoapi.h>
/ Includes_END */
/* Externs_BEGIN /
/ extern double func(double a); /
/ Externs_END */void sensor_proto_Start_wrapper(SimStruct S)
{
/ Start_BEGIN /
/- Custom Start code goes here.
/
/ Start_END */
}
void sensor_proto_Outputs_wrapper(const real_T *J1,
const real_T *J2,
const real_T *J3,
const real_T *J4,
const real_T *J5,
const real_T *J6,
uint8_T *serialized_sensor_message,
int32_T *sensor_message_byte_len,
SimStruct S)
{
/ Output_BEGIN */
static unsigned int sequenceNumber = 0;abb::egm::EgmHeader *header = new abb::egm::EgmHeader();
header->set_seqno(sequenceNumber++);
header->set_tm(GetTickCount());
header->set_mtype(::abb::egm::EgmHeader_MessageType_MSGTYPE_CORRECTION);abb::egm::EgmJoints *joint_var = new abb::egm::EgmJoints();
joint_var->add_joints(J1[0]);
joint_var->add_joints(J2[0]);
joint_var->add_joints(J3[0]);
joint_var->add_joints(J4[0]);
joint_var->add_joints(J5[0]);
joint_var->add_joints(J6[0]);abb::egm::EgmPlanned *planned = new abb::egm::EgmPlanned();
//planned.mutable_joints()->CopyFrom(joint_var);
planned->set_allocated_joints(joint_var);abb::egm::EgmSensor *sensor_message = new abb::egm::EgmSensor ();
sensor_message->set_allocated_header(header);
sensor_message->set_allocated_planned(planned);*sensor_message_byte_len = sensor_message->ByteSizeLong();
sensor_message->SerializeToArray(serialized_sensor_message,sensor_message_byte_len);
/ Output_END */
}void sensor_proto_Terminate_wrapper(SimStruct S)
{
/ Terminate_BEGIN /
/- Custom Terminate code goes here.
/
/ Terminate_END */
}`
Protobuf Setup:
I’ve defined the Protobuf messages in a .proto file, which includes EgmSensor, EgmHeader, and EgmPlanned messages. These messages are built correctly in C++ and serialized before sending.
RobotStudio Configuration:
I’ve configured the Transmission Protocol in RobotStudio to receive messages on the correct IP address and port (127.0.0.1:5514).
The robot appears to receive the messages (no errors in the UDP communication), but it doesn’t execute the movement.
made on local host cause i'm working on the same computerProblem:
Despite everything seeming correct, the robot does not move to the new joint positions. I’ve confirmed that the messages are being sent, but the robot stays in its initial position.
What I’ve Tried:
Ensured that the values of the joint positions are within valid limits.
Checked the serialization process to ensure that the data is correctly formatted.
Monitored the logs in RobotStudio, but haven’t found any clear indications of what might be wrong.ROBOT STUDIO SETTINGS ARE
rapid program
`MODULE TestyEGM
VAR egmident egmID1;
VAR egmstate egmSt1;CONST egm_minmax egm_minmax_joint:=[-1,1]; CONST robtarget p10:=[[364.35,0,594],[0.5,0,0.866025,0],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]; CONST robtarget p30:=[[374,0,630],[0.707112,0,0.707102,0],[0,0,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]; PROC main() !procedura EGM_JOINT_MOVEMENT; ENDPROC PROC EGM_JOINT_MOVEMENT() IF egmSt1=EGM_STATE_DISCONNECTED THEN TPWrite "preparing controller for egm"; ENDIF ! Ottieni un ID per l'EGM EGMGetId egmID1; ! Ottieni lo stato dell'EGM egmSt1:=EGMGetState(egmID1); TPWrite "EGM state: "\num:=egmSt1; ! Verifica se l'EGM connesso IF egmSt1<=EGM_STATE_CONNECTED THEN EGMSetupUC ROB_1,egmID1,"default","TestyEGM"\Joint; TPWrite "EGM is connected, now link to UDP"; ELSE TPWrite "EGM not connected"; ENDIF EGMStreamStart egmID1\SampleRate:=4; ! Muovi il robot alle posizioni iniziali MoveJ p10,v100,fine,tool0; !WaitTime 5; MoveJ p30,v100,fine,tool0; ! Avvia lo streaming, deseriallizzando i messaggi dal device esterno EGMActJoint egmID1,\StreamStart,\Tool:=tool0,\WObj:=wobj0, \J1:=egm_minmax_joint, \J2:=egm_minmax_joint, \J3:=egm_minmax_joint, \J4:=egm_minmax_joint, \J5:=egm_minmax_joint, \J6:=egm_minmax_joint; WaitTime 3; WHILE egmSt1<>EGM_STATE_RUNNING DO egmSt1:=EGMGetState(egmID1); TPWrite "Waiting for EGM to be ready. Current state: "\num:=egmSt1; WaitTime 0.5; ENDWHILE WaitTime 3; ! Verifica se l'EGM è pronto a partire IF egmSt1=EGM_STATE_RUNNING THEN TPWrite "EGM is ready to run. Starting EGMRunJoint."; ELSE TPWrite "EGM not ready. State: "\num:=egmSt1; EXIT; ENDIF WaitTime 3; WHILE TRUE DO !Avvia la corsa EGM in modalità joint EGMRunJoint egmID1,EGM_STOP_RAMP_DOWN,\NoWaitCond,\J1,\J2,\J3,\J4,\J5,\J6; ENDWHILE ! Controlla di nuovo lo stato dell'EGM IF egmSt1=EGM_STATE_CONNECTED THEN TPWrite "waiting movement"; ENDIF ! Verifica se l'EGM in esecuzione IF egmSt1=EGM_STATE_RUNNING THEN TPWrite "EGM is running in Position Guidance mode."; ELSE TPWrite "EGM state: "\num:=egmSt1; ENDIF ! Ferma l'EGM e resettalo IF egmSt1<=EGM_STATE_RUNNING THEN TPWrite "resetting EGM..."; EGMReset egmID1; TPWrite "EGM reset complete."; ENDIF !in caso esce dal while check dell'errore ERROR IF ERRNO=ERR_UDPUC_COMM THEN TPWrite "egm has no external device"; ENDIF ENDPROC
ENDMODULE`
Is there something specific I need to configure in RobotStudio to handle these EGM messages correctly?
or something it's wrong? i can't figure out0 - Custom Start code goes here.
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 800 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings