示例#1
0
文件: main.cpp 项目: crawford/HoIP
int main(int argc, char *argv[]) {
	QApplication a(argc, argv);
	RobotController w;
	w.show();
	a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
	return a.exec();
}
示例#2
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    RobotController w;
    w.show();

    return a.exec();
}
示例#3
0
void quit(int sig)
{
  robot.stop();
  tcsetattr(kfd, TCSANOW, &cooked);
  ros::shutdown();
  exit(0);
}
示例#4
0
int main(int argc, char ** argv)
{
  ros::init(argc, argv, "teleop");

  ros::NodeHandle n("~");
  robot.init(n);
  robot.start();

  ros::Timer timer = n.createTimer(ros::Duration(0.05), callback);

  ros::AsyncSpinner spinner(1);
  spinner.start();

  signal(SIGINT, quit);

  char c;
  bool dirty=false;

  // get the console in raw mode
  tcgetattr(kfd, &cooked);
  memcpy(&raw, &cooked, sizeof(struct termios));
  raw.c_lflag &=~ (ICANON | ECHO);
  // Setting a new line, then end of file
  raw.c_cc[VEOL] = 1;
  raw.c_cc[VEOF] = 2;
  tcsetattr(kfd, TCSANOW, &raw);

  puts("Reading from keyboard");
  puts("---------------------------");
  puts("Use 'WASD' to translate");
  puts("Use arrow keys to move head");
  puts("Any other key to stop");

  while (ros::ok())
  {
    // get the next event from the keyboard
    if (read(kfd, &c, 1) < 0)
    {
      perror("read():");
      exit(-1);
    }

    last = ros::Time::now();
    robot.start();

    switch (c)
    {

    case KEYCODE_W:
      robot.setBaseVelocity(0.5, 0);
      break;
    case KEYCODE_S:
      robot.setBaseVelocity(-0.5, 0);
      break;
    case KEYCODE_A:
      robot.setBaseVelocity(0, 1.0);
      break;
    case KEYCODE_D:
      robot.setBaseVelocity(0, -1.0);
      break;

    case KEYCODE_RIGHT:
      robot.setHeadPosition(robot.getHeadPan() - 0.1, robot.getHeadTilt());
      break;
    case KEYCODE_LEFT:
      robot.setHeadPosition(robot.getHeadPan() + 0.1, robot.getHeadTilt());
      break;

    case KEYCODE_DOWN:
      robot.setHeadPosition(robot.getHeadPan(), robot.getHeadTilt() - 0.1);
      break;
    case KEYCODE_UP:
      robot.setHeadPosition(robot.getHeadPan(), robot.getHeadTilt() + 0.1);
      break;

    default:
      robot.setBaseVelocity(0, 0);
    }
  }

  return 0;
}
示例#5
0
void callback(const ros::TimerEvent&)
{
  if ((ros::Time::now() - last) > ros::Duration(0.5))
    robot.stop();
  robot.sendCommands();
}