Main Page
Namespaces
Classes
Files
File List
File Members
test
helpers.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2018 Open Source Robotics Foundation
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
*/
17
18
#ifndef ROBOTX_GAZEBO_TEST_HELPERS_HH_
19
#define ROBOTX_GAZEBO_TEST_HELPERS_HH_
20
21
#include <gazebo_msgs/ModelStates.h>
22
#include <
ros/ros.h
>
23
#include <string>
24
29
bool
ModelExists
(
const
std::string &_name,
30
const
ros::WallDuration
_timeout =
ros::WallDuration
(5, 0))
31
{
32
ros::WallTime
timeout =
ros::WallTime::now
() + _timeout;
33
while
(
ros::WallTime::now
() < timeout)
34
{
35
gazebo_msgs::ModelStatesConstPtr modelStates =
36
ros::topic::waitForMessage<gazebo_msgs::ModelStates>(
37
std::string(
"/gazebo/model_states"
),
ros::Duration
(0.1));
38
39
if
(!modelStates)
continue
;
40
for
(
auto
model : modelStates->name)
41
{
42
if
(model == _name)
43
return
true
;
44
}
45
}
46
return
false
;
47
}
48
#endif
ros::WallDuration
ros::WallTime
ModelExists
bool ModelExists(const std::string &_name, const ros::WallDuration _timeout=ros::WallDuration(5, 0))
Check whether a model exists on simulation.
Definition:
helpers.hh:29
ros.h
ros::Duration
ros::WallTime::now
static WallTime now()
vrx_gazebo
Author(s): Brian Bingham
, Carlos Aguero
autogenerated on Thu May 7 2020 03:54:56