ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I have solved this problem. We need a loop to set the teach mode.

       std_msgs::String temp;
        std::string cmd_str;
//        std::string force_mode="force_mode( tool_pose(), [0, 0, 1, 0, 0, 0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 2, [0.05, 0.05, 0.05, 0.17, 0.17, 0.17])\n";
//        std::string free_drive_mode = "\tfreedrive_mode()\n";

        while(ros::ok()){
            bool last_io_button = io_button_;
            ros::spinOnce();
            if(!last_io_button && io_button_){
                cmd_str = "def myProg():\n";
                cmd_str += "\twhile (True):\n";
                cmd_str += "\t\tfreedrive_mode()\n";
                cmd_str +="\t\tsync()\n";
                cmd_str += "\tend\n";
                cmd_str +="end\n";
                temp.data = cmd_str;
                pub_free_drive_.publish(temp);
            }
            if(last_io_button && !io_button_){
                cmd_str = "def myProg():\n";
                cmd_str += "\twhile (True):\n";
                cmd_str += "\t\tend_freedrive_mode()\n";
                cmd_str +="\t\tsleep(0.5)\n";
                cmd_str += "\tend\n";
                cmd_str +="end\n";
                temp.data = cmd_str;
                pub_free_drive_.publish(temp);
            }

The detail is in ThomasTimm/ur_modern_driver#73