Make clang compile without warnings. (#903)

Rule out accidental usage of integer-only ::abs.
Correct static, override and protected annotations.
master
gaschler 2018-02-14 11:06:46 +01:00 committed by Wally B. Feed
parent b2581b0d58
commit 244cf615f5
4 changed files with 11 additions and 10 deletions

View File

@ -31,8 +31,9 @@ namespace pose_graph {
// //
// 'start' and 'end' poses have the format [x, y, rotation]. // 'start' and 'end' poses have the format [x, y, rotation].
template <typename T> template <typename T>
std::array<T, 3> ComputeUnscaledError(const transform::Rigid2d& relative_pose, static std::array<T, 3> ComputeUnscaledError(
const T* const start, const T* const end); const transform::Rigid2d& relative_pose, const T* const start,
const T* const end);
template <typename T> template <typename T>
std::array<T, 3> ScaleError(std::array<T, 3> error, T translation_weight, std::array<T, 3> ScaleError(std::array<T, 3> error, T translation_weight,
T rotation_weight); T rotation_weight);
@ -43,11 +44,10 @@ std::array<T, 3> ScaleError(std::array<T, 3> error, T translation_weight,
// 'start' and 'end' translation has the format [x, y, z]. // 'start' and 'end' translation has the format [x, y, z].
// 'start' and 'end' rotation are quaternions in the format [w, n_1, n_2, n_3]. // 'start' and 'end' rotation are quaternions in the format [w, n_1, n_2, n_3].
template <typename T> template <typename T>
std::array<T, 6> ComputeUnscaledError(const transform::Rigid3d& relative_pose, static std::array<T, 6> ComputeUnscaledError(
const T* const start_rotation, const transform::Rigid3d& relative_pose, const T* const start_rotation,
const T* const start_translation, const T* const start_translation, const T* const end_rotation,
const T* const end_rotation, const T* const end_translation);
const T* const end_translation);
template <typename T> template <typename T>
std::array<T, 6> ScaleError(std::array<T, 6> error, T translation_weight, std::array<T, 6> ScaleError(std::array<T, 6> error, T translation_weight,

View File

@ -101,7 +101,8 @@ std::array<T, 4> SlerpQuaternions(const T* const start, const T* const end,
// as the arccosine of their dot product. // as the arccosine of their dot product.
const T cos_theta = start[0] * end[0] + start[1] * end[1] + const T cos_theta = start[0] * end[0] + start[1] * end[1] +
start[2] * end[2] + start[3] * end[3]; start[2] * end[2] + start[3] * end[3];
const T abs_cos_theta = abs(cos_theta); // Avoid using ::abs which would cast to integer.
const T abs_cos_theta = ceres::abs(cos_theta);
// If numerical error brings 'cos_theta' outside [-1 + epsilon, 1 - epsilon] // If numerical error brings 'cos_theta' outside [-1 + epsilon, 1 - epsilon]
// interval, then the quaternions are likely to be collinear. // interval, then the quaternions are likely to be collinear.
T prev_scale = T(1.) - factor; T prev_scale = T(1.) - factor;

View File

@ -35,7 +35,7 @@ namespace cartographer_grpc {
namespace framework { namespace framework {
class Server { class Server {
private: protected:
// All options that configure server behaviour such as number of threads, // All options that configure server behaviour such as number of threads,
// ports etc. // ports etc.
struct Options { struct Options {

View File

@ -69,7 +69,7 @@ class MockMapBuilderContext : public MapBuilderContextInterface {
void EnqueueLocalSlamResultData( void EnqueueLocalSlamResultData(
int trajectory_id, const std::string &sensor_id, int trajectory_id, const std::string &sensor_id,
std::unique_ptr<cartographer::mapping::LocalSlamResultData> std::unique_ptr<cartographer::mapping::LocalSlamResultData>
local_slam_result_data) { local_slam_result_data) override {
DoEnqueueLocalSlamResultData(trajectory_id, sensor_id, DoEnqueueLocalSlamResultData(trajectory_id, sensor_id,
local_slam_result_data.get()); local_slam_result_data.get());
} }