有多少人工,就有多少智能

Franka demo1 - 输出机器人状态(echo_robot_state)

// Copyright (c) 2023 Franka Robotics GmbH
// Use of this source code is governed by the Apache-2.0 license, see LICENSE
#include <iostream>

#include <franka/exception.h>
#include <franka/robot.h>

/**
 * @example echo_robot_state.cpp
 * An example showing how to continuously read the robot state.该示例展示如何连续读取机器人状态(1k Hz)
 */

int main(int argc, char** argv) { // 输入机器人IP
  if (argc != 2) {
    std::cerr << "Usage: " << argv[0] << " <robot-hostname>" << std::endl;
    return -1;
  }

  try {
    franka::Robot robot(argv[1]); // 初始化机器人模型 

    size_t count = 0;
    robot.read([&count](const franka::RobotState& robot_state) { // 连续回调读取机器人状态
      // Printing to std::cout adds a delay. This is acceptable for a read loop such as this, but
      // should not be done in a control loop.
      std::cout << robot_state << std::endl;
      return count++ < 100; // 读取100次,返回false, 停止读取。
    });

    std::cout << "Done." << std::endl;
  } catch (franka::Exception const& e) {
    std::cout << e.what() << std::endl;
    return -1;
  }

  return 0;
}

 

 

posted @ 2024-07-09 23:07  lvdongjie-avatarx  阅读(3)  评论(0编辑  收藏  举报