checkpoint_manager_test.cpp
Go to the documentation of this file.
00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 #include <ros/ros.h>
00004 #include <gtest/gtest.h>
00005 #include "rviz_marker_stub.cpp"
00006 
00007 #include "../../src/checkpoint_manager.h"
00008 
00009 TEST(CheckpointManager, check_checkpoint_srv)
00010 {
00011     RvizMarkerStub rviz_stub;
00012     iri_checkpoint_nav::Checkpoint checkpoint;
00013     ros::NodeHandle n;
00014 
00015     /* sleep one sec help to connect to rviz if it is being used. 
00016      * Otherwise it won't display the checkpoints */
00017     sleep(5);
00018 
00019     // Send a service over the topic "add_nav_checkpoint"
00020     checkpoint.request.ref_frame = "/map";
00021     checkpoint.request.position.x = 1;
00022     checkpoint.request.position.y = 1;
00023     checkpoint.request.position.z = 0;
00024 
00025     ros::ServiceClient client = n.serviceClient<iri_checkpoint_nav::Checkpoint>
00026                                                                        ("add_nav_checkpoint");
00027     client.call(checkpoint);
00028     usleep(400); // some time is needed to transmit the msg through topic
00029 
00030     ASSERT_EQ(rviz_stub.count_markers_received(),1);
00031 }
00032 
00033 TEST(CheckpointManager, checkpoint_start_srv)
00034 {
00035     RvizMarkerStub rviz_stub;
00036     iri_checkpoint_nav::ActionCheckpointNav reset_msg;
00037     iri_checkpoint_nav::ActionCheckpointNav start_msg;
00038 
00039     ros::NodeHandle n;
00040 
00041     reset_msg.request.action = 
00042         iri_checkpoint_nav::ActionCheckpointNav::Request::RESET_CHECKPOINTS;
00043     start_msg.request.action = 
00044         iri_checkpoint_nav::ActionCheckpointNav::Request::START_NAV;
00045 
00046     ros::ServiceClient client = n.serviceClient<iri_checkpoint_nav::ActionCheckpointNav>
00047                                                                       ("action_checkpoint_nav");
00048     client.call(reset_msg);
00049     usleep(200);
00050     ASSERT_TRUE(reset_msg.response.success);
00051 
00052     client.call(start_msg);
00053     usleep(200);
00054     ASSERT_TRUE(start_msg.response.success);
00055 }
00056 
00057 // Run all the tests that were declared with TEST()
00058 int main(int argc, char **argv)
00059 {
00060     ros::init(argc, argv, "checkpoint_manager_test");
00061 
00062     // create asynchronous thread for handling service requests
00063     ros::AsyncSpinner spinner(1);
00064     spinner.start();
00065 
00066     testing::InitGoogleTest(&argc, argv);
00067     return RUN_ALL_TESTS();
00068 }


iri_checkpoint_nav
Author(s): Jose Luis Rivero
autogenerated on Fri Dec 6 2013 22:56:28