flightgoggles_ros_bridge/src/ROSClient/ROSClient.cpp
/**
 * @brief ROSClient::paramCallback updates the sim parameters which are send to unity.
 *        for illumination we would like to set values from 0.3 to 4 where 1.8 is the
 *        optimal illumination
 * @param msg
 *
 * @todo sim scene settings are not yet saved or transmitted
 */
@brief ROSClient::paramCallback updates the sim parameters which are send to unity.
for illumination we would like to set values from 0.3 to 4 where 1.8 is the
optimal illumination
@param msg

@todo sim scene settings are not yet saved or transmitted
@brief ROSClient :: paramCallback updates the sim parameters which are send to unity . for illumination we would like to set values from 0 . 3 to 4 where 1 . 8 is the optimal illumination @param msg @todo sim scene settings are not yet saved or transmitted
void ROSClient::paramCallback(const flightgoggles::FGParamConstPtr& msg)
{
  if (msg->sim_scene_name != "") {
    sim_parameters_.sim_scene_name = msg->sim_scene_name;
  }
  int plus_minus = 0;
  if (msg->illumination_changes_direction.compare("up") == 0) {
    plus_minus = 1;
  } else if (msg->illumination_changes_direction.compare("down") == 0) {
    plus_minus = - 1;
  } else if (msg->illumination_changes_direction.compare("random") == 0) {
    plus_minus = (std::rand() % 2) * 2 - 1;
  } else {
    ROS_ERROR_STREAM("No or wrong Illumination direction parameter, valid options are [up],[down] and [random] ");
    ROS_WARN_STREAM("Seeting it to [random]");
    plus_minus = (std::rand() % 2) * 2 - 1;
  }
  sim_parameters_.sim_cam_dim(0)      = (int) msg->sim_cam_dimensions.x;
  sim_parameters_.sim_cam_dim(1)      = (int) msg->sim_cam_dimensions.y;
  sim_parameters_.sim_cam_fov         = msg->sim_cam_fov;
  sim_parameters_.level_clutter       = msg->level_clutter;
  sim_parameters_.level_features      = msg->level_features;
  sim_parameters_.level_motion_blur   = msg->level_motion_blur;
  sim_parameters_.cam_distortion      = msg->cam_fisheye_distortion;
  sim_parameters_.cam_is_grayscale    = msg->cam_is_grayscale;
  sim_parameters_.imu_acc_noise       = msg->imu_acc_noise;
  sim_parameters_.imu_gyro_noise      = msg->imu_gyro_noise;
  sim_parameters_.cam_time_delay      = msg->cam_time_delay;
  if (plus_minus > 0) {
    sim_parameters_.level_illumination  = 1.0 + (1.0/54)*std::pow(msg->level_illumination,2) + (1.0/9.0)*msg->level_illumination;
  } else if (plus_minus < 0){
    sim_parameters_.level_illumination  = 1.0 + (0.73/54)*std::pow(msg->level_illumination,2) - 0.23*msg->level_illumination;
  }
  ROS_INFO_STREAM("Set scene to " << sim_parameters_.sim_scene_name);
  ROS_INFO_STREAM("Set image width to " << sim_parameters_.sim_cam_dim(0));
  ROS_INFO_STREAM("Set image height to " << sim_parameters_.sim_cam_dim(1));
  ROS_INFO_STREAM("Set camera diagonal fov to " << sim_parameters_.sim_cam_fov);
  ROS_INFO_STREAM("Set camera fisheye distortion to " << sim_parameters_.cam_distortion);
  ROS_INFO_STREAM("Set camera to grayscale " << sim_parameters_.cam_is_grayscale);
  ROS_INFO_STREAM("Set illumination (difficulty) level to " << sim_parameters_.level_illumination);
  ROS_INFO_STREAM("Set features (difficulty) level to " << sim_parameters_.level_features);
  ROS_INFO_STREAM("Set motion blur (difficulty) level to " << sim_parameters_.level_motion_blur);
  ROS_INFO_STREAM("Set clutter (difficulty) level to " << sim_parameters_.level_clutter);
  ROS_INFO_STREAM("Set imu accelerometer noise level to " << sim_parameters_.imu_acc_noise);
  ROS_INFO_STREAM("Set imu gyrometer noise level to " << sim_parameters_.imu_gyro_noise);
  ROS_INFO_STREAM("Set cam-imu time delay level to " << sim_parameters_.cam_time_delay);
  scene_params_.reinitialize = true;
  populateRenderSettings();
}
void ROSClient :: paramCallback ( const flightgoggles :: FGParamConstPtr & msg ) { if ( msg -> sim_scene_name != " " ) { sim_parameters_ . sim_scene_name = msg -> sim_scene_name ; } int plus_minus = 0 ; if ( msg -> illumination_changes_direction . compare ( " " ) == 0 ) { plus_minus = 1 ; } else if ( msg -> illumination_changes_direction . compare ( " " ) == 0 ) { plus_minus = - 1 ; } else if ( msg -> illumination_changes_direction . compare ( " " ) == 0 ) { plus_minus = ( std :: rand ( ) % 2 ) * 2 - 1 ; } else { ROS_ERROR_STREAM ( " " ) ; ROS_WARN_STREAM ( " " ) ; plus_minus = ( std :: rand ( ) % 2 ) * 2 - 1 ; } sim_parameters_ . sim_cam_dim ( 0 ) = ( int ) msg -> sim_cam_dimensions . x ; sim_parameters_ . sim_cam_dim ( 1 ) = ( int ) msg -> sim_cam_dimensions . y ; sim_parameters_ . sim_cam_fov = msg -> sim_cam_fov ; sim_parameters_ . level_clutter = msg -> level_clutter ; sim_parameters_ . level_features = msg -> level_features ; sim_parameters_ . level_motion_blur = msg -> level_motion_blur ; sim_parameters_ . cam_distortion = msg -> cam_fisheye_distortion ; sim_parameters_ . cam_is_grayscale = msg -> cam_is_grayscale ; sim_parameters_ . imu_acc_noise = msg -> imu_acc_noise ; sim_parameters_ . imu_gyro_noise = msg -> imu_gyro_noise ; sim_parameters_ . cam_time_delay = msg -> cam_time_delay ; if ( plus_minus > 0 ) { sim_parameters_ . level_illumination = 1.0 + ( 1.0 / 54 ) * std :: pow ( msg -> level_illumination , 2 ) + ( 1.0 / 9.0 ) * msg -> level_illumination ; } else if ( plus_minus < 0 ) { sim_parameters_ . level_illumination = 1.0 + ( 0.73 / 54 ) * std :: pow ( msg -> level_illumination , 2 ) - 0.23 * msg -> level_illumination ; } ROS_INFO_STREAM ( " " << sim_parameters_ . sim_scene_name ) ; ROS_INFO_STREAM ( " " << sim_parameters_ . sim_cam_dim ( 0 ) ) ; ROS_INFO_STREAM ( " " << sim_parameters_ . sim_cam_dim ( 1 ) ) ; ROS_INFO_STREAM ( " " << sim_parameters_ . sim_cam_fov ) ; ROS_INFO_STREAM ( " " << sim_parameters_ . cam_distortion ) ; ROS_INFO_STREAM ( " " << sim_parameters_ . cam_is_grayscale ) ; ROS_INFO_STREAM ( " " << sim_parameters_ . level_illumination ) ; ROS_INFO_STREAM ( " " << sim_parameters_ . level_features ) ; ROS_INFO_STREAM ( " " << sim_parameters_ . level_motion_blur ) ; ROS_INFO_STREAM ( " " << sim_parameters_ . level_clutter ) ; ROS_INFO_STREAM ( " " << sim_parameters_ . imu_acc_noise ) ; ROS_INFO_STREAM ( " " << sim_parameters_ . imu_gyro_noise ) ; ROS_INFO_STREAM ( " " << sim_parameters_ . cam_time_delay ) ; scene_params_ . reinitialize = true ; populateRenderSettings ( ) ; }
@brief ROSClient::paramCallback updates the sim parameters which are send to unity.
@brief ROSClient :: paramCallback updates the sim parameters which are send to unity .
// update current parameter settings // Set if illumination should decrease only, increase only or be random // (1/54)l^2 + (1/9)l +1 // (0.72/54)l^2 - 0.23l + 1 // setup scene params to reinitialize // update settings