ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

strange behavior and crash

asked 2015-07-15 10:21:32 -0500

holmes.kirby gravatar image

updated 2015-07-15 10:25:24 -0500

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-07-15 10:52:22 -0500

mgruhler gravatar image

This is coming from you piping std::cout back into std::cout, as e.g. here:

std::cout << "defining the vectors \n" << std::cout;

I guess you mean

std::cout << "defining the vectors \n" << std::endl;
edit flag offensive delete link more

Comments

that's embarrassing. I should have more coffee before I code haha

holmes.kirby gravatar image holmes.kirby  ( 2015-07-15 10:57:06 -0500 )edit

always the best solution ;-)

mgruhler gravatar image mgruhler  ( 2015-07-15 11:00:25 -0500 )edit

Question Tools

Stats

Asked: 2015-07-15 10:21:32 -0500

Seen: 359 times

Last updated: Jul 15 '15