errors while using moveit into class

asked 2019-10-18 09:20:19 -0600

sadeksadek gravatar image

updated 2019-10-18 10:39:13 -0600

gvdhoorn gravatar image

good Day guys

iam trying to use moveit classes to implement them into my class and when i try to put then into main function it works but i cant use them at function members and when i put them in public always there is no decleration and many errors so if anyone could help it would be very nice

and this is my file

using namespace std;
using namespace geometry_msgs;
namespace rvt = rviz_visual_tools;
char h;
class kuka
    ros::Publisher chatter_pub;
    ros::NodeHandle nh_;
    geometry_msgs::PoseStamped rob;
    geometry_msgs::PoseStamped cam;
    geometry_msgs::PoseStamped target_pose3 ;
        ros::Subscriber sub;
        ros::Subscriber sub_1;
        kuka(ros::NodeHandle &nh) //constructor 
          chatter_pub = nh_.advertise<geometry_msgs::PoseStamped>("/targpos", 1000);


    void status(void) //func showing the actual position (case0)

        cout<<"robot status is";
        cout<<"robot status sub";

    void callback(const geometry_msgs::PoseStamped::ConstPtr& rob)//callbackfunc showing the actual position (case0)
        cout<<"robot status";
        cout<<endl << "RobCoor.X: "<< rob->pose.position.x << endl << "RobCoor.Y:"<< rob->pose.position.y << endl << "RobCoor.Z: "<< rob->pose.position.z << endl <<"RobCoor.A: "<< rob->pose.orientation.x << endl << "RobCoor.B: "<<rob->pose.orientation.y << endl << "RobCoor.C: "<< rob->pose.orientation.z  << endl;

    void callback1(const geometry_msgs::PoseStamped::ConstPtr& rob)//callback func moving to home position (case1)
        cout<<"robot at Home "<< endl;
    if((rob->pose.orientation.x >=0.001||rob->pose.orientation.x<=-0.99)&&(rob->pose.orientation.y >=1.001||rob->pose.orientation.y <=0.99)&&(rob->pose.orientation.z >=0.001||rob->pose.orientation.z <=-0.99)&&(rob->pose.orientation.w >=0.001||rob->pose.orientation.w <=-0.99)){
    cout<<"robot  not at home position"<< endl;
        cout<<"would you like to plan way to home y or n   ";
         if(h =='y'){ 

    target_pose3.pose.orientation.x = 0;
    target_pose3.pose.orientation.y = 1;
    target_pose3.pose.orientation.z = 0;
    target_pose3.pose.orientation.w = 0;
    target_pose3.pose.position.x = -0.020;
    target_pose3.pose.position.y = 0.001;
    target_pose3.pose.position.z = 0.511;


        cout<<endl << "robCoor.X: "<< rob->pose.position.x << endl << "robCoor.Y:"<< rob->pose.position.y << endl << "robCoor.Z: "<< rob->pose.position.z << endl <<"robCoor.A: "<< rob->pose.orientation.x << endl << "robCoor.B: "<<rob->pose.orientation.y << endl << "robCoor.C: "<< rob->pose.orientation.z  << endl;
    if(h =='n'){ std:: cout<<"exit  "<<std::endl;}  

int main(int argc, char** argv)


    ros::init(argc, argv, "kuka");
    ros::NodeHandle nh;
    ros::AsyncSpinner spinner(1); spinner.start();
    static const std::string PLANNING_GROUP = "kr3";
    moveit::planning_interface::MoveGroupInterface move_group(PLANNING_GROUP);
    moveit::planning_interface::PlanningSceneInterface planning_scene_interface;
    const robot_state::JointModelGroup* joint_model_group =
robot_model_loader::RobotModelLoader robot_model_loader("robot_description");
  robot_model::RobotModelPtr kinematic_model = robot_model_loader.getModel();
  ROS_INFO("Model frame: %s", kinematic_model->getModelFrame().c_str());
 const robot_state::RobotStatePtr kinematic_state(new robot_state::RobotState(kinematic_model));
  const robot_state::JointModelGroup* joint_model_groups = kinematic_model->getJointModelGroup  (PLANNING_GROUP);
  const std::vector<std::string>& joint_names = joint_model_groups->getVariableNames();
    int j;  
    char loop='*';
    kuka listen_0(nh);
    kuka listen_1(nh);
     cout<<"|0 |check ...
edit retag flag offensive close merge delete