-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ab1c58
commit eec4e33
Showing
15 changed files
with
285 additions
and
13 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
docker/simulation/carla_sample_node/carla_sample_node.Dockerfile
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,63 @@ | ||
ARG BASE_IMAGE=ghcr.io/watonomous/wato_monorepo/base:humble-ubuntu22.04 | ||
|
||
################################ Source ################################ | ||
FROM ${BASE_IMAGE} as source | ||
|
||
WORKDIR ${AMENT_WS}/src | ||
|
||
# Copy in source code | ||
COPY src/simulation/carla_sample_node carla_sample_node | ||
COPY src/wato_msgs/sample_msgs sample_msgs | ||
COPY src/wato_msgs/simulation/common_msgs common_msgs | ||
COPY src/wato_msgs/simulation/embedded_msgs embedded_msgs | ||
COPY src/wato_msgs/simulation/path_planning_msgs path_planning_msgs | ||
|
||
# Carla specific messages | ||
RUN git clone --depth 1 https://github.com/ros-drivers/ackermann_msgs.git --branch ros2 && \ | ||
git clone --depth 1 https://github.com/ros-perception/image_common.git --branch $ROS_DISTRO && \ | ||
git clone --depth 1 https://github.com/carla-simulator/ros-carla-msgs.git --branch master | ||
|
||
# Scan for rosdeps | ||
RUN apt-get -qq update && rosdep update && \ | ||
rosdep install --from-paths . --ignore-src -r -s \ | ||
| grep 'apt-get install' \ | ||
| awk '{print $3}' \ | ||
| sort > /tmp/colcon_install_list | ||
|
||
################################# Dependencies ################################ | ||
FROM ${BASE_IMAGE} as dependencies | ||
|
||
# Install Rosdep requirements | ||
COPY --from=source /tmp/colcon_install_list /tmp/colcon_install_list | ||
RUN apt-fast install -qq -y --no-install-recommends $(cat /tmp/colcon_install_list) | ||
|
||
# Copy in source code from source stage | ||
WORKDIR ${AMENT_WS} | ||
COPY --from=source ${AMENT_WS}/src src | ||
|
||
# Dependency Cleanup | ||
WORKDIR / | ||
RUN apt-get -qq autoremove -y && apt-get -qq autoclean && apt-get -qq clean && \ | ||
rm -rf /root/* /root/.ros /tmp/* /var/lib/apt/lists/* /usr/share/doc/* | ||
|
||
################################ Build ################################ | ||
FROM dependencies as build | ||
|
||
# Build ROS2 packages | ||
WORKDIR ${AMENT_WS} | ||
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ | ||
colcon build \ | ||
--cmake-args -DCMAKE_BUILD_TYPE=Release | ||
|
||
# Entrypoint will run before any CMD on launch. Sources ~/opt/<ROS_DISTRO>/setup.bash and ~/ament_ws/install/setup.bash | ||
COPY docker/wato_ros_entrypoint.sh ${AMENT_WS}/wato_ros_entrypoint.sh | ||
ENTRYPOINT ["./wato_ros_entrypoint.sh"] | ||
|
||
################################ Prod ################################ | ||
FROM build as deploy | ||
|
||
# Source Cleanup and Security Setup | ||
RUN chown -R $USER:$USER ${AMENT_WS} | ||
RUN rm -rf src/* | ||
|
||
USER ${USER} |
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 @@ | ||
logs |
Empty file.
56 changes: 56 additions & 0 deletions
56
src/simulation/carla_sample_node/carla_sample_node/carla_sample_node.py
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,56 @@ | ||
##### IMPORTANT #### | ||
""" | ||
Uncomment the code under the main function (at the bottom of this file) to have the node actually run | ||
""" | ||
|
||
|
||
import rclpy | ||
from rclpy.node import Node | ||
|
||
from nav_msgs.msg import Odometry # For odometry | ||
from sensor_msgs.msg import NavSatFix # For GNSS | ||
|
||
from std_msgs.msg import Bool | ||
|
||
import os | ||
|
||
class Datalogger(Node): | ||
def __init__(self): | ||
super().__init__('datalogger') | ||
self.gnssSubscription = self.create_subscription( | ||
NavSatFix, | ||
'/carla/ego_vehicle/gnss', | ||
self.gnss_callback, | ||
10 | ||
) | ||
self.gnssSubscription # prevent unused variable warning | ||
self.autopilotPublisher = self.create_publisher( | ||
Bool, | ||
'/carla/ego_vehicle/enable_autopilot', | ||
10 | ||
) | ||
self.timer = self.create_timer(10, self.timer_callback) # Publish autopilot message every 10 seconds | ||
def gnss_callback(self, msg): | ||
# with open("/home/docker/ament_ws/src/carla_sample_node/logs/gnss_" + self.containerId + ".txt", 'a+') as file: | ||
# file.write(str(msg.latitude) + ", " + str(msg.longitude) + "\n") | ||
self.get_logger().info(str(msg.latitude) + ", " + str(msg.longitude)) # print to screen | ||
def timer_callback(self): | ||
msg = Bool() | ||
msg.data = True | ||
self.autopilotPublisher.publish(msg) | ||
|
||
def main(args=None): | ||
# Uncomment the below lines to actually run the sample node | ||
|
||
# rclpy.init(args=args) | ||
|
||
# datalogger = Datalogger() | ||
|
||
# rclpy.spin(datalogger) | ||
|
||
# datalogger.destroy_node() | ||
# rclpy.shutdown() | ||
return | ||
|
||
if __name__ == '__main__': | ||
main() |
8 changes: 8 additions & 0 deletions
8
src/simulation/carla_sample_node/launch/carla_sample_node.launch.py
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,8 @@ | ||
from launch import LaunchDescription | ||
import launch_ros.actions | ||
|
||
def generate_launch_description(): | ||
return LaunchDescription([ | ||
launch_ros.actions.Node( | ||
namespace= "carla_sample_node", package='carla_sample_node', executable='carla_sample_node', output='screen'), | ||
]) |
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,20 @@ | ||
<?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>carla_sample_node</name> | ||
<version>0.0.0</version> | ||
<description>Sample python node to read data from CARLA</description> | ||
<maintainer email="[email protected]">Vishal Jayakumar</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> | ||
|
||
<depend>rclpy</depend> | ||
|
||
<export> | ||
<build_type>ament_python</build_type> | ||
</export> | ||
</package> |
Empty file.
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,4 @@ | ||
[develop] | ||
script_dir=$base/lib/carla_sample_node | ||
[install] | ||
install_scripts=$base/lib/carla_sample_node |
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,29 @@ | ||
from setuptools import setup | ||
from glob import glob | ||
import os | ||
|
||
package_name = 'carla_sample_node' | ||
|
||
setup( | ||
name=package_name, | ||
version='0.0.0', | ||
packages=[package_name], | ||
data_files=[ | ||
('share/ament_index/resource_index/packages', | ||
['resource/' + package_name]), | ||
('share/' + package_name, ['package.xml']), | ||
('share/' + package_name, glob(os.path.join('launch', '*.launch.py'))) | ||
], | ||
install_requires=['setuptools'], | ||
zip_safe=True, | ||
maintainer='Vishal Jayakumar', | ||
maintainer_email='[email protected]', | ||
description='Sample python node to read data from CARLA', | ||
license='TODO: License declaration', | ||
tests_require=['pytest'], | ||
entry_points={ | ||
'console_scripts': [ | ||
'carla_sample_node = carla_sample_node.carla_sample_node: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 |
---|---|---|
@@ -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' |
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,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) |
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,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' |
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