-
Notifications
You must be signed in to change notification settings - Fork 30
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
changes made to build without warnings #143
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for being diligent to fix these warnings. Since this is a rather pedantic pull request, I'll take this opportunity to be overly pedantic myself! 😉
- Most of the casts to
unsigned int
probably should be casts tosize_t
instead. - Use
static_cast
instead of a C style casts. - Use
AIKIDO_UPPER_CASE
for macros to differentiate them from normal functions and variables.
Also, note that the hauser_parabolic_smoother
subdirectory is imported from another project and doesn't use Aikido's coding standard. I recommend disabling all of the warnings in this subdirectory instead of trying to fix them - that just makes the diff with the tarball we imported unnecessarily larger.
@@ -62,7 +62,7 @@ bool RnBoxConstraintSampleGenerator::sample( | |||
{ | |||
Eigen::VectorXd value(mDistributions.size()); | |||
|
|||
for (size_t i = 0; i < value.size(); ++i) | |||
for (int i = 0; i < value.size(); ++i) // i should be the same type as size() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this comment is necessary.
src/trajectory/Interpolated.cpp
Outdated
@@ -90,11 +90,11 @@ void Interpolated::evaluate(double _t, State *_state) const | |||
void Interpolated::evaluateDerivative(double _t, int _derivative, | |||
Eigen::VectorXd& _tangentVector ) const | |||
{ | |||
if (_derivative == 0) | |||
if (_derivative <= 0) // Invalid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize I pushed this edit as well. This has nothing to do with warnings. I am changing it back to the original for now.
|
CMakeLists.txt
Outdated
@@ -137,7 +137,7 @@ include_directories(${DART_INCLUDE_DIRS}) | |||
# Libraries and unit tests. | |||
# | |||
# TODO: Add this to each target's DEFINITIONS property. | |||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | |||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror -Wno-unused-local-typedefs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is -Wno-unused-local-typedefs
necessary? Could we remove the unused typedef
s instead? 😉
src/statespace/dart/SE3Joint.cpp
Outdated
: JointStateSpace(_joint) | ||
, SE3() | ||
: SE3() | ||
, JointStateSpace(_joint) // Order of class members to be maintained |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is misleading. SE3
and JointSubSpace
are super classes, not class members.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. My bad. I'll fix it.
Can we merge this after #114 is merged? I'd like to make |
I approved #114. Let's merge that first, make the last few changes here, and merge this as well. |
I'll review this again first thing in the morning, address the suggestions by @mkoval. Should be ready for merge by morning. |
Should be ready for merge now. 😅
|
Let me resolve the conflicts with master branch. |
Conflicts: CMakeLists.txt src/external/hauser_parabolic_smoother/CMakeLists.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conflicts with master branch are resolved, but I still see warnings from the unit tests. @aditya-vk Could you resolve them by building Aikido with tests
target as make -j4 tests
?
src/statespace/dart/SE2Joint.cpp
Outdated
, SE2() | ||
: SE2() | ||
, JointStateSpace(_joint) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Remove unnecessary empty line
Builds without warnings even on unit tests. |
I am not sure what to do with the following warning: Rest of the warnings have all been fixed with -Wpedantic as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you can fix the variadic-macros
warning by adding SYSTEM
to this line:
include_directories("${gtest_SOURCE_DIR}/include")
The only variadic macro I see in the project is in gtest
, which should be flagged as a SYSTEM
header so it doesn't generate warnings.
@@ -11,4 +11,5 @@ set_target_properties("${PROJECT_NAME}_external_hauserparabolicsmoother" | |||
) | |||
target_compile_options("${PROJECT_NAME}_external_hauserparabolicsmoother" | |||
PUBLIC ${AIKIDO_CXX_STANDARD_FLAGS} | |||
PRIVATE -w |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this? 😱
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm correct, this is to ignore warnings from ${PROJECT_NAME}_external_hauserparabolicsmoother
target. Since it's not an external target, we cannot use include_directories()
with SYSTEM
option.
src/trajectory/Interpolated.cpp
Outdated
@@ -90,11 +90,11 @@ void Interpolated::evaluate(double _t, State *_state) const | |||
void Interpolated::evaluateDerivative(double _t, int _derivative, | |||
Eigen::VectorXd& _tangentVector ) const | |||
{ | |||
if (_derivative == 0) | |||
if (_derivative == 0) // Invalid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Remove comment.
@@ -26,7 +26,7 @@ class SO2UniformSamplerTests : public ::testing::Test | |||
mRng = make_unique<RNGWrapper<std::default_random_engine>>(0); | |||
|
|||
mTargets.clear(); | |||
for (int i = 0; i < NUM_TARGETS; ++i) | |||
for (auto i = 0u; i < NUM_TARGETS; ++i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Could we just make this a size_t
? I'm generally a fan of almost always auto
, but it's a bit funny that we changed a bunch of other loop variables to size_
in this pull request. 😉
Woohoo! Done! I guess? :D Added the SYSTEM flag in the CMakeLists.txt one level lower. I am not sure why including the flag in the tests/CMakeLists did not solve the issue..shouldn't it have? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why including the flag in the tests/CMakeLists did not solve the issue..shouldn't it have?
I think it's because of the location of the SYSTEM
option. It should appear before directory.
Sorry for this PR keeps bothering you but I still see errors. 😓
Some warnings are compiler version dependent. If you cannot reproduce the error (warning), I can help to fix them.
Also, as the warnings from gtest is resolved, we might don't want to change the gtest code. It would be good to undo the changes you've made in the previous commits.
tests/CMakeLists.txt
Outdated
@@ -1,5 +1,6 @@ | |||
# GTest setup. | |||
add_subdirectory(gtest) | |||
|
|||
include_directories("${gtest_SOURCE_DIR}/include") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This line is not added by this PR, but it seems redundant. "${gtest_SOURCE_DIR}/include"
is included in the CMakeLists.txt
under gtest
subdirectory.
tests/constraint/test_TSR.cpp
Outdated
@@ -18,15 +18,15 @@ using dart::common::make_unique; | |||
using DefaultRNG = RNGWrapper<std::default_random_engine>; | |||
|
|||
|
|||
static Eigen::Vector6d getPose(Eigen::Isometry3d isometry) | |||
static inline Eigen::Vector6d getPose(Eigen::Isometry3d isometry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this really cause warnings? This function is defined in source code so we shouldn't worry about duplicated definitions. Am I missing something here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the documentation:
-Wunused-function
Warn whenever a static function is declared but not defined or a non-inline static function is unused. This warning is enabled by -Wall.
In our case a non-inline static function's not used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems the real problem is that this function is unused. I think we could simply remove this function since it was defined only for the local tests but not used.
cmake/CompilerSettings.cmake
Outdated
@@ -17,6 +17,8 @@ if(CMAKE_COMPILER_IS_GNUCXX) | |||
|
|||
set(AIKIDO_CXX_STANDARD_FLAGS -std=c++11) | |||
|
|||
add_compile_options(-Wall) | |||
add_compile_options(-Wpedantic) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We could put multiple options in one function like add_compile_options(-Wall -Wpedantic)
.
@@ -35,17 +35,11 @@ class NonCollidingTest : public ::testing::Test | |||
auto boxNode = mBox->createJointAndBodyNodePair<FreeJoint>().second; | |||
Eigen::Vector3d boxSize(0.5, 0.5, 0.5); | |||
std::shared_ptr<BoxShape> boxShape(new BoxShape(boxSize)); | |||
auto shapeNode = boxNode->createShapeNodeWith | |||
<VisualAspect, CollisionAspect, DynamicsAspect>(boxShape); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't remove the whole line, but just shapeNode
variable. createShapeNodeWith<...>()
creates ShapeNode
within boxNode
and returns the pointer. That means this function changes the internal state of bodyNode
, which is necessary for this test.
// Create a shpae node for visualization and collision checking | ||
auto shapeNode1 = bn1->createShapeNodeWith | ||
<VisualAspect, CollisionAspect, DynamicsAspect>(box); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't remove the whole line but shapeNode1
. (see above)
All the warnings of more tighter warning levels are gone! 🎉 |
@mkoval Could you do take a look once more for sure? |
typedef (unused) -> set to ignore this warning. Need a fix.
Major warnings:
different types compared -> type casted as appropriate
incorrectly ordered initialization -> reordered
unused variables -> specified to have been unused
This change is