-
Notifications
You must be signed in to change notification settings - Fork 640
Enhancement/use hpp for headers #3113
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
Merged
sea-bass
merged 60 commits into
moveit:main
from
TSNoble:enhancement/use-hpp-for-headers
Nov 29, 2024
Merged
Changes from 53 commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
2c5e59f
Replaces moveit imports from .h to .hpp
TSNoble fcc088c
Replaces moveit imports from .h to .hpp
TSNoble 3d8f70a
Renames all .h files to .hpp
TSNoble 252e5da
Fixes moveit_core compiler errors
TSNoble c4ebfc5
Fixes compilation up to moveit_planners
TSNoble f64a9fa
Fixes compilation up to moveit_py
TSNoble 603ba86
Fixes compilation up to moveit_ros
TSNoble 4340e08
Merge branch 'main' into enhancement/use-hpp-for-headers
TSNoble 3199c85
Updates MIGRATION.md
TSNoble e5b505f
Merges with main
TSNoble fc0425d
Fixes chomp imports
TSNoble f0d1f21
Fixes ikfast imports
TSNoble 294f890
Adds create_deprecated_headers.py
TSNoble be8f3fd
Fixes lingering version.h
TSNoble 4ae41ea
Fixes python formatting
TSNoble 5a2843c
Updates MIGRATION.md
TSNoble 84a6ab0
Fixes MIGRATION.md formatting
TSNoble 483f5b5
Fixes ikfast errors
TSNoble d0bb7e7
Fixes ikfast errors
TSNoble 194d544
Fixes tf2_ros imports
TSNoble 7924769
Fixes ikfast errors
TSNoble 0d2080d
Rename ikfast.hpp to ikfast.h
TSNoble 7eb5cc2
Applies changes from d529029062305520817c261be6601bab94b21255
TSNoble 4028c13
Applies changes from d529029062305520817c261be6601bab94b21255
TSNoble 6e6f300
Fixes typos
TSNoble 3c0ad59
Reverts botched merge
TSNoble 3fa7b06
Partially fixes merge conflicts
TSNoble 4ef4ccd
Merge branch 'main' into enhancement/use-hpp-for-headers
TSNoble 695d1c7
Fixes merge conflicts
TSNoble f9ff2c3
Merge branch 'main' into enhancement/use-hpp-for-headers
riv-tnoble 4564094
Adds CMake wrapper around python script
TSNoble 03c5143
Adds create_deprecated_headers() call after every install() that uses…
TSNoble a59cd57
Fixes formatting
TSNoble bf11b68
Fixes script
TSNoble 71efe77
Simplifies script
TSNoble 939f24f
Removes create_deprecated_headers() macro calls
TSNoble cdd0b63
Adds authorship and TODOs
TSNoble bdf8e7b
Adds new header generator
TSNoble b0d563f
Removes test script
TSNoble a7465de
Updates deprecated headers script
TSNoble 4b3304c
Adds #pragma once to files that don't have it
TSNoble 16eeb75
Generate headers where we can
TSNoble bd16103
Applies formatting
TSNoble b4a6299
Deletes referenced to now removed cmake file
TSNoble aca9ab1
Minor tweaks to script and updates .h files
TSNoble 3b0ad74
Temporarily disables deprecation msg to reduce compiler spam
TSNoble 4d8bdf1
Fixes script comment
TSNoble f2dc4c8
Applies formatting
TSNoble c2b681f
Merge branch 'main' into enhancement/use-hpp-for-headers
TSNoble 31f6d4e
Fixes autogen script
TSNoble 9793f46
Delete moveit_core/macros/include/moveit/macros/deprecation.hpp
TSNoble 94032aa
Delete moveit_core/macros/include/moveit/macros/deprecation.h
TSNoble d8ed584
Merge branch 'main' into enhancement/use-hpp-for-headers
TSNoble 23b3882
Update moveit/scripts/create_deprecated_headers.py
riv-tnoble e25d46a
Update moveit/scripts/create_deprecated_headers.py
riv-tnoble dda37c4
Updates script copyright
riv-tnoble 4e3667b
Refactors script. Removes newline from parameter_name_list.hpp
TSNoble a10a31a
Removes now unused parse_args() function
TSNoble 04f375f
Updates .h disclaimer with more info. Regenerates headers.
TSNoble cc3981a
Merge branch 'main' into enhancement/use-hpp-for-headers
sea-bass File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright 2021 PickNik Inc. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# | ||
# * Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# | ||
# * Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# | ||
# * Neither the name of the PickNik Inc. nor the names of its | ||
# contributors may be used to endorse or promote products derived from | ||
# this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
|
||
# Author: Tom Noble | ||
|
||
import sys | ||
import logging | ||
from typing import List, Tuple | ||
from pathlib import Path | ||
|
||
|
||
class NoIncludeGuard(Exception): | ||
ERROR = "No include guard found in {}.hpp. Unable to generate pretext." | ||
|
||
def __init__(self, file: Path): | ||
super().__init__(self.ERROR.format(file)) | ||
|
||
|
||
class NoIncludeDirectory(Exception): | ||
ERROR = "No includue directory found for {}.hpp. Unable to generate relative .hpp include" | ||
riv-tnoble marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def __init__(self, file: Path): | ||
super().__init__(self.ERROR.format(file)) | ||
|
||
|
||
class HppFile: | ||
def __init__(self, path: Path): | ||
self.path = path | ||
self.guard = "#pragma once" | ||
self.pretext = self.pretext() | ||
self.include = self.include() | ||
|
||
def drop_data_after(self, data: str, match: str): | ||
return data[: data.find(match) + len(match)] | ||
|
||
def read(self) -> str: | ||
data = open(self.path, "r").read() | ||
contains_guard = self.guard in data | ||
if not contains_guard: | ||
raise NoIncludeGuard(self.path) | ||
return data | ||
|
||
def pretext(self) -> str: | ||
data = self.read() | ||
return self.drop_data_after(data, self.guard) | ||
|
||
def include(self) -> str: | ||
ends_with_include = lambda p: str(p).endswith("include") | ||
include_paths = [p for p in self.path.parents if ends_with_include(p)] | ||
if not include_paths: | ||
raise NoIncludeDirectory(self.path) | ||
relative_import = self.path.relative_to(include_paths[0]) | ||
return f"#include <{relative_import}>" | ||
|
||
|
||
class DeprecatedHeader: | ||
def __init__(self, hpp: HppFile): | ||
self.hpp = hpp | ||
self.path = hpp.path.with_suffix(".h") | ||
self.prefix = f"/* This file was autogenerated by {Path(__file__).name} */" | ||
self.warn = '#pragma message(".h header is obsolete. Please use the .hpp")' | ||
riv-tnoble marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.contents = self.contents() | ||
|
||
def contents(self) -> str: | ||
items = [self.prefix, self.hpp.pretext, self.warn, self.hpp.include] | ||
return "\n\n".join(items) | ||
|
||
|
||
def parse_args(args: List) -> bool: | ||
n_args = len(sys.argv) | ||
if n_args > 2: | ||
sys.exit("Usage: ./create_deprecated_headers [--apply]") | ||
apply = "--apply" == sys.argv[1] if n_args == 2 else False | ||
return apply | ||
TSNoble marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
if __name__ == "__main__": | ||
apply = parse_args(sys.argv) | ||
hpp_paths = list(Path.cwd().rglob("*.hpp")) | ||
print(f"Generating deprecated .h files for {len(hpp_paths)} .hpp files...") | ||
processed = [] | ||
bad = [] | ||
TSNoble marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for hpp_path in hpp_paths: | ||
try: | ||
processed.append(HppFile(hpp_path)) | ||
except NoIncludeDirectory as e: | ||
bad.append(str(hpp_path)) | ||
except NoIncludeGuard as e: | ||
bad.append(str(hpp_path)) | ||
print(f"Summary: Can generate {len(processed)} .h files") | ||
if bad: | ||
print(f"Cannot generate .h files for the following files:") | ||
print("\n".join(bad)) | ||
if apply and bad: | ||
answer = input("Proceed to generate? (y/n): ") | ||
apply = answer.lower() == "y" | ||
if apply: | ||
print(f"Proceeding to generate {len(processed)} .h files...") | ||
to_generate = [DeprecatedHeader(hpp) for hpp in processed] | ||
_ = [open(h.path, "w").write(h.contents) for h in to_generate] | ||
print("Done. (You may need to rerun formatting)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...ion/include/moveit/collision_detection/allvalid/collision_detector_allocator_allvalid.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/********************************************************************* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2013, Willow Garage, Inc. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* * Neither the name of Willow Garage nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*********************************************************************/ | ||
|
||
/* Author: Acorn Pooley, Ioan Sucan */ | ||
|
||
#pragma once | ||
|
||
#include <moveit/collision_detection/collision_detector_allocator.hpp> | ||
#include <moveit/collision_detection/allvalid/collision_env_allvalid.hpp> | ||
|
||
#include <moveit_collision_detection_export.h> | ||
|
||
namespace collision_detection | ||
{ | ||
/** \brief An allocator for AllValid collision detectors */ | ||
class MOVEIT_COLLISION_DETECTION_EXPORT CollisionDetectorAllocatorAllValid | ||
: public CollisionDetectorAllocatorTemplate<CollisionEnvAllValid, CollisionDetectorAllocatorAllValid> | ||
{ | ||
public: | ||
static const std::string NAME; // defined in collision_env_allvalid.cpp | ||
}; | ||
} // namespace collision_detection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...ollision_detection/include/moveit/collision_detection/allvalid/collision_env_allvalid.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/********************************************************************* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2011, Willow Garage, Inc. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* * Neither the name of Willow Garage nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*********************************************************************/ | ||
|
||
/* Author: Ioan Sucan, Jia Pan, Jens Petit */ | ||
|
||
#pragma once | ||
|
||
#include <moveit/collision_detection/collision_env.hpp> | ||
|
||
namespace collision_detection | ||
{ | ||
/** \brief Collision environment which always just returns no collisions. | ||
* | ||
* This can be used to save resources if collision checking is not important. */ | ||
class CollisionEnvAllValid : public CollisionEnv | ||
{ | ||
public: | ||
CollisionEnvAllValid(const moveit::core::RobotModelConstPtr& robot_model, double padding = 0.0, double scale = 1.0); | ||
CollisionEnvAllValid(const moveit::core::RobotModelConstPtr& robot_model, const WorldPtr& world, double padding = 0.0, | ||
double scale = 1.0); | ||
CollisionEnvAllValid(const CollisionEnv& other, const WorldPtr& world); | ||
|
||
void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, | ||
const moveit::core::RobotState& state) const override; | ||
void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const moveit::core::RobotState& state, | ||
const AllowedCollisionMatrix& acm) const override; | ||
void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const moveit::core::RobotState& state1, | ||
const moveit::core::RobotState& state2) const override; | ||
void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const moveit::core::RobotState& state1, | ||
const moveit::core::RobotState& state2, const AllowedCollisionMatrix& acm) const override; | ||
|
||
virtual double distanceRobot(const moveit::core::RobotState& state) const; | ||
virtual double distanceRobot(const moveit::core::RobotState& state, const AllowedCollisionMatrix& acm) const; | ||
void distanceRobot(const DistanceRequest& req, DistanceResult& res, | ||
const moveit::core::RobotState& state) const override; | ||
|
||
void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, | ||
const moveit::core::RobotState& state) const override; | ||
void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, const moveit::core::RobotState& state, | ||
const AllowedCollisionMatrix& acm) const override; | ||
|
||
void distanceSelf(const DistanceRequest& req, DistanceResult& res, | ||
const moveit::core::RobotState& state) const override; | ||
}; | ||
} // namespace collision_detection |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.