This repository was archived by the owner on May 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
C++ workspace docs updates #91
Draft
hhenry01
wants to merge
5
commits into
main
Choose a base branch
from
hhenry01/NET-workspace-structure
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 all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f4b01ee
C++ workspace docs updates
hhenry01 b4df58d
Move NET workspace page and rebased to get linting updates
hhenry01 1767524
Merge branch 'main' into hhenry01/NET-workspace-structure
patrick-5546 c6c3bb1
Move net workspace to network_systems dir
patrick-5546 9cf47ee
Update ROS launch command
DFriend01 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 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,107 @@ | ||
| # Repository Structure | ||
|
|
||
| ## root | ||
|
|
||
| The Network Systems directory is similar to the following (READMEs and CMakeLists excluded): | ||
|
|
||
| ``` | ||
| network_systems | ||
| | package.xml | ||
| | | ||
| └───.github | ||
| | | ... | ||
| | | ||
| └───launch | ||
| | | ... | ||
| | | ||
| └───lib | ||
| | └───protofiles | ||
| | | message.proto | ||
| | | ... | ||
| | | ||
| └───projects | ||
| └───example | ||
| | └───inc | ||
| | | | example.h | ||
| | | | ... | ||
| | | | ||
| | └───src | ||
| | | | example.cpp | ||
| | | | example_subscriber.cpp | ||
| | | | ... | ||
| | | | ||
| | └───test | ||
| | | | test_example.cpp | ||
| | | | ... | ||
| | | ||
| └───... | ||
|
|
||
| ``` | ||
|
|
||
| At the root of the directory is a `package.xml`. This file tells ROS2 that the network_systems package exists. It is | ||
| what allows us to run, for example: `ros2 run network_systems main_launch.py`. | ||
|
|
||
| `.github/` contains Github specific files like workflows for continuous integration. | ||
|
|
||
| `launch/` contains ROS launch files. | ||
|
|
||
| ## lib | ||
|
|
||
| The lib is where we will place static libraries that we want to be accessible to all programs. This means they do not | ||
| generate their own executable and will always link to a program in the projects directory. | ||
|
|
||
| To add new libraries, create a folder and add it to `lib/CMakeLists.txt`. Add a `CMakeLists.txt` file to your newly | ||
| created folder and fill it out accordingly. | ||
|
|
||
| ## projects | ||
|
|
||
| Each directory found under projects is module directory. For example, the CAN transceiver will have its own folder in | ||
| this directory. Each module will define its executable, unit test executable, and (optionally) its public interface. | ||
|
|
||
| Additionally, we will separate the functional source file (`example.cpp`) from the the ROS communication interface file | ||
| (`example_subscriber.cpp`). The point is to make the unit tests cover only the functional code, while the communication | ||
| code is tackled by integration testing. | ||
|
|
||
| To add a new module, create a folder and add it to `projects/CMakeLists.txt`. In your new module folder, add an `inc/` | ||
| (optional), `src/`, and `test/` folder, as well as a `CMakeLists.txt` which will need to be filled out accordingly. | ||
|
|
||
| ??? example | ||
| This is the `CMakeLists.txt` for an example module where the source files are for a Cached Fibonacci program. | ||
|
|
||
| ```cmake | ||
| set(module example) | ||
|
|
||
| # Create module library | ||
| set(srcs | ||
| ${CMAKE_CURRENT_LIST_DIR}/src/cached_fib.cpp | ||
| ) | ||
| # Make the header accessible to other modules | ||
| add_library(${module} ${srcs}) | ||
| target_include_directories(${module} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/inc ${PROTOBUF_INCLUDE_PATH}) | ||
|
|
||
| # Create module ROS executable | ||
| set(bin_module bin_${module}) | ||
| set(bin_srcs | ||
| ${srcs} | ||
| ${CMAKE_CURRENT_LIST_DIR}/src/cached_fib_subscriber.cpp | ||
| ) | ||
| add_executable(${bin_module} ${bin_srcs}) | ||
| ament_target_dependencies(${bin_module} rclcpp std_msgs) | ||
| target_include_directories(${bin_module} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/inc ${PROTOBUF_INCLUDE_PATH}) | ||
| install(TARGETS ${bin_module} DESTINATION lib/${PROJECT_NAME}) | ||
| # Rename the output binary to just be the module name | ||
| set_target_properties(${bin_module} PROPERTIES OUTPUT_NAME ${module}) | ||
|
|
||
| # Create unit test | ||
| set(test_module test_${module}) | ||
| set(test_srcs | ||
| ${srcs} | ||
| ${CMAKE_CURRENT_LIST_DIR}/test/test_cached_fib.cpp | ||
| ) | ||
| add_executable(${test_module} ${test_srcs}) | ||
| target_include_directories(${test_module} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/inc ${PROTOBUF_INCLUDE_PATH}) | ||
| target_link_libraries(${test_module} ${GTEST_LINK_LIBS}) | ||
| # Make the unit test runnable with CTest (invoked via test.sh) | ||
| add_test(NAME ${test_module} COMMAND ${test_module}) | ||
|
|
||
| ``` |
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
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.
I feel like most, if not all of this information in this file, might belong on the project README rather than the docs website. How do others feel about this? @patrick-5546 @hhenry01?