MoveIt stop command usage
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 <iostream>
#include <ros/ros.h>
#include <moveit/move_group_interface/move_group.h>
#include <sstream>
#include <ur5_inf3480/Coor.h>
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<ur5_inf3480::Coor>("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 gives the following error.
/home/lauran/ur5robot_ws/src/ur5_inf3480/src/stop_robot.cpp: In member function ‘void StopRobot::stop()’:
/home/lauran/ur5robot_ws/src/ur5_inf3480/src/stop_robot.cpp:22:46: error: cannot call member function ‘void moveit::planning_interface::MoveGroup::stop()’ without object
moveit::planning_interface::MoveGroup::stop();
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.
Can you please update your question with a copy and paste of the errors (not a screenshot)? This way we don't have to mentally compile the code to figure out what the error is. Thanks.
Yes of course, sorry for that.