Skip to content

Commit

Permalink
Setup ROS structure
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjong committed Jun 26, 2024
1 parent 0e57f8a commit fab7150
Show file tree
Hide file tree
Showing 314 changed files with 696 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM osrf/ros:humble-desktop-full

WORKDIR /ws/

RUN apt install ros-humble-mavros
RUN wget https://raw.githubusercontent.com/mavlink/mavros/ros2/mavros/scripts/install_geographiclib_datasets.sh && chmod +x install_geographiclib_datasets.sh && ./install_geographiclib_datasets.sh

1 change: 1 addition & 0 deletions docker/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# docker compose file
4 changes: 4 additions & 0 deletions installation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Installation scripts, for example:
- for ground control station
- for spirit drone
- for some other drone
Empty file.
Empty file removed robot/logging/.gitkeep
Empty file.
3 changes: 3 additions & 0 deletions ros_ws/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/
install/
log/
File renamed without changes.
5 changes: 5 additions & 0 deletions ros_ws/src/ground_control_station/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Eventually we will have some ground control station that enables commanding all robots simultaneously.

Envision a GUI like an RTS game, where you have a global 3D map you can move around, and can also see and control your "units" on the map.
A minimap will help with understanding where you are.
Envision the map being built up over time in 3D as your agents explore.
6 changes: 6 additions & 0 deletions ros_ws/src/main_launch/launch/main_launch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
launch:

- node:
pkg: "demo_nodes_cpp"
exec: "talker"
name: "talker"
File renamed without changes.
18 changes: 18 additions & 0 deletions ros_ws/src/main_launch/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>main_launch</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="[email protected]">andrew</maintainer>
<license>TODO: License declaration</license>

<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>

<export>
<build_type>ament_python</build_type>
</export>
</package>
File renamed without changes.
4 changes: 4 additions & 0 deletions ros_ws/src/main_launch/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[develop]
script_dir=$base/lib/main_launch
[install]
install_scripts=$base/lib/main_launch
33 changes: 33 additions & 0 deletions ros_ws/src/main_launch/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from setuptools import find_packages, setup
import os
from glob import glob

package_name = 'main_launch'

setup(
name=package_name,
version='0.0.0',
packages=find_packages(exclude=['test']),
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
],
install_requires=['setuptools'],
zip_safe=True,
maintainer='andrew',
maintainer_email='[email protected]',
description='TODO: Package description',
license='TODO: License declaration',
tests_require=['pytest'],
entry_points={
'console_scripts': [
],
},
data_files=[
# ... Other data files
# Include all launch files.
(os.path.join('share', package_name, 'launch'), glob(os.path.join('launch', '*launch.[pxy][yma]*')))
]

)
25 changes: 25 additions & 0 deletions ros_ws/src/main_launch/test/test_copyright.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2015 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ament_copyright.main import main
import pytest


# Remove the `skip` decorator once the source file(s) have a copyright header
@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.')
@pytest.mark.copyright
@pytest.mark.linter
def test_copyright():
rc = main(argv=['.', 'test'])
assert rc == 0, 'Found errors'
25 changes: 25 additions & 0 deletions ros_ws/src/main_launch/test/test_flake8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2017 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ament_flake8.main import main_with_errors
import pytest


@pytest.mark.flake8
@pytest.mark.linter
def test_flake8():
rc, errors = main_with_errors(argv=[])
assert rc == 0, \
'Found %d code style errors / warnings:\n' % len(errors) + \
'\n'.join(errors)
23 changes: 23 additions & 0 deletions ros_ws/src/main_launch/test/test_pep257.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2015 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ament_pep257.main import main
import pytest


@pytest.mark.linter
@pytest.mark.pep257
def test_pep257():
rc = main(argv=['.', 'test'])
assert rc == 0, 'Found code style errors / warnings'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
41 changes: 41 additions & 0 deletions ros_ws/src/robot/autonomy/install_geographiclib_datasets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
# Script to install the model datasets required
# to GeographicLib apply certain conversions

if [[ $UID != 0 ]]; then
echo "This script require root privileges!" 1>&2
exit 1
fi

# Install datasets
run_get() {
local dir="$1"
local tool="$2"
local model="$3"

files=$(shopt -s nullglob dotglob; echo /usr/share/GeographicLib/$dir/$model* /usr/local/share/GeographicLib/$dir/$model*)
if (( ${#files} )); then
echo "GeographicLib $tool dataset $model already exists, skipping"
return
fi

echo "Installing GeographicLib $tool $model"
geographiclib-get-$tool $model >/dev/null 2>&1

files=$(shopt -s nullglob dotglob; echo /usr/share/GeographicLib/$dir/$model* /usr/local/share/GeographicLib/$dir/$model*)
if (( ! ${#files} )); then
echo "Error while installing GeographicLib $tool $model"
return
fi
}

# check which command script is available
if hash geographiclib-get-geoids; then
run_get geoids geoids egm96-5
run_get gravity gravity egm96
run_get magnetic magnetic emm2015
elif hash geographiclib-datasets-download; then # only allows install the goid model dataset
geographiclib-datasets-download egm96_5;
else
echo "OS not supported! Check GeographicLib page for supported OS and lib versions." 1>&2
fi
File renamed without changes.
35 changes: 35 additions & 0 deletions ros_ws/src/robot/autonomy/my_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.8)
project(my_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)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

add_executable(my_node src/my_node.cpp)
target_include_directories(my_node PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_compile_features(my_node PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17

install(TARGETS my_node
DESTINATION lib/${PROJECT_NAME})

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_package()
18 changes: 18 additions & 0 deletions ros_ws/src/robot/autonomy/my_package/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>my_package</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="[email protected]">andrew</maintainer>
<license>TODO: License declaration</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
10 changes: 10 additions & 0 deletions ros_ws/src/robot/autonomy/my_package/src/my_node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <cstdio>

int main(int argc, char ** argv)
{
(void) argc;
(void) argv;

printf("hello world my_package package\n");
return 0;
}
Loading

0 comments on commit fab7150

Please sign in to comment.