Hello,
I want to stop a UR5 while it is executing a movement. Now, I have three different scripts. One which sends information like coordinates and variables. One which makes the UR5 execute a movement and the third script should stop the robot. My question is now, how can I stop the robot. I found a command which should stop it. I've read on some forum that it should work with some delay.
void moveit::planning_interface::MoveGroup::stop (void)
So my question basically is: How do I implement this void in my code in such a way that I can make the UR5 stop.
This is what I currently have.
#include
#include
#include
#include
#include
class StopRobot {
public:
int a;
int counter;
void stop(void);
void PublishCoordinatesCallback(const ur5_inf3480::Coor msg);
};
void StopRobot::PublishCoordinatesCallback(const ur5_inf3480::Coor msg) {
a = msg.a;
counter = msg.counter;
}
void StopRobot::stop(void) {
moveit::planning_interface::MoveGroup::stop();
}
int main(int argc, char **argv) {
ros::init(argc, argv, "coordinates");
ros::NodeHandle nh;
ros::Rate loop_rate(30);
StopRobot sr;
ros::Subscriber sub = nh.subscribe("coordinates", 1000, &StopRobot::PublishCoordinatesCallback, &sr);
int a = sr.a;
int counter = sr.counter;
while (ros::ok()) {
a = sr.a;
loop_rate.sleep();
ros::spinOnce();
if (a == 0) {
sr.stop();
}
}
return 0;
}
When I catkin_make the code like this it says that I can't call a member function without an object. I have tried to do different sorts of code but every code gives another error. So I'm a bit stuck now on how the usage of this certain command is.
Could someone please help me on this.
Thank you.
↧