Difference between revisions of "API2"

From RobotinoWiki
(Example)
Line 9: Line 9:
 
* [https://doc.openrobotino.org/download/RobotinoAPI2/rec_robotino_api2/ Documentation]
 
* [https://doc.openrobotino.org/download/RobotinoAPI2/rec_robotino_api2/ Documentation]
  
==Example==
+
==C++ example==
 
<pre>
 
<pre>
 
#include <iostream>
 
#include <iostream>

Revision as of 10:42, 18 March 2019

Introduction

Robotino api2 icon 64.png A C/C++ library to access Robotino's sensors and actors from your own program.

Quick links

C++ example

#include <iostream>
#include "rec/robotino/api2/all.h"

rec::robotino::api2::Com com;
rec::robotino::api2::Bumper bumper;

int main( int argc, char **argv )
{
  std::string hostname = "172.26.1.1";
  if( argc > 1 )
  {
    hostname = argv[1];
  }

  com.setAddress( hostname.c_str() );
  com.connectToServer( true );
  
  while(com.isConnected() && false == bumper.value())
  {
    std::cout << "Bumper is " << (bumper.value()?"":"not") << " pressed" << std::endl;
    com.processEvents();
    rec::robotino::api2::msleep( 100 );
  }

  com.disconnectFromServer();

  rec::robotino::api2::shutdown();

  return 0;
}