Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"build": {
"args": {
"WORKSPACE": "${containerWorkspaceFolder}",
"ROS_DISTRO": "humble"
"ROS_DISTRO": "rolling"
}
},
"remoteUser": "dev",
"remoteUser": "blue",
"runArgs": [
"--network=host",
"--cap-add=SYS_PTRACE",
Expand Down Expand Up @@ -91,9 +91,6 @@
"[xml]": {
"editor.defaultFormatter": "redhat.vscode-xml"
},
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml"
},
"[markdown]": {
"editor.rulers": [80],
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint"
Expand Down
53 changes: 31 additions & 22 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ RUN apt-get -q update \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Install MAVROS dependencies prior to installing ROS dependencies
RUN [ "/bin/bash" , "-c" , "\
wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh \
&& chmod +x install_geographiclib_datasets.sh \
&& sudo ./install_geographiclib_datasets.sh" ]

# Install all ROS dependencies
RUN apt-get -q update \
&& apt-get -q -y upgrade \
Expand All @@ -42,6 +36,35 @@ RUN apt-get -q update \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Configure a new non-root user
ARG USERNAME=blue
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& apt-get update && apt-get upgrade -y \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& rm -rf /var/lib/apt/lists/* \
&& echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc

# Switch to the non-root user to install MAVROS dependencies and ArduSub
USER $USERNAME
ENV USER=$USERNAME

# Set the working directory to the user's home directory
WORKDIR /home/$USERNAME

# Install MAVROS dependencies
RUN wget https://raw.githubusercontent.com/mavlink/mavros/ros2/mavros/scripts/install_geographiclib_datasets.sh \
&& chmod +x install_geographiclib_datasets.sh \
&& sudo ./install_geographiclib_datasets.sh

# Switch back to root user
USER root
ENV USER=root

FROM ci as source

ENV ROS_UNDERLAY /root/ws_blue/install
Expand Down Expand Up @@ -105,20 +128,6 @@ RUN pip3 install \
black \
setuptools==58.2.0

# Configure a new non-root user
ARG USERNAME=dev
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& apt-get update && apt-get upgrade -y \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& rm -rf /var/lib/apt/lists/* \
&& echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc \
&& echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc

ARG WORKSPACE
RUN echo "if [ -f ${WORKSPACE}/install/setup.bash ]; then source ${WORKSPACE}/install/setup.bash; fi" >> /home/$USERNAME/.bashrc
RUN echo "if [ -f ${WORKSPACE}/install/setup.bash ]; then source ${WORKSPACE}/install/setup.bash; fi" >> /home/$USERNAME/.bashrc \
&& echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
!blue_manager
!blue_control
!blue_msgs
!blue_bringup
17 changes: 17 additions & 0 deletions blue_bringup/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Empty file.
50 changes: 50 additions & 0 deletions blue_bringup/config/blue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
blue_manager:
ros__parameters:
num_thrusters: 8
mode_change_timeout: 1.0
mode_change_retries: 3

ismc:
ros__parameters:
mass: 11.5
buoyancy: 112.80
weight: 114.80
inertia_tensor_coeff: [0.16, 0.16, 0.16]
added_mass_coeff: [-5.50, -12.70, -14.60, -0.12, -0.12, -0.12]
linear_damping_coeff: [-4.03, -6.22, -5.18, -0.07, -0.07, -0.07]
quadratic_damping_coeff: [-18.18, -21.66, -36.99, -1.55, -1.55, -1.55]
center_of_gravity: [0.0, 0.0, 0.0]
center_of_buoyancy: [0.0, 0.0, 0.0]
ocean_current: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
num_thrusters: 8
tcm: [0.707, 0.707, -0.707, -0.707, 0.0, 0.0, 0.0, 0.0,
-0.707, 0.707, -0.707, 0.707, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, -1.0, 1.0, 1.0, -1.0,
0.06, -0.06, 0.06, -0.06, -0.218, -0.218, 0.218, 0.218,
0.06, 0.06, -0.06, -0.06, 0.120, -0.120, 0.120, -0.120,
-0.1888, 0.1888, 0.1888, -0.1888, 0.0, 0.0, 0.0, 0.0]
msg_ids: [31, 32]
msg_rates: [100.0, 100.0]

mavros:
ros__parameters:
system_id: 255
plugin_allowlist:
- sys_status
- command
- imu
- local_position
- rc_io
- param
- vision_pose

mavros_node:
ros__parameters:
fcu_url: "tcp://localhost"
gcs_url: "udp://@localhost:14550"

mavros/local_position:
ros__parameters:
frame_id: "map"
tf:
send: false
93 changes: 93 additions & 0 deletions blue_bringup/launch/blue.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Copyright 2023, Evan Palmer
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description() -> LaunchDescription:
"""Generate a launch description to run the system.

Returns:
The Blue ROS 2 launch description.
"""
# Declare the launch arguments
args = [
DeclareLaunchArgument(
"config",
default_value="blue.yaml",
description="The ROS 2 parameters configuration file",
),
DeclareLaunchArgument(
"controller",
default_value="ismc",
description=(
"The controller to use; this should be the same name as the"
" controller's executable"
),
choices=["ismc"],
),
]

config_filepath = PathJoinSubstitution(
[
FindPackageShare("blue_bringup"),
"config",
LaunchConfiguration("config"),
]
)

nodes = [
Node(
package="mavros",
executable="mavros_node",
output="screen",
parameters=[config_filepath],
),
]

# Declare additional launch files to run
includes = [
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution(
[FindPackageShare("blue_manager"), "manager.launch.py"]
)
),
launch_arguments={"config_filepath": config_filepath}.items(),
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution(
[FindPackageShare("blue_control"), "launch", "control.launch.py"]
)
),
launch_arguments={
"config_filepath": config_filepath,
"controller": LaunchConfiguration("controller"),
}.items(),
),
]

return LaunchDescription(args + nodes + includes)
21 changes: 21 additions & 0 deletions blue_bringup/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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>blue_bringup</name>
<version>0.0.1</version>
<description>Entrypoints for the Blue project.</description>
<maintainer email="evanp922@gmail.com">Evan Palmer</maintainer>
<license>MIT</license>

<exec_depend>mavros</exec_depend>
<exec_depend>mavros_extras</exec_depend>

<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>
Empty file.
4 changes: 4 additions & 0 deletions blue_bringup/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[develop]
script_dir=$base/lib/blue_bringup
[install]
install_scripts=$base/lib/blue_bringup
48 changes: 48 additions & 0 deletions blue_bringup/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2023, Evan Palmer
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import os
from glob import glob

from setuptools import setup

package_name = "blue_bringup"

setup(
name=package_name,
version="0.0.1",
packages=[package_name],
data_files=[
("share/ament_index/resource_index/packages", ["resource/" + package_name]),
("share/" + package_name, ["package.xml"]),
(os.path.join("share", package_name), glob("launch/*.launch.py")),
(os.path.join("share", package_name, "config"), glob("config/*.yaml")),
],
install_requires=["setuptools"],
zip_safe=True,
maintainer="Evan Palmer",
maintainer_email="evanp922@gmail.com",
description="Entrypoints for the Blue project.",
license="MIT",
tests_require=["pytest"],
entry_points={
"console_scripts": [],
},
)
27 changes: 27 additions & 0 deletions blue_bringup/test/test_copyright.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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.

import pytest
from ament_copyright.main import main


# 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 blue_bringup/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.

import pytest
from ament_flake8.main import main_with_errors


@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)
Loading