Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
cmake_minimum_required(VERSION 2.6.0)
cmake_minimum_required(VERSION 3.5.0)
set (CMAKE_CXX_STANDARD 11)

include_directories(include)
# project(proj VERSION 0.0.1 DESCRIPTION "GraphSDK wrapper to Julia system.")

# include_directories(include)
include_directories(src/test)

add_subdirectory(src)
20 changes: 20 additions & 0 deletions src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,28 @@ find_library(ZeroMQ_LIBRARY
PATHS ${PC_ZeroMQ_LIBRARY_DIRS}
)

message("CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}")

add_library(graffsdk SHARED GraffSDK.cpp)
# set_target_properties(graffsdk PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(graffsdk PROPERTIES PUBLIC_HEADER GraffSDK.h)
target_include_directories(graffsdk PRIVATE .)
include(GNUInstallDirs)
install(TARGETS graffsdk
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

add_executable(feitor-test main.cpp)
## add the include directory to our compile directives
target_include_directories(feitor-test PUBLIC ${ZeroMQ_INCLUDE_DIR})
## at the 0mq library to our link directive
target_link_libraries(feitor-test PUBLIC ${ZeroMQ_LIBRARY})
# target_link_libraries(feitor-test PUBLIC graffsdk)

# the api testing program
add_executable(api-test apitest.cpp)
## add the include directory to our compile directives
target_include_directories(api-test PUBLIC ${ZeroMQ_INCLUDE_DIR})
## at the 0mq library to our link directive
target_link_libraries(api-test PUBLIC ${ZeroMQ_LIBRARY})
target_link_libraries(api-test PUBLIC graffsdk)
17 changes: 17 additions & 0 deletions src/test/GraffSDK.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// GraffSDK
#include "GraffSDK.h"
#include <iostream>
#include "json.hpp"

using nlohmann::json;


std::string getStatus(const GraffConfig &cfg) {
json request;
request["userId"] = cfg.userId;
request["robotId"] = cfg.robotId;
request["sessionId"] = cfg.sessionId;
request["type"] = "getStatus";
std::string request_str = request.dump(2); // serialize
return request_str;
}
13 changes: 13 additions & 0 deletions src/test/GraffSDK.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// GraffSDK

#include <iostream>
#include "json.hpp"


struct GraffConfig {
std::string userId;
std::string robotId;
std::string sessionId;
};

std::string getStatus(const GraffConfig &cfg);
77 changes: 77 additions & 0 deletions src/test/apitest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include <chrono>
#include <iostream>
#include <string>
#include <thread>

#include <zmq.hpp>

#include "json.hpp"
#include "GraffSDK.h"

using nlohmann::json;

const double PI = 3.141592653589793238463;



int main(int argCount, char **argValues) {
// Prepare our context and socket
zmq::context_t context(1);
zmq::socket_t socket(context, ZMQ_REQ);

std::cout << "Connecting to navi server…" << std::endl;
socket.connect("tcp://localhost:5555");

std::string robot_id = "FeitorBot";
std::string session_id = "FeitorBotTestSession001";

GraffConfig gff;
gff.userId = "Pedro";
gff.robotId = "PedroBot";
gff.sessionId = "ThisIsACTest001";

std::cout << "made it this far" << std::endl;

std::string stsr = getStatus(gff);

zmq::message_t msg(stsr.length());
memcpy(msg.data(), stsr.c_str(), stsr.length());
socket.send(msg);


std::cout << "Asked for status" << std::endl;

// for (int i = 0; i < 6; ++i) {
// create request
// json request;
// request["robot_id"] = robot_id;
// request["session_id"] = session_id;
// request["type"] = "AddOdometry2D";
// request["measurement"] = {10.0, 0.0, PI / 3.0};
// request["covariance"] = {{0.1, 0.0, 0.1}, {0.1, 0.0, 0.1}, {0.1, 0.0, 0.1}};
// std::string request_str = request.dump(2); // serialize
//
// // send it
// zmq::message_t msg(request_str.length());
// memcpy(msg.data(), request_str.c_str(), request_str.length());
// socket.send(msg);
//
// std::cout << "Sent request " << i << "…";
//
// // wait for reply
// zmq::message_t reply;
// if (socket.recv(&reply) < 0) {
// std::cerr << "something went wrong :(";
// break;
// }
// std::string result =
// std::string(static_cast<char *>(reply.data()), reply.size());
// std::cout << result << "\n";
//
// if (result.compare("OK")) {
// std::cerr << "server is unhappy with request." << "\n";
// break;
// }
// }
return(0);
}
2 changes: 2 additions & 0 deletions src/test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ using nlohmann::json;

const double PI = 3.141592653589793238463;



int main(int argCount, char **argValues) {
// Prepare our context and socket
zmq::context_t context(1);
Expand Down