-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
31 changed files
with
2,118 additions
and
0 deletions.
There are no files selected for viewing
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,34 @@ | ||
FROM osrf/ros:galactic-desktop-focal | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
# create a non-root user | ||
# 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 | ||
|
||
USER $USERNAME | ||
|
||
# update all packages | ||
RUN sudo apt-get update && sudo apt-get upgrade -y | ||
|
||
# install packages | ||
RUN sudo apt-get install -y python3-pip git | ||
|
||
# install fast rtps | ||
RUN sudo apt install -y ros-galactic-rmw-fastrtps-cpp | ||
|
||
# update ros dependencies | ||
RUN rosdep update --rosdistro galactic | ||
|
||
# ros configuration | ||
RUN echo "source /opt/ros/$ROS_DISTRO/setup.sh" >> ~/.bashrc | ||
RUN echo "export RMW_IMPLEMENTATION=rmw_fastrtps_cpp" >> ~/.bashrc |
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,42 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu | ||
{ | ||
|
||
"name": "galactic-desktop-focal", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
"features": { | ||
"ghcr.io/devcontainers/features/python:1": {} | ||
}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
"runArgs": ["--network=host"], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "bash .devcontainer/installation.sh", | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"python.defaultInterpreterPath": "/usr/bin/python3" | ||
}, | ||
"extensions": [ | ||
"mhutchie.git-graph", | ||
"ms-azuretools.vscode-docker", | ||
"ms-vscode.live-server", | ||
"mechatroner.rainbow-csv" | ||
] | ||
} | ||
} | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
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 @@ | ||
sudo apt-get update && sudo apt-get upgrade -y \ | ||
&& pip3 install --user -r .devcontainer/requirements.txt \ | ||
&& colcon build \ | ||
&& echo "source install/setup.bash" >> ~/.bashrc |
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,6 @@ | ||
pyyaml==5.3.1 | ||
rosbags==0.9.22 | ||
pathlib==1.0.1 | ||
plotly==5.18.0 | ||
pandas==2.0.3 | ||
numpy==1.24.4 |
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 @@ | ||
data/* | ||
src/__pycache__/* | ||
src/*.html | ||
log/* | ||
build/* | ||
install/* | ||
plot/* | ||
csv/* |
File renamed without changes.
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,71 @@ | ||
# ROS2 Rosbag Fault Injection | ||
|
||
![Docker](https://img.shields.io/badge/docker-%230db7ed.svg?style=for-the-badge&logo=docker&logoColor=white) | ||
![Visual Studio Code](https://img.shields.io/badge/Visual%20Studio%20Code-0078d7.svg?style=for-the-badge&logo=visual-studio-code&logoColor=white) | ||
![ROS](https://img.shields.io/badge/ros-%230A0FF9.svg?style=for-the-badge&logo=ros&logoColor=white) | ||
![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54) | ||
![Shell Script](https://img.shields.io/badge/shell_script-%23121011.svg?style=for-the-badge&logo=gnu-bash&logoColor=white) | ||
|
||
Fault injection for [ROS2](https://github.com/ros2) rosbags that supports recording, modifying, and plotting the fault injected rosbags. | ||
|
||
## Getting Started | ||
|
||
### Prerequisite (at host) | ||
|
||
* Visual Code | ||
* Docker | ||
* If you have a Docker Desktop license, Docker Desktop >= 4.27.2 | ||
* If you don't have a Docker Desktop license, [Docker Engine on WSL2](https://www.youtube.com/redirect?event=video_description&redir_token=QUFFLUhqbU8zY0gzaUpIak1nWWM5NExPNlhDYjdYRGh1QXxBQ3Jtc0trMjgzWVZzeGxXSnMtSEpUNlBxeXAwdWg3a29iaVlJcVVIZEdMbzVaeVhOQ3NNSllSa3JnVXlDVVZMLUY2ZzJxSGZQdWNmSDhjRVJWVTYwbFFmRzhzSnJoQ05MNktGRUlCRjdqTDI3OXJ2T2NLVVBhcw&q=https%3A%2F%2Fdocs.docker.com%2Fengine%2Finstall%2Fubuntu%2F%23install-using-the-convenience-script&v=SDk3pqFXgs8) (Docker Engine != Docker Desktop) | ||
* In case of another installation, make sure you have deleted the previous Docker completely | ||
* After installation, check if Docker Container Engine is running well | ||
``` | ||
# to check if docker container engine is running | ||
sudo service docker status | ||
``` | ||
* Python >= 3.8.10 | ||
* The user must be added in the `docker` group with sudo previledge | ||
``` | ||
# add a group named docker | ||
sudo gropuadd docker | ||
# add the current user to the docker group with sudo privilege | ||
sudo gpasswd -a $USER docker | ||
# change the current user's primary group to docker | ||
newgrp docker | ||
``` | ||
### Setup | ||
To clone the repo: | ||
``` | ||
git clone https://github.com/boschresearch/rosbag-fault-injection.git | ||
``` | ||
To open the Visual Code: | ||
``` | ||
# change directory to the project | ||
cd rosbag-fault-injection | ||
|
||
# open visual code | ||
code . | ||
``` | ||
The project contains `devcontainer` that runs [ROS2 Galactic](https://docs.ros.org/en/galactic/index.html) as a container with all required dependencies and initial setup. | ||
To open the `devcontainer`, press `Ctrl`+`Shift`+`P` from Visual Code and select `Reopen in Container`. See [Visual Studio Blog](https://code.visualstudio.com/blogs/2020/07/01/containers-wsl#_getting-started) for visual guidelines. | ||
After `devcontainer` is up and running successfully, you can open a `bash` terminal with `vscode` user name. And `ros2` commands are usable right away. :) | ||
## Fault injection | ||
WIP | ||
## Trouble Shooting | ||
Q1. Opening the container fails with `... "docker-credential-desktop.exe": executable file not found in $PATH, out: ...`. | ||
A1. Delete the line with `credsStore` from `~/.docker/config.json` on WSL2. | ||
## License | ||
This project is licenced under the Apache-2.0 license. See the [LICENSE](LICENSE) file for more details. |
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,21 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(interfaces) | ||
|
||
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(std_msgs REQUIRED) | ||
find_package(rosidl_default_generators REQUIRED) | ||
|
||
rosidl_generate_interfaces(${PROJECT_NAME} | ||
"msg/BoolWithHeader.msg" | ||
"msg/IntWithHeader.msg" | ||
DEPENDENCIES std_msgs | ||
) | ||
|
||
ament_export_dependencies(rosidl_default_runtime) | ||
|
||
ament_package() |
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,2 @@ | ||
std_msgs/Header header | ||
bool data |
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,2 @@ | ||
std_msgs/Header header | ||
int32 data |
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,26 @@ | ||
<?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>interfaces</name> | ||
<version>0.0.0</version> | ||
<description>Interfaces</description> | ||
<maintainer email="[email protected]">vscode</maintainer> | ||
<license>Apache License 2.0</license> | ||
|
||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
|
||
<build_depend>rosidl_default_generators</build_depend> | ||
|
||
<exec_depend>rosidl_default_runtime</exec_depend> | ||
|
||
<member_of_group>rosidl_interface_packages</member_of_group> | ||
|
||
<depend>std_msgs</depend> | ||
|
||
<test_depend>ament_lint_auto</test_depend> | ||
<test_depend>ament_lint_common</test_depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
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,27 @@ | ||
from launch import LaunchDescription | ||
from launch_ros.actions import Node | ||
|
||
|
||
def generate_launch_description(): | ||
return LaunchDescription([ | ||
Node( | ||
package='num_generator', | ||
executable='generator', | ||
name='generator', | ||
), | ||
Node( | ||
package='num_generator', | ||
executable='multiplier', | ||
name='multiplier', | ||
), | ||
Node( | ||
package='num_generator', | ||
executable='feedback', | ||
name='feedback', | ||
), | ||
Node( | ||
package='num_generator', | ||
executable='initialiser', | ||
name='initialiser', | ||
) | ||
]) |
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,67 @@ | ||
"""" This node is used to provide feedback to the generator | ||
if a condition is fulfilled""" | ||
#!/usr/bin/env python3 | ||
# | ||
# Copyright (c) 2024 Robert Bosch GmbH and its subsidiaries. | ||
# This program and the accompanying materials are made available under | ||
# the terms of the Bosch Internal Open Source License v4 | ||
# which accompanies this distribution, and is available at | ||
# http://bios.intranet.bosch.com/bioslv4.txt | ||
|
||
__author__ = "Min Hee Jo" | ||
__copyright__ = "Copyright 2024, Robert Bosch GmbH" | ||
__license__ = "BIOSL" | ||
__version__ = "4.0" | ||
__email__ = "[email protected]" | ||
|
||
import rclpy | ||
import time | ||
from rclpy.node import Node | ||
from std_msgs.msg import Header | ||
from interfaces.msg import BoolWithHeader, IntWithHeader | ||
|
||
|
||
class Feedback(Node): | ||
|
||
def __init__(self): | ||
super().__init__('Feedback') | ||
self.reset_signal = True | ||
self.subscription = self.create_subscription( | ||
IntWithHeader, 'multiplier2feedback', self.num_feedback, 1) | ||
self.publisher = self.create_publisher(BoolWithHeader, 'feedback2generator', 1) | ||
|
||
def num_feedback(self, msg): | ||
# create message | ||
bool_msg = BoolWithHeader() | ||
|
||
# header | ||
header = Header() | ||
header.stamp = self.get_clock().now().to_msg() | ||
bool_msg.header = header | ||
|
||
# data | ||
if msg.data < 10: | ||
bool_msg.data = self.reset_signal = False # if condition not met set to False | ||
else: | ||
bool_msg.data = self.reset_signal = True # if condition met set to True | ||
|
||
print(bool_msg.data) | ||
|
||
# publish | ||
self.publisher.publish(bool_msg) | ||
|
||
|
||
def main(args=None): | ||
rclpy.init(args=args) | ||
node = Feedback() | ||
try: | ||
# sleep statement to spin the node after 0.2 seconds | ||
time.sleep(0.2) | ||
rclpy.spin(node) | ||
except KeyboardInterrupt: | ||
node.destroy_node() | ||
rclpy.shutdown() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.