Commit ea5153ff authored by Joseph Mirabel's avatar Joseph Mirabel Committed by olivier stasse
Browse files

Fix SEGV when initializing absent sensors.

parent e49b7304
...@@ -310,12 +310,15 @@ namespace sot_controller ...@@ -310,12 +310,15 @@ namespace sot_controller
{ {
if (!initJoints()) if (!initJoints())
return false; return false;
if (!initIMU()) if (!initIMU()) {
return false; ROS_WARN("could not initialize IMU sensor(s).");
if (!initForceSensors()) }
return false; if (!initForceSensors()) {
if (!initTemperatureSensors()) ROS_WARN("could not initialize force sensor(s).");
return false; }
if (!initTemperatureSensors()) {
ROS_WARN("could not initialize temperature sensor(s).");
}
// Initialize ros node. // Initialize ros node.
int argc=1; int argc=1;
...@@ -782,6 +785,8 @@ namespace sot_controller ...@@ -782,6 +785,8 @@ namespace sot_controller
bool RCSotController:: bool RCSotController::
initIMU() initIMU()
{ {
if (!imu_iface_) return false;
// get all imu sensor names // get all imu sensor names
const std :: vector<std :: string >& imu_iface_names = imu_iface_->getNames(); const std :: vector<std :: string >& imu_iface_names = imu_iface_->getNames();
if (verbosity_level_>0) if (verbosity_level_>0)
...@@ -800,6 +805,8 @@ namespace sot_controller ...@@ -800,6 +805,8 @@ namespace sot_controller
bool RCSotController:: bool RCSotController::
initForceSensors() initForceSensors()
{ {
if (!ft_iface_) return false;
// get force torque sensors names package. // get force torque sensors names package.
const std::vector<std::string>& ft_iface_names = ft_iface_->getNames(); const std::vector<std::string>& ft_iface_names = ft_iface_->getNames();
if (verbosity_level_>0) if (verbosity_level_>0)
...@@ -821,6 +828,8 @@ namespace sot_controller ...@@ -821,6 +828,8 @@ namespace sot_controller
if (!simulation_mode_) if (!simulation_mode_)
{ {
#ifdef TEMPERATURE_SENSOR_CONTROLLER #ifdef TEMPERATURE_SENSOR_CONTROLLER
if (!act_temp_iface_) return false;
// get temperature sensors names // get temperature sensors names
const std::vector<std::string>& act_temp_iface_names = act_temp_iface_->getNames(); const std::vector<std::string>& act_temp_iface_names = act_temp_iface_->getNames();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment