-
Notifications
You must be signed in to change notification settings - Fork 43
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
[trajoptlib] Simple spline initial guess with wpilib dependency #727
Draft
bruingineer
wants to merge
10
commits into
SleipnirGroup:main
Choose a base branch
from
bruingineer:spline-initial-guess-simple
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
40c50b9
add files
bruingineer 8c92654
spline guess
bruingineer 0d39c57
format
bruingineer d98e4d1
spline is one function & format
bruingineer 135d608
Update settings.json
bruingineer e59a64b
update allwpilib
bruingineer 531d04f
update posewithcurvate and spline optional
bruingineer de97cc3
remove file associations, again
bruingineer 4ca8b57
fmt
bruingineer 7be604f
wip not working
bruingineer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
|
@@ -178,4 +178,4 @@ impl DiffyGenerationTransformer for ConstraintSetter { | |
}; | ||
} | ||
} | ||
} | ||
} |
This file contains 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 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 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 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 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,122 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import re | ||
import shutil | ||
import subprocess | ||
import sys | ||
import typing | ||
|
||
|
||
def get_linesep(contents): | ||
"""Returns string containing autodetected line separator for file. | ||
Keyword arguments: | ||
contents -- file contents string | ||
""" | ||
# Find potential line separator | ||
pos = contents.find("\n") | ||
|
||
# If a newline character was found and the character preceding it is a | ||
# carriage return, assume CRLF line endings. LF line endings are assumed | ||
# for empty files. | ||
if pos > 0 and contents[pos - 1] == "\r": | ||
return "\r\n" | ||
else: | ||
return "\n" | ||
|
||
|
||
def modify_file(filename, func: typing.Callable[[list[str]], list[str]]): | ||
""" | ||
Reads a file, modifies the contents with func, then writes the file. | ||
""" | ||
with open(filename, encoding="utf-8") as f: | ||
contents = f.read() | ||
|
||
sep = get_linesep(contents) | ||
lines = contents.split(sep) | ||
lines = func(lines) | ||
|
||
with open(filename, "w", encoding="utf-8") as f: | ||
f.write(sep.join(lines)) | ||
|
||
|
||
def remove_protobuf_support(): | ||
shutil.rmtree("wpimath/src/main/native/cpp/controller/proto", ignore_errors=True) | ||
shutil.rmtree("wpimath/src/main/native/cpp/geometry/proto", ignore_errors=True) | ||
shutil.rmtree("wpimath/src/main/native/cpp/kinematics/proto", ignore_errors=True) | ||
shutil.rmtree("wpimath/src/main/native/cpp/system/plant/proto", ignore_errors=True) | ||
shutil.rmtree("wpimath/src/main/native/cpp/trajectory/proto", ignore_errors=True) | ||
shutil.rmtree("wpiutil/src/main/native/cpp/protobuf", ignore_errors=True) | ||
shutil.rmtree( | ||
"wpimath/src/main/native/include/frc/controller/proto", ignore_errors=True | ||
) | ||
shutil.rmtree( | ||
"wpimath/src/main/native/include/frc/geometry/proto", ignore_errors=True | ||
) | ||
shutil.rmtree( | ||
"wpimath/src/main/native/include/frc/kinematics/proto", ignore_errors=True | ||
) | ||
shutil.rmtree( | ||
"wpimath/src/main/native/include/frc/system/plant/proto", ignore_errors=True | ||
) | ||
shutil.rmtree( | ||
"wpimath/src/main/native/include/frc/trajectory/proto", ignore_errors=True | ||
) | ||
shutil.rmtree("wpiutil/src/main/native/thirdparty/protobuf", ignore_errors=True) | ||
shutil.rmtree("wpiutil/src/main/native/cpp/DataLog.cpp", ignore_errors=True) | ||
shutil.rmtree("wpiutil/src/main/native/include/wpi/DataLog.h", ignore_errors=True) | ||
|
||
modify_file( | ||
"CMakeLists.txt", | ||
lambda lines: [ | ||
line | ||
for line in lines | ||
if line != "find_package(Protobuf REQUIRED)" | ||
and line != "find_program(PROTOC_COMPILER protoc REQUIRED)" | ||
], | ||
) | ||
modify_file( | ||
"wpiutil/CMakeLists.txt", | ||
lambda lines: [line.replace("protobuf::libprotobuf", "") for line in lines], | ||
) | ||
modify_file( | ||
"wpiutil/wpiutil-config.cmake.in", | ||
lambda lines: [line for line in lines if line != "find_dependency(Protobuf)"], | ||
) | ||
|
||
filenames = [os.path.join(dp, f) for dp, dn, fn in os.walk("wpimath") for f in fn] | ||
|
||
def fix(lines): | ||
# Remove lines mentioning protobuf | ||
lines = [ | ||
line | ||
for line in lines | ||
if "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/protobuf>" not in line | ||
and not re.search(r"#include \"\w+\.pb\.h\"", line) | ||
and not re.search(r"#include \"frc/.*?Proto\.h\"", line) | ||
] | ||
|
||
# Remove protobuf_generate_cpp() call | ||
filtered_lines = [] | ||
found = False | ||
for i in range(len(lines)): | ||
if lines[i].startswith("# workaround for makefiles"): | ||
found = True | ||
if not found: | ||
filtered_lines.append(lines[i]) | ||
if found and lines[i].startswith(")"): | ||
found = False | ||
lines = filtered_lines | ||
|
||
return lines | ||
|
||
for filename in filenames: | ||
modify_file(filename, fix) | ||
|
||
|
||
def main(): | ||
remove_protobuf_support() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains 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 |
---|---|---|
|
@@ -14,5 +14,6 @@ modifiableFileExclude { | |
|
||
includeOtherLibs { | ||
^Eigen/ | ||
^frc/ | ||
^sleipnir/ | ||
} |
This file contains 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
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.
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.
These should probably go in the user settings.json instead of the workspace one due to how many there are: https://code.visualstudio.com/docs/getstarted/settings#_settings-file-locations
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.
good catch, I'll delete all of this