1#include <stdio.h>
2#include <iostream>
3#include <RobotRaconteur.h>
4#include "robotraconteur_generated.h"
5
6// Only use the RR alias in cpp files. Do not use it in header files.
7namespace RR = RobotRaconteur;
8
9#define M_PI 3.14159265358979323846
10
11int main(int argc, char* argv[])
12{
13 // Use RobotRaconteur::NodeSetup to initialize Robot Raconteur
14 RR::ClientNodeSetup node_setup(ROBOTRACONTEUR_SERVICE_TYPES);
15
16 // Connect to the service
17 std::string url = "rr+tcp://localhost:29200/?service=reynard";
18 auto reynard =
19 RR::rr_cast<experimental::reynard_the_robot::Reynard>(RR::RobotRaconteurNode::s()->ConnectService(url));
20
21 // Teleport the robot
22 reynard->teleport(0.1, -0.2);
23
24 // Drive the robot with no timeout
25 reynard->drive_robot(0.5, -0.2, -1, false);
26
27 // Wait for 1 second
28 RR::RobotRaconteurNode::s()->Sleep(boost::posix_time::milliseconds(1000));
29
30 // Stop the robot
31 reynard->drive_robot(0, 0, -1, false);
32
33 // Set the arm position
34 reynard->setf_arm_position(100.0 * (M_PI / 180.0), -30.0 * (M_PI / 180.0), -70.0 * (M_PI / 180.0));
35
36 // Drive the arm using timeout and wait
37 reynard->drive_arm(10.0 * (M_PI / 180.0), -30.0 * (M_PI / 180.0), -15.0 * (M_PI / 180.0), 1.5, true);
38
39 // Set the color to red
40 double red_color[] = {1.0, 0.0, 0.0};
41 RR::RRArrayPtr<double> color = RR::AttachRRArray<double>(red_color, 3, false);
42 reynard->set_color(color);
43
44 // Read the color
45 auto color_in = reynard->get_color();
46 std::cout << "Color: " << color_in->at(0) << " " << color_in->at(1) << " " << color_in->at(2) << std::endl;
47
48 RR::RobotRaconteurNode::s()->Sleep(boost::posix_time::milliseconds(1000));
49
50 // Reset the color
51 double reset_color_a[] = {0.929, 0.49, 0.129};
52 RR::RRArrayPtr<double> reset_color = RR::AttachRRArray<double>(reset_color_a, 3, false);
53 reynard->set_color(reset_color);
54
55 // Say hello
56 reynard->say("Hello, World From C++!");
57
58 return 0;
59}