-
Notifications
You must be signed in to change notification settings - Fork 47
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_[Barisyaz]_[Ingenuity Flight Simulator] #39
Open
BarisYazici
wants to merge
3
commits into
space-ros:main
Choose a base branch
from
BarisYazici:feat/ingenuity-helicopter-simulation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,88 @@ | ||
# Copyright 2021 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 osrf/space-ros:latest | ||
|
||
# Disable prompting during package installation | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
ENV INGENUITY_DIR=${HOME_DIR}/ingenuity_helicopter | ||
|
||
RUN sudo apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --no-install-recommends \ | ||
ros-humble-hardware-interface \ | ||
ros-humble-generate-parameter-library \ | ||
ros-humble-xacro \ | ||
ros-humble-controller-interface \ | ||
ros-humble-realtime-tools \ | ||
ros-humble-ros2-control-test-assets \ | ||
ros-humble-controller-manager \ | ||
ros-humble-joint-state-publisher-gui \ | ||
ros-humble-control-msgs \ | ||
ros-humble-gazebo-ros \ | ||
ros-humble-control-toolbox \ | ||
ros-humble-ackermann-msgs \ | ||
ros-humble-ament-cmake \ | ||
ros-humble-ament-cmake-clang-format \ | ||
ros-humble-moveit \ | ||
ros-humble-joint-state-broadcaster \ | ||
libignition-gazebo6-dev \ | ||
ros-humble-joint-trajectory-controller \ | ||
ros-humble-ros-ign-gazebo \ | ||
ros-humble-ros-gz-bridge \ | ||
libeigen3-dev | ||
|
||
# Install the various build and test tools | ||
RUN sudo apt install -y \ | ||
build-essential \ | ||
clang-format \ | ||
cmake \ | ||
git \ | ||
libbullet-dev \ | ||
python3-colcon-common-extensions \ | ||
python3-flake8 \ | ||
python3-pip \ | ||
python3-pytest-cov \ | ||
python3-rosdep \ | ||
python3-setuptools \ | ||
python3-vcstool \ | ||
wget | ||
|
||
# Install some pip packages needed for testing | ||
RUN python3 -m pip install -U \ | ||
argcomplete \ | ||
flake8-blind-except \ | ||
flake8-builtins \ | ||
flake8-class-newline \ | ||
flake8-comprehensions \ | ||
flake8-deprecated \ | ||
flake8-docstrings \ | ||
flake8-import-order \ | ||
flake8-quotes \ | ||
pytest-repeat \ | ||
pytest-rerunfailures \ | ||
pytest | ||
|
||
COPY ingenuity_mars_helicopter ${INGENUITY_DIR}/src/ingenuity_mars_helicopter | ||
COPY helicopter_flight_control ${INGENUITY_DIR}/src/helicopter_flight_control | ||
COPY helicopter_flight_simulation ${INGENUITY_DIR}/src/helicopter_flight_simulation | ||
COPY ingenuity_bringup ${INGENUITY_DIR}/src/ingenuity_bringup | ||
COPY ingenuity_description ${INGENUITY_DIR}/src/ingenuity_description | ||
COPY ./entrypoint.sh ${INGENUITY_DIR}/entrypoint.sh | ||
|
||
RUN sudo chown -R ${USERNAME}:${USERNAME} ${INGENUITY_DIR} | ||
|
||
RUN sudo chmod +x ${INGENUITY_DIR}/entrypoint.sh | ||
|
||
ENTRYPOINT ["/home/spaceros-user/ingenuity_helicopter/entrypoint.sh"] |
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,153 @@ | ||
# NASA Space ROS Sim Summer Sprint Challenge | ||
Team lead freelance username: Barisyaz | ||
Submission title: Ingenuity Flight Simulator | ||
|
||
# Ingenuity Flight Simulator | ||
|
||
This project simulates the Ingenuity Mars Helicopter using Gazebo and ROS 2 in Space-ROS. | ||
|
||
Aim of this project is to develop tools to mimic the Martian environment as close as possible. This enables space robots to easily iterate over the development cycles. This is important especially for the aerial vehicles. Because the air is much thinner and the nature events are different. Having this in mind, I develop the Ingenuity Flight Simulator, calculating the lift and drag forces as close to the Martian atmosphere and gravity as possible. This could enable Nasa engineers to develop controllers that can react to the nature events or test flight controllers with sensor noise such as IMU, altimeter or Camera. | ||
|
||
## Structure | ||
|
||
Each folder is a ROS 2 package. Each package has their own README.md file explaining the APIs and usage examples. | ||
|
||
## Prerequisites | ||
|
||
- Docker | ||
- NVIDIA GPU (optional, but recommended for better performance) | ||
|
||
## Setup | ||
|
||
1. Clone this repository: | ||
```bash | ||
git clone [email protected]:BarisYazici/demos.git | ||
git checkout feat/ingenuity-helicopter-simulation | ||
|
||
``` | ||
|
||
2. Build the Ingenuity Flight Simulator image: | ||
```bash | ||
cd ingenuity_flight_simulator | ||
./build.sh | ||
``` | ||
|
||
## Running the Simulation | ||
|
||
First run the following to allow GUI passthrough: | ||
```bash | ||
xhost +local:docker | ||
``` | ||
|
||
To start the simulation, run: | ||
```bash | ||
./run.sh | ||
``` | ||
|
||
while the simulation is running in another terminal: | ||
|
||
```bash | ||
docker exec -it ingenuity_flight_simulator bash | ||
``` | ||
|
||
to view all the topics coming from the simulator do: | ||
|
||
```bash | ||
ign topic -l | ||
``` | ||
|
||
As an example you can subscribe to the /imu topic published from the ingenuity's body. | ||
|
||
```bash | ||
ign topic -et /imu | ||
``` | ||
|
||
|
||
This will launch the Gazebo simulation with the Ingenuity model. Gazebo simulation GUI and RViz will pop up in new windows. By default, the Ingenuity's flight controller is activated and hovers the Martian helicopter to 10 meters of altitude. | ||
|
||
|
||
## Contribution to Simulation and Control of Ingenuity | ||
|
||
To control the ingenuity helicopter we need to change the angle of attack of the blade. There are two ways to change the angle of attack of the blades. First one is collective, this changes the angle of attack of the blades uniformly over the rotation of the blade. Collective control changes the altitude of the helicopter. Second way of control is cyclic control. This way we change the angle of attack interchangeably such that it creates different lift in different parts of the rotation. Cyclic control allows us to translate in x and y directions. | ||
|
||
Ingenuity flight controller plugin implements a PID controller to change the collective to reach the desired altitude published as a gazebo ignition topic. This controller doesn't yet control the attitude of the helicopter. | ||
|
||
|
||
## Demonstration | ||
|
||
Here are some GIFs demonstrating the Ingenuity in action: | ||
|
||
![Mars dust storm](assets/mars_dust_storm.gif) | ||
*Demonstrate mars dust storm* | ||
|
||
![Take-off](assets/altitude_control.gif) | ||
*Take-off * | ||
|
||
![Landing](assets/landing.gif) | ||
*Landing* | ||
|
||
![martian helicopter](assets/martian_helicopter.png) | ||
*Close up view of Ingenuity* | ||
|
||
![rviz visualization](assets/rviz.png) | ||
*RViz visualization integration* | ||
|
||
## Architecture | ||
|
||
|
||
Here's a diagram illustrating the architecture: | ||
|
||
```mermaid | ||
graph TD | ||
A[User Input] -->|/alpha_c, /alpha_s| D[Flight Simulation Plugin] | ||
A -->|/desired_altitude| C[Flight Control Plugin] | ||
C -->|/angle_of_attack| D | ||
D -->|Forces & Torques| E[Gazebo Physics Engine] | ||
E -->|Physics Update| F[Ingenuity Model] | ||
F -->|State Feedback| E | ||
E -->|Model State| D | ||
D -->|Telemetry| G[Visualization] | ||
|
||
subgraph Gazebo Simulation | ||
E | ||
F | ||
end | ||
|
||
subgraph Gazebo Plugins | ||
C | ||
D | ||
end | ||
|
||
classDef userInput fill:#f9f,stroke:#333,stroke-width:2px; | ||
classDef gazebo fill:#cfc,stroke:#333,stroke-width:2px; | ||
classDef spaceROS fill:#fcf,stroke:#333,stroke-width:2px; | ||
classDef visualization fill:#ccf,stroke:#333,stroke-width:2px; | ||
|
||
class A userInput; | ||
class E,F gazebo; | ||
class C,D spaceROS; | ||
class G visualization; | ||
``` | ||
|
||
## Topics | ||
|
||
The following table explains the key topics used in the Ingenuity Flight Simulator: | ||
|
||
| Topic Name | Description | Data Type | Direction | | ||
|------------|-------------|-----------|-----------| | ||
| `/angle_of_attack` | Controls the collective pitch of the rotor blades | `ignition.msgs.Double` | Input to Simulation | | ||
| `/alpha_c` | Lateral cyclic control input | `ignition.msgs.Double` | Input to Simulation | | ||
| `/alpha_s` | Longitudinal cyclic control input | `ignition.msgs.Double` | Input to Simulation | | ||
| `/desired_altitude` | Sets the target altitude for the flight controller | `ignition.msgs.Double` | Input to Controller | | ||
| `/imu` | Provides IMU sensor data from the Ingenuity model | `ignition.msgs.IMU` | Output from Simulation | | ||
| `/altimeter` | Provides altitude data from the Ingenuity model | `ignition.msgs.Altimeter` | Output from Simulation | | ||
| `/camera` | Provides camera feed from the Ingenuity model | `ignition.msgs.Image` | Output from Simulation | | ||
| `/wrench/ingenuity_model/blade_1` | Forces and torques applied to blade 1 | `ignition.msgs.Wrench` | Output from Simulation | | ||
| `/wrench/ingenuity_model/blade_2` | Forces and torques applied to blade 2 | `ignition.msgs.Wrench` | Output from Simulation | | ||
| `/wrench/ingenuity_model/blade_3` | Forces and torques applied to blade 3 | `ignition.msgs.Wrench` | Output from Simulation | | ||
| `/wrench/ingenuity_model/blade_4` | Forces and torques applied to blade 4 | `ignition.msgs.Wrench` | Output from Simulation | | ||
|
||
|
||
## License | ||
|
||
Apache License 2.0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,7 @@ | ||
# !/usr/bin/env bash | ||
|
||
|
||
docker build -t ingenuity_flight_simulator . | ||
|
||
echo "" | ||
echo "##### Done! #####" |
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 @@ | ||
#!/bin/bash | ||
sudo chown -R ${USERNAME}:${USERNAME} /home/spaceros-user/ingenuity_helicopter | ||
source /home/spaceros-user/spaceros/install/setup.sh | ||
source /opt/ros/humble/setup.sh | ||
cd /home/spaceros-user/ingenuity_helicopter | ||
colcon build --packages-select helicopter_flight_control helicopter_flight_simulation ingenuity_description ingenuity_bringup | ||
source /home/spaceros-user/ingenuity_helicopter/install/setup.sh | ||
ros2 launch ingenuity_bringup ingenuity_demo.launch.py |
85 changes: 85 additions & 0 deletions
85
ingenuity_mars_helicopter/helicopter_flight_control/CMakeLists.txt
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,85 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(helicopter_flight_control) | ||
|
||
# Default to C11 for C and C++17 for C++ | ||
if(NOT CMAKE_C_STANDARD) | ||
set(CMAKE_C_STANDARD 11) | ||
endif() | ||
if(NOT CMAKE_CXX_STANDARD) | ||
set(CMAKE_CXX_STANDARD 17) | ||
endif() | ||
|
||
# Compiler options | ||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
endif() | ||
|
||
# Find packages | ||
find_package(ament_cmake REQUIRED) | ||
find_package(rclcpp REQUIRED) | ||
find_package(geometry_msgs REQUIRED) | ||
find_package(ignition-gazebo6 REQUIRED) # Assuming using Ignition Fortress | ||
find_package(pluginlib REQUIRED) | ||
|
||
if("$ENV{IGNITION_VERSION}" STREQUAL "citadel") | ||
find_package(ignition-gazebo3 REQUIRED) | ||
set(IGN_GAZEBO_VER ${ignition-gazebo3_VERSION_MAJOR}) | ||
message(STATUS "Compiling against Ignition Citadel") | ||
|
||
elseif("$ENV{IGNITION_VERSION}" STREQUAL "edifice") | ||
find_package(ignition-gazebo5 REQUIRED) | ||
set(IGN_GAZEBO_VER ${ignition-gazebo5_VERSION_MAJOR}) | ||
message(STATUS "Compiling against Ignition Edifice") | ||
|
||
elseif("$ENV{IGNITION_VERSION}" STREQUAL "fortress") | ||
find_package(ignition-gazebo6 REQUIRED) | ||
set(IGN_GAZEBO_VER ${ignition-gazebo6_VERSION_MAJOR}) | ||
message(STATUS "Compiling against Ignition Fortress") | ||
|
||
else() | ||
find_package(ignition-gazebo6 REQUIRED) | ||
set(IGN_GAZEBO_VER ${ignition-gazebo6_VERSION_MAJOR}) | ||
message(STATUS "Compiling against Ignition Fortress") | ||
endif() | ||
|
||
find_package(ignition-plugin1 REQUIRED) | ||
set(IGN_PLUGIN_VER ${ignition-plugin1_VERSION_MAJOR}) | ||
|
||
# Include directories | ||
include_directories(include) | ||
|
||
# Declare a C++ library | ||
add_library(${PROJECT_NAME} SHARED | ||
src/helicopter_flight_control.cc | ||
) | ||
|
||
|
||
target_link_libraries(${PROJECT_NAME} | ||
ignition-gazebo${IGN_GAZEBO_VER}::core | ||
ignition-plugin${IGN_PLUGIN_VER}::register | ||
) | ||
|
||
# Ament target dependencies | ||
ament_target_dependencies(${PROJECT_NAME} | ||
rclcpp | ||
geometry_msgs | ||
) | ||
|
||
# Install the library | ||
install(TARGETS ${PROJECT_NAME} | ||
DESTINATION lib | ||
) | ||
|
||
# Install header files | ||
install(DIRECTORY include/ | ||
DESTINATION include | ||
) | ||
|
||
pluginlib_export_plugin_description_file(helicopter_flight_control ign_hardware_plugins.xml) | ||
|
||
|
||
# Install launch files and other directories if necessary | ||
# e.g., install(DIRECTORY launch DESTINATION share/${PROJECT_NAME}/) | ||
|
||
# Setup the project | ||
ament_package() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move the
colcon build
into the Dockerfile so that we can ensure the build works correctly using CIThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the Dockerfile with the colcon build command. Also adjusted the entrypoint.sh such that it directly start the launch file.