test/integration/kinetic_energy_monitor_system.cc
/////////////////////////////////////////////////
// The test checks the world pose and sensor readings of a falling altimeter
The test checks the world pose and sensor readings of a falling altimeter
The test checks the world pose and sensor readings of a falling altimeter
TEST_F(KineticEnergyMonitorTest, ModelFalling)
{
  ServerConfig serverConfig;
  const auto sdfFile = std::string(PROJECT_SOURCE_PATH) +
    "/test/worlds/altimeter.sdf";
  serverConfig.SetSdfFile(sdfFile);
  Server server(serverConfig);
  EXPECT_FALSE(server.Running());
  EXPECT_FALSE(*server.Running(0));
  const std::string sensorName = "altimeter_sensor";
  std::string topic = "/model/altimeter_model/kinetic_energy";
  transport::Node node;
  node.Subscribe(topic, &cb);
  size_t iters = 1000u;
  server.Run(true, iters, false);
  for (int sleep = 0; sleep < 30; ++sleep)
  {
    std::this_thread::sleep_for(std::chrono::milliseconds(100));
    mutex.lock();
    bool received = dblMsgs.size() > 0;
    mutex.unlock();
    if (received)
      break;
  }
  mutex.lock();
  EXPECT_EQ(1u, dblMsgs.size());
  auto firstMsg = dblMsgs.front();
  mutex.unlock();
  EXPECT_GT(firstMsg.data(), 2);
}
TEST_F ( KineticEnergyMonitorTest , ModelFalling ) { ServerConfig serverConfig ; const auto sdfFile = std :: string ( PROJECT_SOURCE_PATH ) + " " ; serverConfig . SetSdfFile ( sdfFile ) ; Server server ( serverConfig ) ; EXPECT_FALSE ( server . Running ( ) ) ; EXPECT_FALSE ( * server . Running ( 0 ) ) ; const std :: string sensorName = " " ; std :: string topic = " " ; transport :: Node node ; node . Subscribe ( topic , & cb ) ; size_t iters = 1000u ; server . Run ( true , iters , false ) ; for ( int sleep = 0 ; sleep < 30 ; ++ sleep ) { std :: this_thread :: sleep_for ( std :: chrono :: milliseconds ( 100 ) ) ; mutex . lock ( ) ; bool received = dblMsgs . size ( ) > 0 ; mutex . unlock ( ) ; if ( received ) break ; } mutex . lock ( ) ; EXPECT_EQ ( 1u , dblMsgs . size ( ) ) ; auto firstMsg = dblMsgs . front ( ) ; mutex . unlock ( ) ; EXPECT_GT ( firstMsg . data ( ) , 2 ) ; }
The test checks the world pose and sensor readings of a falling altimeter
The test checks the world pose and sensor readings of a falling altimeter
// Start server // subscribe to kinetic energy topic // Run server // Wait for messages to be received