41 #include "robocluedo_msgs/RandomRoom.h"
48 #define PATH_PARAMETER_SERVER_WHERE "cluedo_path_where"
49 #define SERVICE_RANDOM_ROOM "/random_room"
50 #define OUTLOG std::cout << "[cluedo_random_room] "
51 #define LOGSQUARE( str ) "[" << str << "] "
59 std::uniform_int_distribution<std::mt19937::result_type> randgen;
79 std::ifstream filestream( path );
80 if( !filestream.is_open( ) )
82 OUTLOG <<
"ERROR: no existing file!" << std::endl;
87 rooms = std::vector<std::string>( );
88 std::string temp =
"";
90 while( getline( filestream, temp ) )
94 rooms.push_back( temp );
98 OUTLOG <<
"closing file ..." << std::endl;
115 int generated_random_number = randgen( rng );
116 ROS_INFO(
"generated: %d", generated_random_number );
118 return rooms[ generated_random_number ];
138 bool ChooseRoomRandom( robocluedo_msgs::RandomRoom::Request& empty, robocluedo_msgs::RandomRoom::Response& room )
153 int main(
int argc,
char* argv[] )
155 ros::init( argc, argv,
"cluedo_random_room" );
171 int nRooms =
rooms.size( );
174 std::random_device dev;
176 rng = std::mt19937(dev());
177 randgen = std::uniform_int_distribution<std::mt19937::result_type>( 0, nRooms-1 );
185 OUTLOG <<
"ready!" << std::endl;