forked from space-ros/demos
-
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.
resolves space-ros#67 support ingenuity realistic flight simulation a…
…nd control fix: docker container support
- Loading branch information
1 parent
981bd60
commit 2310827
Showing
54 changed files
with
6,509 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,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,139 @@ | ||
# 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 | ||
|
||
This project builds on `openrobotics/space_robots_demo` docker image. To build that docker image follow the instructions at this [README](https://github.com/space-ros/docker/blob/main/moveit2/README.md). To build that image, you also need to build the spaceros base image. You can access that [here](https://github.com/space-ros/space-ros). | ||
|
||
After ensuring you have the `openrobotics/space_robots_demo` docker image. Go ahead and clone this repo. | ||
|
||
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; | ||
``` | ||
|
||
|
||
## 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.