server_test.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 
31 #include <ros/ros.h>
32 
33 #include <gtest/gtest.h>
34 
36 
37 #include <chrono>
38 #include <thread>
39 
40 TEST(InteractiveMarkerServer, addRemove)
41 {
42  // create an interactive marker server on the topic namespace simple_marker
44 
45  // create an interactive marker for our server
46  visualization_msgs::InteractiveMarker int_marker;
47  int_marker.name = "marker1";
48 
49  // create a valid pose
50  geometry_msgs::Pose pose;
51  pose.orientation.w = 1.0;
52 
53  //insert, apply, erase, apply
54  server.insert(int_marker);
55  ASSERT_TRUE( server.get("marker1", int_marker) );
56 
57  server.applyChanges();
58  ASSERT_TRUE( server.get("marker1", int_marker) );
59 
60  ASSERT_TRUE( server.erase( "marker1" ) );
61  ASSERT_FALSE( server.get("marker1", int_marker) );
62 
63  server.applyChanges();
64  ASSERT_FALSE( server.get("marker1", int_marker) );
65 
66 
67  //insert, erase, apply
68  server.insert(int_marker);
69  ASSERT_TRUE( server.get("marker1", int_marker) );
70 
71  ASSERT_TRUE( server.erase( "marker1" ) );
72  ASSERT_FALSE( server.get("marker1", int_marker) );
73 
74  server.applyChanges();
75  ASSERT_FALSE( server.get("marker1", int_marker) );
76 
77  //insert, apply, clear, apply
78  server.insert(int_marker);
79  ASSERT_TRUE( server.get("marker1", int_marker) );
80 
81  server.applyChanges();
82  ASSERT_TRUE( server.get("marker1", int_marker) );
83 
84  server.clear();
85  ASSERT_FALSE( server.get("marker1", int_marker) );
86 
87  server.applyChanges();
88  ASSERT_FALSE( server.get("marker1", int_marker) );
89 
90  //insert, setPose, apply, clear, apply
91  server.insert(int_marker);
92  ASSERT_TRUE( server.setPose("marker1", pose) );
93 
94  server.applyChanges();
95  server.clear();
96  ASSERT_FALSE( server.get("marker1", int_marker) );
97 
98  server.applyChanges();
99 
100  // erase unknown marker
101  ASSERT_FALSE( server.erase("marker1") );
102 
103  //avoid subscriber destruction warning
104  std::this_thread::sleep_for(std::chrono::microseconds(1000));
105 }
106 
107 
108 // Run all the tests that were declared with TEST()
109 int main(int argc, char **argv)
110 {
111  ros::init(argc, argv, "im_server_test");
112  testing::InitGoogleTest(&argc, argv);
113  return RUN_ALL_TESTS();
114 }
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
boost::shared_ptr< interactive_markers::InteractiveMarkerServer > server
Definition: bursty_tf.cpp:43
TEST(InteractiveMarkerServer, addRemove)
Definition: server_test.cpp:40
INTERACTIVE_MARKERS_PUBLIC void insert(const visualization_msgs::InteractiveMarker &int_marker)
INTERACTIVE_MARKERS_PUBLIC bool setPose(const std::string &name, const geometry_msgs::Pose &pose, const std_msgs::Header &header=std_msgs::Header())
int main(int argc, char **argv)
INTERACTIVE_MARKERS_PUBLIC bool erase(const std::string &name)
INTERACTIVE_MARKERS_PUBLIC bool get(std::string name, visualization_msgs::InteractiveMarker &int_marker) const


interactive_markers
Author(s): David Gossow, William Woodall
autogenerated on Mon Feb 28 2022 22:33:22