strange behavior and crash
I am in the process of moving some system parameters from being hard coded to retrieving them from a parameter server. I am getting some strange outputs in by class constructor.
Here is the code:
// Ros Initalization
ros::NodeHandle n;
// getting system parameters from server
std::cout << "defining the vectors \n" << std::cout;
vector<float>
cam_disp,
cam_eul,
imu_disp,
imu_eul,
imu_cov,
lights;
std::cout << " defining the bool \n" << std::cout;
bool sim = false;
std::cout << " I am entering the while loop \n" << std::cout;
while(!n.hasParam("Camera/euler_angles") ||
!n.hasParam("Camera/displacement") ||
!n.hasParam("Imu/euler_angles") ||
!n.hasParam("Imu/displacement") ||
!n.hasParam("Is_simulation") ||
!n.hasParam("Shipdeck/lights")){
std::cout << " waiting for params " << std::endl;
ros::Duration(0.5).sleep();
}
std::cout << " leaving the while loop" << std::cout;
n.getParam("Camera/euler_angles", cam_eul);
n.getParam("Camera/displacement", cam_disp);
n.getParam("Imu/euler_angles", imu_eul);
n.getParam("Imu/displacement", imu_disp);
n.getParam("Is_simulating", sim);
n.getParam("Shipdeck/lights", lights);
if (sim == false){
while(!n.hasParam("Imu/covariance"))
ros::Duration(0.5).sleep();
n.getParam("Imu/covariance", imu_cov);
}
else{
while(!n.hasParam("Imu/covariance_sim"))
ros::Duration(0.5).sleep();
n.getParam("Imu/covariance_sim", imu_cov);
}
This is the output I'm seeing
defining the vectors
0x190354 defining the bool
0x190354 I am entering the while loop
I have no idea where the numbers are coming from, they aren't from anywhere else in the code. I don't believe that it's getting stuck in the while loop; I've run the code with an empty parameter sever and I've seen the waiting msg. Previously I was checking for the existence of each individual parameter and that worked fine. I moved to this setup because it's much easier to read. Any help would be appreciated.
I should add that after the output I've posted above, the terminal becomes unresponsive. crt+c does nothing and I end up closing the window.