|
44 | 44 |
|
45 | 45 | namespace urdf { |
46 | 46 |
|
47 | | -SensorBaseSharedPtr CameraParser::parse(TiXmlElement &config) |
| 47 | +SensorBase* CameraParser::parse(TiXmlElement &config) |
48 | 48 | { |
49 | 49 | TiXmlElement *image = config.FirstChildElement("image"); |
50 | 50 | if (image) |
51 | 51 | { |
52 | 52 | try { |
53 | | - CameraSharedPtr camera(new Camera()); |
| 53 | + std::unique_ptr<Camera> camera(new Camera()); |
54 | 54 | camera->width = parseAttribute<unsigned int>(*image, "width"); |
55 | 55 | camera->height = parseAttribute<unsigned int>(*image, "height"); |
56 | 56 | camera->format = parseAttribute<std::string>(*image, "format"); |
57 | 57 | camera->hfov = parseAttribute<double>(*image, "hfov"); |
58 | 58 | camera->near = parseAttribute<double>(*image, "near"); |
59 | 59 | camera->far = parseAttribute<double>(*image, "far"); |
60 | | - return camera; |
| 60 | + return camera.release(); |
61 | 61 | } |
62 | 62 | catch (const std::exception &e) |
63 | 63 | { |
64 | 64 | CONSOLE_BRIDGE_logError("Camera sensor %s", e.what()); |
65 | | - return CameraSharedPtr(); |
| 65 | + return nullptr; |
66 | 66 | } |
67 | 67 | } |
68 | 68 | else |
69 | 69 | { |
70 | 70 | CONSOLE_BRIDGE_logError("Camera sensor has no <image> element"); |
71 | | - return CameraSharedPtr(); |
| 71 | + return nullptr; |
72 | 72 | } |
73 | 73 | } |
74 | 74 |
|
75 | 75 |
|
76 | | -SensorBaseSharedPtr RayParser::parse(TiXmlElement &config) |
| 76 | +SensorBase* RayParser::parse(TiXmlElement &config) |
77 | 77 | { |
78 | 78 | TiXmlElement *horizontal = config.FirstChildElement("horizontal"); |
79 | 79 | if (horizontal) |
80 | 80 | { |
81 | 81 | try { |
82 | | - RaySharedPtr ray (new Ray()); |
| 82 | + std::unique_ptr<Ray> ray(new Ray()); |
83 | 83 | ray->horizontal_samples = parseAttribute<unsigned int>(*horizontal, "samples"); |
84 | 84 | ray->horizontal_resolution = parseAttribute<double>(*horizontal, "resolution"); |
85 | 85 | ray->horizontal_min_angle = parseAttribute<double>(*horizontal, "min_angle"); |
86 | 86 | ray->horizontal_max_angle = parseAttribute<double>(*horizontal, "max_angle"); |
87 | | - return ray; |
| 87 | + return ray.release(); |
88 | 88 | } |
89 | 89 | catch (const std::exception &e) |
90 | 90 | { |
91 | 91 | CONSOLE_BRIDGE_logError("Ray horizontal: %s", e.what()); |
92 | | - return RaySharedPtr(); |
| 92 | + return nullptr; |
93 | 93 | } |
94 | 94 | } |
95 | 95 |
|
96 | 96 | TiXmlElement *vertical = config.FirstChildElement("vertical"); |
97 | 97 | if (vertical) |
98 | 98 | { |
99 | 99 | try { |
100 | | - RaySharedPtr ray (new Ray()); |
| 100 | + std::unique_ptr<Ray> ray(new Ray()); |
101 | 101 | ray->vertical_samples = parseAttribute<unsigned int>(*vertical, "samples"); |
102 | 102 | ray->vertical_resolution = parseAttribute<double>(*vertical, "resolution"); |
103 | 103 | ray->vertical_min_angle = parseAttribute<double>(*vertical, "min_angle"); |
104 | 104 | ray->vertical_max_angle = parseAttribute<double>(*vertical, "max_angle"); |
105 | | - return ray; |
| 105 | + return ray.release(); |
106 | 106 | } |
107 | 107 | catch (const std::exception &e) |
108 | 108 | { |
109 | 109 | CONSOLE_BRIDGE_logError("Ray horizontal: %s", e.what()); |
110 | | - return RaySharedPtr(); |
| 110 | + return nullptr; |
111 | 111 | } |
112 | 112 | } |
113 | | - return RaySharedPtr(); |
| 113 | + return nullptr; |
114 | 114 | } |
115 | 115 |
|
116 | 116 | } |
0 commit comments