Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NASA Challenge_[@utkrishtjain]_[Custom Models & Gazebo Plugins for Realistic Simulations] (Ref Issue: #46) #40

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4bde781
Added base custom_gz_plugins ros2 pkg (#46)
jasmeet0915 Sep 1, 2024
15d1202
Updated names from ignition gazebo to Gz Sim (#46)
jasmeet0915 Sep 3, 2024
51ffd66
Updated world to latest standards (#46)
jasmeet0915 Sep 3, 2024
89f82a5
Changed name of terrain model to prevent conflict (#46)
jasmeet0915 Sep 3, 2024
846ee61
Added world files for custom terrain models made from NASA PDS (#46)
jasmeet0915 Sep 4, 2024
cb7480b
Added DustManager Plugin for dust control (#46)
namikxgithub Sep 4, 2024
770b653
Added hooks and models (#46)
namikxgithub Sep 4, 2024
225b636
CmakeList changes for env hooks and plugins (#46)
namikxgithub Sep 4, 2024
ae7a700
Fixed hooks (#46)
namikxgithub Sep 4, 2024
5beeaef
Removed hooks and models (#46)
namikxgithub Sep 4, 2024
3b8fbbc
Added launch file for launching demo_worlds (#46)
jasmeet0915 Sep 4, 2024
20a6bfa
Added base readme for dust manager (#46)
namikxgithub Sep 4, 2024
d337e08
Readded env hooks (#46)
namikxgithub Sep 4, 2024
3890c75
Fixed launch files for mars rover (#46)
namikxgithub Sep 4, 2024
6f57eee
Updated README file (#46)
jchaudhary21 Sep 4, 2024
cdf41f4
Converted sun_sphere model.sdf file into raw string in DayLightManage…
jchaudhary21 Sep 4, 2024
dc8ada7
Changed sun's direction from CCW -> CW (#46)
jchaudhary21 Sep 4, 2024
6d0ff59
Modify license header in DayLightManager.cc (#46)
jchaudhary21 Sep 4, 2024
7ac8998
Modify license header in DayLightManager.hh (#46)
jchaudhary21 Sep 4, 2024
ff97cc1
Updated README file (#46)
jchaudhary21 Sep 4, 2024
945e993
Added Dockerfile, build.sh & run.sh scripts (#46)
jasmeet0915 Sep 8, 2024
f22eb1c
Added assets and readme changes (#46)
namikxgithub Sep 4, 2024
3545382
Added XACRO to dependencies, corrected demo launch file (#46)
namikxgithub Sep 8, 2024
72c6fee
Added time publisher (#46)
jchaudhary21 Sep 9, 2024
49ce01d
Changed VCS repo branch and completed plugin ReadMe.md (#46)
namikxgithub Sep 10, 2024
fbdad4b
Added base Reame.md (#46)
namikxgithub Sep 11, 2024
6839d24
Added VehicleDust plugin (#46)
namikxgithub Sep 11, 2024
09b4544
Added DroneDustPlugin and added documentation for the plugins (#46)
namikxgithub Sep 11, 2024
5c38d20
Added demo launch files (#46)
namikxgithub Sep 11, 2024
7d330e2
Added readme instructions to launch the simulation (#46)
namikxgithub Sep 11, 2024
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
23 changes: 23 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"configurations": [
{
"browse": {
"databaseFilename": "${default}",
"limitSymbolsToIncludedHeaders": false
},
"includePath": [
"/home/nxfrst/x-storage/atom_robotics/space_ros_submissions/space_ros_ws/install/canadarm/include/**",
"/home/nxfrst/x-storage/combat_robotics/arista_test_ws/install/arista_interfaces/include/**",
"/home/nxfrst/x-storage/combat_robotics/arista_test_ws/install/arista_control_stream/include/**",
"/opt/ros/humble/include/**",
"/usr/include/**"
],
"name": "ROS",
"intelliSenseMode": "gcc-x64",
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "c++14"
}
],
"version": 4
}
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"python.autoComplete.extraPaths": [
"/home/nxfrst/x-storage/atom_robotics/space_ros_submissions/space_ros_ws/install/mars_rover/local/lib/python3.10/dist-packages",
"/home/nxfrst/x-storage/atom_robotics/space_ros_submissions/space_ros_ws/install/canadarm/local/lib/python3.10/dist-packages",
"/home/nxfrst/x-storage/combat_robotics/arista_test_ws/install/arista_interfaces/local/lib/python3.10/dist-packages",
"/opt/ros/humble/lib/python3.10/site-packages",
"/opt/ros/humble/local/lib/python3.10/dist-packages"
],
"python.analysis.extraPaths": [
"/home/nxfrst/x-storage/atom_robotics/space_ros_submissions/space_ros_ws/install/mars_rover/local/lib/python3.10/dist-packages",
"/home/nxfrst/x-storage/atom_robotics/space_ros_submissions/space_ros_ws/install/canadarm/local/lib/python3.10/dist-packages",
"/home/nxfrst/x-storage/combat_robotics/arista_test_ws/install/arista_interfaces/local/lib/python3.10/dist-packages",
"/opt/ros/humble/lib/python3.10/site-packages",
"/opt/ros/humble/local/lib/python3.10/dist-packages"
]
}
50 changes: 50 additions & 0 deletions custom_gz_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
cmake_minimum_required(VERSION 3.8)
project(custom_gz_plugins)

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(rclcpp REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

add_subdirectory(src/DayLightManager)
add_subdirectory(src/DustManager)
add_subdirectory(src/VehicleDust)
add_subdirectory(src/DroneDustPlugin)

add_executable(inguenity_control nodes/inguenity_control.cpp)
ament_target_dependencies(inguenity_control rclcpp std_msgs)

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

## Install the launch directory
install(
DIRECTORY launch worlds config
DESTINATION share/${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_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/env_hooks/${PROJECT_NAME}.dsv.in")

ament_package()
108 changes: 108 additions & 0 deletions custom_gz_plugins/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Copyright 2024 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.
#
# A Docker configuration script to build the Space ROS image.
#
# The script provides the following build arguments:
#
# VCS_REF - The git revision of the Space ROS source code (no default value).
# VERSION - The version of Space ROS (default: "preview")

FROM osrf/space-ros:latest

# Define arguments used in the metadata definition
ARG VCS_REF
ARG VERSION="preview"

# Specify the docker image metadata
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.name="Real World Extraterrestrial Simulations"
LABEL org.label-schema.description="Realistic Extraterrestrial Simulations demos using custom GZ plugins & data from NASA PDS"
LABEL org.label-schema.vendor="Open Robotics"
LABEL org.label-schema.version=${VERSION}
LABEL org.label-schema.url="https://github.com/space-ros"
LABEL org.label-schema.vcs-url="https://github.com/space-ros/docker"
LABEL org.label-schema.vcs-ref=${VCS_REF}

# Define a few key variables
ENV DEMO_DIR=${HOME_DIR}/demos_ws
ENV GZ_VERSION=harmonic

# Disable prompting during package installation
ARG DEBIAN_FRONTEND=noninteractive

# Clone all space-ros sources
RUN mkdir ${SPACEROS_DIR}/src \
&& vcs import ${SPACEROS_DIR}/src < ${SPACEROS_DIR}/exact.repos

# Make sure the latest versions of packages are installed
# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that
# the cache won't make it into the built image but will be maintained between steps.
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
sudo apt-get update
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
sudo apt-get dist-upgrade -y
RUN rosdep update

# Get rosinstall_generator
# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that
# the cache won't make it into the built image but will be maintained between steps.
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
sudo apt-get update -y && sudo apt-get install -y python3-rosinstall-generator

RUN mkdir -p ${DEMO_DIR}/src
WORKDIR ${DEMO_DIR}

# Install libmongoc for development
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
sudo apt-get install libmongoc-dev -y

# Compile mongo cxx driver https://mongocxx.org/mongocxx-v3/installation/linux/
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
sudo apt-get install libssl-dev build-essential devscripts debian-keyring fakeroot debhelper cmake libboost-dev libsasl2-dev libicu-dev libzstd-dev doxygen -y
RUN wget https://github.com/mongodb/mongo-cxx-driver/releases/download/r3.6.7/mongo-cxx-driver-r3.6.7.tar.gz
RUN tar -xzf mongo-cxx-driver-r3.6.7.tar.gz
RUN cd mongo-cxx-driver-r3.6.7/build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local && sudo cmake --build . --target EP_mnmlstc_core && cmake --build . && sudo cmake --build . --target install

# Add osrf packages repository and manually install gz sim harmonic dependecies as they haven't been added to the rosdep index as of yet
RUN sudo curl https://packages.osrfoundation.org/gazebo.gpg --output /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
RUN sudo apt-get update && sudo apt-get install -y libgz-math7-dev libgz-transport13-dev libgz-sim8-dev libgz-msgs10-dev libgz-plugin2-dev

# Get the source for the dependencies
COPY --chown=${USERNAME}:${USERNAME} dependencies_source_pkgs.repos /tmp/
RUN vcs import src < /tmp/dependencies_source_pkgs.repos && /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"'

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
sudo apt-get update -y \
&& /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' \
&& rosdep install --from-paths ${SPACEROS_DIR}/src src --ignore-src -r -y --rosdistro ${ROSDISTRO} --skip-keys "console_bridge generate_parameter_library fastcdr fastrtps rti-connext-dds-5.3.1 urdfdom_headers rmw_connextdds ros_testing rmw_connextdds rmw_fastrtps_cpp rmw_fastrtps_dynamic_cpp composition demo_nodes_py lifecycle rosidl_typesupport_fastrtps_cpp rosidl_typesupport_fastrtps_c ikos diagnostic_aggregator diagnostic_updater joy qt_gui rqt_gui rqt_gui_py"

# Build the demo
RUN /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash \
&& colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release'

# Add the user to the render group so that the user can access /dev/dri/renderD128
RUN sudo usermod -aG render $USERNAME

# Setup the entrypoint
COPY ./entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
CMD ["bash"]
109 changes: 109 additions & 0 deletions custom_gz_plugins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# NASA Space ROS Sim Summer Sprint Challenge

Team Lead Freelancer Username: @utkrishtjain

Submission Title: Custom Models & Gazebo Plugins for Realistic Simulations

## Description and Features

### Day Light Manager Plugin
The Sun is a crucial factor in driving most planetary processes, affecting nearly every environmental aspect either directly or indirectly. For realistic environmental simulations, accurately modeling the Sun's movement is vital, particularly in complex scenarios. The Daylight Manager plugin in Gazebo simulates the Sun's path based on the time of day and the observer's latitude, offering a dynamic and lifelike portrayal of sunlight. As the Sun's position changes, the shadows cast by objects and the background color also shift, as illustrated below.
> For detailed description of the plugin and it's usage, click [here](src/DayLightManager/README.md).

![Day Light Manager](assets/time_of_day.gif)


### Dust Manager Plugin
The Dust Manager plugin enables the simulation of realistic dust behavior in Martian or space environments by managing particle emitters. Dust plays a critical role in extraterrestrial settings, especially on Mars, where it can impact visibility, equipment functionality, and the overall success of missions. This plugin allows for precise simulation of dust clouds, supporting the development and testing of vehicles and systems intended for planetary exploration. By replicating how dust interacts with moving objects, it helps create more authentic and challenging scenarios for space missions. Additionally, the Dust Manager Plugin offers the ability to control wind conditions based on the parameters of dust storms incorporated into the simulation.
> For detailed description of the plugin and it's usage, click [here](src/DustManager/README.md).

![Dust Manager Gui](assets/dust_gui.gif)

### Car Dust Plugin
The Dust Emission Plugin simulates dust clouds generated by heavy vehicles moving across dusty terrains, such as the surfaces of Mars or the Moon. As vehicles traverse these environments, the plugin dynamically controls particle emitters to mimic realistic dust behavior, taking into account vehicle speed, surface texture, and atmospheric conditions. This enhances the accuracy of simulations for planetary exploration by providing lifelike interactions between vehicles and dust, aiding in the design and testing of exploration systems.

> For detailed description of the plugin and it's usage, click [here](src/VehicleDust/README.md)

![Car Dust](assets/car_dust.gif)

### Drone Dust Plugin
The Drone Dust plugin simulates the dust clouds dispersed by a drone's thrusters during takeoff and landing in dusty environments, such as on Mars or the Moon. It dynamically controls particle emitters based on the drone's movement and thruster activity, creating realistic dust dispersion effects. This plugin helps in evaluating how dust affects the drone's performance and surrounding environment, enabling more accurate simulations for planetary exploration and vehicle testing.

> For detailed description of the plugin and it's usage, click [here](src/DroneDustPlugin/README.md)

![Drone Dust](assets/drone_dust.gif)



### Real Surface Models
Custom models made from real elevation data (From NASA's Planetary Data System) of celestial bodies like Moon and Mars is also added.

- Model of Lunar Terrain made from elevation data LOLA on board the Lunar Reconnaissance Orbiter (LRO)

- Models of Martian Terrain made from elevation data from HiRISE Images on board the Mars Reconnaissance Orbiter (MRO)

<img src="assets/mars_world.png" alt="Mars" width="45%">
<img src="assets/moon_world.png" alt="Moon" width="45%">

## Build and Run

- Build the Custom Docker image with all the custom dependencies using the following command

```shell
./build.sh
```

- Once the Image has been build, use the following command to run the container

```shell
./run.sh
```
This will run the container where you can launch the simulation.
> If the container is running, you can use the same script/command in another terminal instance to attach a terminal into the docker.

### GUI PLUGINS
- Once the docker container is up, you can use the demo launch file to launch the simualtion using the following command.

```shell
ros2 launch custom_gz_plugins demo_world.launch.py
```
> In order to user the GUI Plugin: DustManger or DayLightManger, use to menu option in the simulation (Top Right Corner) to load the plugin

### System Plugins

#### Vehicle Dust
- Inside the docker container, navigate to the worlds directory using the following command
```bash
cd /home/spaceros-user/demos_ws/src/demos/custom_gz_plugins/worlds
```
- Use the follwing command to launch the world in GZ SIM

```bash
gz sim -r vehicle_dust_demo.sdf
```
- Use the teleop GUI plugin in GZ SIM to drive the robot im order to see the dust effect in the simulation

#### Drone Dust
- Inside the docker container, navigate to the worlds directory using the following command
```bash
cd /home/spaceros-user/demos_ws/src/demos/custom_gz_plugins/worlds
```
- Use the follwing command to launch the world in GZ SIM

```bash
gz sim -r vehicle_dust_demo.sdf
```

- Run the follwoing command to launch the ros-gz bridges
```bash
ros2 launch custom_gz_plugins ingenuity.launch.py
```

- Run the following command to start the teleop node of ingenuity.
```bash
ros2 run custom_gz_plugins inguenity_control
```
- Use the teleop node to fly the ingenuity robot im order to see the dust effect in the simulation


> Note: These simulations are just to demonstate the plugins features so the dynamics and physics of the models might not be accurate.
Binary file added custom_gz_plugins/assets/car_dust.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added custom_gz_plugins/assets/drone_dust.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added custom_gz_plugins/assets/dust_gui.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added custom_gz_plugins/assets/mars_world.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added custom_gz_plugins/assets/moon_world.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added custom_gz_plugins/assets/time_of_day.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions custom_gz_plugins/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

ORG=spaceros
IMAGE=custom_sim_custom_plugins_demo
TAG=latest

VCS_REF=""
VERSION=preview

# Exit script with failure if build fails
set -eo pipefail

echo ""
echo "##### Building Docker Image #####"
echo ""

docker build -t $ORG/$IMAGE:$TAG \
--build-arg VCS_REF="$VCS_REF" \
--build-arg VERSION="$VERSION" .

echo ""
echo "##### Done! #####"
Empty file.
24 changes: 24 additions & 0 deletions custom_gz_plugins/config/ingenuity_bridge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

- ros_topic_name: "/thrust"
gz_topic_name: "/model/ingenuity/joint/bottomblade_joint/cmd_thrust"
ros_type_name: "std_msgs/msg/Float64"
gz_type_name: "gz.msgs.Double"
direction: ROS_TO_GZ

- ros_topic_name: "/ang_vel"
gz_topic_name: "/model/ingenuity/joint/bottomblade_joint/ang_vel"
ros_type_name: "std_msgs/msg/Float64"
gz_type_name: "gz.msgs.Double"
direction: ROS_TO_GZ

- ros_topic_name: "/upper_blade"
gz_topic_name: "/plate1_joint/cmd_pos"
ros_type_name: "std_msgs/msg/Float64"
gz_type_name: "gz.msgs.Double"
direction: ROS_TO_GZ

- ros_topic_name: "/lower_blade"
gz_topic_name: "/plate2_joint/cmd_pos"
ros_type_name: "std_msgs/msg/Float64"
gz_type_name: "gz.msgs.Double"
direction: ROS_TO_GZ
Loading
Loading