Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set_robot_mode(ROBOT_MODE::ROBOT_MODE_MANUAL) doesn't seem to work after drl_stop #34

Open
gabri202 opened this issue Sep 7, 2023 · 0 comments

Comments

@gabri202
Copy link

gabri202 commented Sep 7, 2023

Hi,
I write because we found that after endind the program with drl_stop(), and sending set_robot_mode(ROBOT_MODE::ROBOT_MODE_MANUAL), the robot remains in in autonomous mode with the white led.

The api version is the latest available GL010118_20230324A.

I attach below an example for testing:

#include "DRFC.h"
#include "DRFL.h"
#include "DRFLEx.h"
#include "DRFS.h"
#include
#include <unistd.h>

static DRAFramework::CDRFLEx drfl;

int main(int argc, char *argv[]){

  /****************************/
  /*    OPEN CONNECTION       */
  /****************************/
  std::cout << "Open connection..." << endl;
  
  bool robotConnected = drfl.open_connection("192.168.0.100");
  

  if(robotConnected == 1){
      cout << "\tOpening done" << endl;
  }
  else{
      cout << "\tOpening failed" << endl;
      return -1;
  }

  usleep(1000000); 

  /****************************/
  /*       GET CONTROL	    */
  /****************************/
  std::cout << "Send robot control request... ";
  drfl.manage_access_control(MANAGE_ACCESS_CONTROL::MANAGE_ACCESS_CONTROL_FORCE_REQUEST);
  std::cout << "OK!" << std::endl;
  usleep(1000000);

  /****************************/
  /*		  SERVO ON	        */
  /****************************/
      std::cout << "Servo on" << std::endl;
  drfl.set_robot_control(ROBOT_CONTROL::CONTROL_RESET_SAFET_OFF);
  std::cout << "OK!" << std::endl;
  usleep(1000000);
  
  /****************************/
  /*		 SEND PROGRAM 		*/
  /****************************/
  std::cout << "Send program to robot" << endl;
  LPROBOT_POSE currentPose;
  currentPose = drfl.get_current_pose(ROBOT_SPACE::ROBOT_SPACE_TASK);

  std::string drlProgram  = "wait(1) \r\n";
  
  std::cout << "Program to send: " << std::endl << drlProgram << std::endl;

  // set robot in autonomous mode
  drfl.set_robot_mode(ROBOT_MODE::ROBOT_MODE_AUTONOMOUS); 
  usleep(1000000);
  
  ROBOT_SYSTEM targetSystem = ROBOT_SYSTEM::ROBOT_SYSTEM_REAL;
  
  
  std::cout << "Start program" << std::endl;
  drfl.drl_start(targetSystem, drlProgram);

  /****************************/
  /*  SEND STOP				*/
  /****************************/
  // after a sleep, send a stop command
  usleep(3000000);
  if (drfl.get_program_state() == DRL_PROGRAM_STATE::DRL_PROGRAM_STATE_PLAY) { 
    bool stop = drfl.drl_stop();
    if(stop)
  	  std::cout << "Stop sent correctly" << std::endl;
    else
  	  std::cout << "Error sending stop" << std::endl;
  }
  else{
      std::cout << "program not in execution" << std::endl;
  }

  while(drfl.get_program_state() == DRL_PROGRAM_STATE::DRL_PROGRAM_STATE_PLAY) {
      usleep(1000000);
  }
  std::cout << "Program state stop" << std::endl;
  drfl.set_robot_mode(ROBOT_MODE::ROBOT_MODE_MANUAL); 

  // Here we expect to change to manual mode
  // But we noticed that the robot remains in automatic mode
  // despite the set_robot_mode return  (success) 
  while (drfl.get_robot_mode() != ROBOT_MODE::ROBOT_MODE_MANUAL) {
      int mode = drfl.get_robot_mode(); 
      std::cout << "Robot mode: " << mode << std::endl;  // 0: MANUAL, 1: AUTONOMOUS
      int manual = drfl.set_robot_mode(ROBOT_MODE::ROBOT_MODE_MANUAL); 
      std::cout << "Changing robot mode: " << manual << std::endl;  // 0: Success, 1: error
      usleep(1000000);
  }
  std::cout << "Robot mode manual" << std::endl;

  while (1) { usleep(1000000); }

  return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant