Difference between revisions of "API2"

From RobotinoWiki
(Getting started)
Line 1: Line 1:
 
==Introduction==
 
==Introduction==
{|cellspacing="20" cellpadding="10"
+
{|class="wikitable" cellpadding="20" vertical-align="top"
|- style="vertical-align:top"
+
|-
 
|[[Image:Robotino_api2_icon_64.png]]
 
|[[Image:Robotino_api2_icon_64.png]]
|The new API2 for Robotino is currently in its final stages of development and it is supposed to replace the current [[OpenRobotinoAPI]] on Robotino.
+
|A C/C++ library to access Robotino's sensors and actors from your own program.
! style="text-align:left; width:20em; background-color:#dddddd"|
+
|}
=== Package links ===
 
[[downloads#API2|API2 binary packages]]
 
  
[[downloads#CF_card_images|API2 ready to use CF card image]]
+
==Example==
|}
+
<pre>
 +
#include <iostream>
 +
#include "rec/robotino/api2/all.h"
 +
 
 +
rec::robotino::api2::Com com;
 +
rec::robotino::api2::Bumper bumper;
  
The new API2 is based on a RPC like infrastructure. The [http://servicerobotics.eu/weitere-projekte/rec-rpc-library/ REC-RPC] library is a interprocess communication middleware similar to ROS. It is completely based on Qt and does not have any other dependencies.
+
int main( int argc, char **argv )
 +
{
 +
  std::string hostname = "172.26.1.1";
 +
  if( argc > 1 )
 +
  {
 +
    hostname = argv[1];
 +
  }
  
Documentation can be found [http://doc.openrobotino.org/download/RobotinoAPI2/rec_robotino_api2/index.html here].
+
  com.setAddress( hostname.c_str() );
=== New features ===
+
  com.connectToServer( true );
The major new features introduced in the API2 are:
+
 
* Kinect sensor now supported
+
  while(com.isConnected() && false == bumper.value())
* Support for up to 4 cameras.
+
  {
* Support for up to 4 laser rangefinders.
+
    std::cout << "Bumper is " << (bumper.value()?"":"not") << " pressed" << std::endl;
* Support for camera controls like brightness, contrast, auto white balance (Note: The supported controls depend on the camera used).
+
    com.processEvents();
* Integrated web server for controlling Robotino by a web browser or your smartphone.
+
    rec::robotino::api2::msleep( 100 );
* Easier build process due to minimal dependencies on external libraries.
+
  }
* Uses TCP port 12080 for communication only. This minimizes problems with firewalls.
 
  
== Getting started ==
+
  com.disconnectFromServer();
* [[API2_quickstart|Quickstart guide to use API2]]
 
* [[Cpp2|How to build API2 examples]]
 
* [[Install_daemons_v3|How to install API2 daemons on Robotino]]
 
* [[Cpp2|C++ programming with API2]]
 
  
== Robotino API2 Overview ==
+
  rec::robotino::api2::shutdown();
  
<imagemap>Image:Api2_overview_600.png|
+
  return 0;
rect 0 96 103 144 [[smartsoft|]]
+
}
rect 25 158 103 204 [[dotnet|]]
+
</pre>
rect 25 215 103 263 [[java|]]
 
rect 0 285 81 334 [[matlab|]]
 
rect 1 347 81 393 [[labview|]]
 
rect 1 405 80 453 [[ROS|]]
 
rect 1 465 80 513 [[MRDS|]]
 
rect 111 46 163 509 [[Cpp|]]
 
rect 210 586 284 640 [[fcgid|]]
 
rect 185 689 297 743 [[fleetcomd|]]
 
rect 316 46 358 852 [[rpcd|]]
 
rect 391 46 464 101 [[controld3|]]
 
rect 390 121 464 175 [[lcdd2|]]
 
rect 391 196 464 251 [[camd2|]]
 
rect 391 330 464 386 [[ftdid|]]
 
rect 391 495 464 551 [[laserd2|]]
 
rect 391 600 464 654 [[robotinoxtd|]]
 
rect 391 720 464 775 [[grapplerd|]]
 
rect 391 794 464 851 [[kinectd|]]
 
rect 494 46 554 123 [[I/O_boards|]]
 
rect 496 136 568 187 [[display|]]
 
rect 495 197 557 272 [[camera|]]
 
rect 495 284 570 358 [[gyro|]]
 
rect 495 375 566 467 [[northstar|]]
 
rect 495 479 558 579 [[scanner|]]
 
rect 494 600 588 666 [[cbha|]]
 
rect 494 675 565 786 [[grappler|]]
 
rect 494 801 589 859 [[kinect|]]
 
rect 45 569 165 659 [[Robotino_Web_Interface|]]
 
</imagemap>
 

Revision as of 11:38, 18 March 2019

Introduction

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

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;
}