From 3cb58319da7ace0adf0416d883b56fdde7b2bc70 Mon Sep 17 00:00:00 2001 From: Joseph Carpinelli Date: Wed, 26 Jun 2024 20:01:29 +0000 Subject: [PATCH] Adds workspace content --- .devcontainer/Dockerfile | 48 +++++++++++++++ .devcontainer/devcontainer.json | 10 ++++ .gitignore | 5 +- src/example_package/CMakeLists.txt | 59 +++++++++++++++++++ .../example_package/example_package.hpp | 19 ++++++ .../example_package/visibility_control.h | 35 +++++++++++ src/example_package/package.xml | 18 ++++++ src/example_package/src/example_package.cpp | 14 +++++ 8 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 src/example_package/CMakeLists.txt create mode 100644 src/example_package/include/example_package/example_package.hpp create mode 100644 src/example_package/include/example_package/visibility_control.h create mode 100644 src/example_package/package.xml create mode 100644 src/example_package/src/example_package.cpp diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..7c5c4d0 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,48 @@ +FROM osrf/ros:humble-desktop-full + + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y git make graphviz python3-pip + +RUN cd /tmp \ + && git clone --recursive https://github.com/ros2/ros2_documentation \ + && pip install --requirement ros2_documentation/requirements.txt \ + && rm -rf ros2_documentation + +RUN cd /tmp \ + && git clone --recursive https://github.com/ros-infrastructure/rosdoc2 \ + && pip install --upgrade ./rosdoc2 \ + && rm -rf rosdoc2 + +# Add vscode user with same UID and GID as your host system +# (copied from https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_creating-a-nonroot-user) +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=$USER_UID +RUN groupadd --gid $USER_GID $USERNAME \ + && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ + && apt-get update \ + && apt-get install -y sudo \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ + && chmod 0440 /etc/sudoers.d/$USERNAME +# Switch from root to user +USER $USERNAME + +# Add user to video group to allow access to webcam +RUN sudo usermod --append --groups video $USERNAME + +# Update all packages +RUN sudo apt update && sudo apt upgrade -y + +# Install Git +RUN sudo apt install -y git + +# Rosdep update +RUN rosdep update + +# Source the ROS setup file +RUN echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> ~/.bashrc + +# Remove apt lists +RUN sudo apt-get autoremove -y && sudo apt-get clean -y && rm -rf /var/lib/lists/* diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..93294c4 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,10 @@ +{ + "name": "humble desktop-full", + "dockerFile": "Dockerfile", + "runArgs": [ + "--privileged", + "--network=host" + ], + "workspaceMount": "source=${localWorkspaceFolder},target=/${localWorkspaceFolderBasename},type=bind", + "workspaceFolder": "/${localWorkspaceFolderBasename}" +} diff --git a/.gitignore b/.gitignore index 35d74bb..403431f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,11 @@ devel/ logs/ +install/ +log/ build/ bin/ lib/ +docs_build msg_gen/ srv_gen/ msg/*Action.msg @@ -48,4 +51,4 @@ qtcreator-* .#* # Catkin custom files -CATKIN_IGNORE +CATKIN_IGNORE \ No newline at end of file diff --git a/src/example_package/CMakeLists.txt b/src/example_package/CMakeLists.txt new file mode 100644 index 0000000..4a92598 --- /dev/null +++ b/src/example_package/CMakeLists.txt @@ -0,0 +1,59 @@ +cmake_minimum_required(VERSION 3.8) +project(example_package) + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# find dependencies +find_package(ament_cmake REQUIRED) +find_package(ament_cmake_ros REQUIRED) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) + +add_library(example_package src/example_package.cpp) +target_compile_features(example_package PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17 +target_include_directories(example_package PUBLIC + $ + $) + +# Causes the visibility macros to use dllexport rather than dllimport, +# which is appropriate when building the dll but not consuming it. +target_compile_definitions(example_package PRIVATE "EXAMPLE_PACKAGE_BUILDING_LIBRARY") + +install( + DIRECTORY include/ + DESTINATION include +) +install( + TARGETS example_package + EXPORT export_${PROJECT_NAME} + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin +) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # comment the line when a copyright and license is added to all source files + set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # comment the line when this package is in a git repo and when + # a copyright and license is added to all source files + set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_export_include_directories( + include +) +ament_export_libraries( + example_package +) +ament_export_targets( + export_${PROJECT_NAME} +) + +ament_package() diff --git a/src/example_package/include/example_package/example_package.hpp b/src/example_package/include/example_package/example_package.hpp new file mode 100644 index 0000000..48e84fb --- /dev/null +++ b/src/example_package/include/example_package/example_package.hpp @@ -0,0 +1,19 @@ +#ifndef EXAMPLE_PACKAGE__EXAMPLE_PACKAGE_HPP_ +#define EXAMPLE_PACKAGE__EXAMPLE_PACKAGE_HPP_ + +#include "example_package/visibility_control.h" + +namespace example_package +{ + +class ExamplePackage +{ +public: + ExamplePackage(); + + virtual ~ExamplePackage(); +}; + +} // namespace example_package + +#endif // EXAMPLE_PACKAGE__EXAMPLE_PACKAGE_HPP_ diff --git a/src/example_package/include/example_package/visibility_control.h b/src/example_package/include/example_package/visibility_control.h new file mode 100644 index 0000000..4575462 --- /dev/null +++ b/src/example_package/include/example_package/visibility_control.h @@ -0,0 +1,35 @@ +#ifndef EXAMPLE_PACKAGE__VISIBILITY_CONTROL_H_ +#define EXAMPLE_PACKAGE__VISIBILITY_CONTROL_H_ + +// This logic was borrowed (then namespaced) from the examples on the gcc wiki: +// https://gcc.gnu.org/wiki/Visibility + +#if defined _WIN32 || defined __CYGWIN__ + #ifdef __GNUC__ + #define EXAMPLE_PACKAGE_EXPORT __attribute__ ((dllexport)) + #define EXAMPLE_PACKAGE_IMPORT __attribute__ ((dllimport)) + #else + #define EXAMPLE_PACKAGE_EXPORT __declspec(dllexport) + #define EXAMPLE_PACKAGE_IMPORT __declspec(dllimport) + #endif + #ifdef EXAMPLE_PACKAGE_BUILDING_LIBRARY + #define EXAMPLE_PACKAGE_PUBLIC EXAMPLE_PACKAGE_EXPORT + #else + #define EXAMPLE_PACKAGE_PUBLIC EXAMPLE_PACKAGE_IMPORT + #endif + #define EXAMPLE_PACKAGE_PUBLIC_TYPE EXAMPLE_PACKAGE_PUBLIC + #define EXAMPLE_PACKAGE_LOCAL +#else + #define EXAMPLE_PACKAGE_EXPORT __attribute__ ((visibility("default"))) + #define EXAMPLE_PACKAGE_IMPORT + #if __GNUC__ >= 4 + #define EXAMPLE_PACKAGE_PUBLIC __attribute__ ((visibility("default"))) + #define EXAMPLE_PACKAGE_LOCAL __attribute__ ((visibility("hidden"))) + #else + #define EXAMPLE_PACKAGE_PUBLIC + #define EXAMPLE_PACKAGE_LOCAL + #endif + #define EXAMPLE_PACKAGE_PUBLIC_TYPE +#endif + +#endif // EXAMPLE_PACKAGE__VISIBILITY_CONTROL_H_ diff --git a/src/example_package/package.xml b/src/example_package/package.xml new file mode 100644 index 0000000..8998ad3 --- /dev/null +++ b/src/example_package/package.xml @@ -0,0 +1,18 @@ + + + + example_package + 0.0.0 + TODO: Package description + vscode + TODO: License declaration + + ament_cmake_ros + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/src/example_package/src/example_package.cpp b/src/example_package/src/example_package.cpp new file mode 100644 index 0000000..522b06d --- /dev/null +++ b/src/example_package/src/example_package.cpp @@ -0,0 +1,14 @@ +#include "example_package/example_package.hpp" + +namespace example_package +{ + +ExamplePackage::ExamplePackage() +{ +} + +ExamplePackage::~ExamplePackage() +{ +} + +} // namespace example_package