Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use SensorBase class as base class for sensors #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions urdf_parser/src/urdf_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,33 +294,36 @@ bool parseRay(Ray &ray, TiXmlElement* config)
}
}

boost::shared_ptr<VisualSensor> parseVisualSensor(TiXmlElement *g)
boost::shared_ptr<SensorBase> parseSensorBase(TiXmlElement *g)
{
boost::shared_ptr<VisualSensor> visual_sensor;
boost::shared_ptr<SensorBase> sensor_;

// get sensor type
TiXmlElement *sensor_xml;
if (g->FirstChildElement("camera"))
{
Camera *camera = new Camera();
visual_sensor.reset(camera);
sensor_.reset(camera);
sensor_->sensor_type = SensorBase::VISUAL;
sensor_xml = g->FirstChildElement("camera");
if (!parseCamera(*camera, sensor_xml))
visual_sensor.reset();
sensor_.reset();
}
else if (g->FirstChildElement("ray"))
{
Ray *ray = new Ray();
visual_sensor.reset(ray);
sensor_.reset(ray);
sensor_->sensor_type = SensorBase::VISUAL;
sensor_xml = g->FirstChildElement("ray");
if (!parseRay(*ray, sensor_xml))
visual_sensor.reset();
sensor_.reset();
}
else
{
logError("No know sensor types [camera|ray] defined in <sensor> block");
}
return visual_sensor;

return sensor_;
}


Expand Down Expand Up @@ -354,7 +357,7 @@ bool parseSensor(Sensor &sensor, TiXmlElement* config)
}

// parse sensor
sensor.sensor = parseVisualSensor(config);
sensor.sensor = parseSensorBase(config);
return true;
}

Expand Down