Skip to content

Commit 2310827

Browse files
committed
resolves #67 support ingenuity realistic flight simulation and control
fix: docker container support
1 parent 981bd60 commit 2310827

54 files changed

Lines changed: 6509 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Copyright 2021 Open Source Robotics Foundation, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
FROM osrf/space-ros:latest
16+
17+
# Disable prompting during package installation
18+
ARG DEBIAN_FRONTEND=noninteractive
19+
20+
ENV INGENUITY_DIR=${HOME_DIR}/ingenuity_helicopter
21+
22+
RUN sudo apt-get update && \
23+
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --no-install-recommends \
24+
ros-humble-hardware-interface \
25+
ros-humble-generate-parameter-library \
26+
ros-humble-xacro \
27+
ros-humble-controller-interface \
28+
ros-humble-realtime-tools \
29+
ros-humble-ros2-control-test-assets \
30+
ros-humble-controller-manager \
31+
ros-humble-joint-state-publisher-gui \
32+
ros-humble-control-msgs \
33+
ros-humble-gazebo-ros \
34+
ros-humble-control-toolbox \
35+
ros-humble-ackermann-msgs \
36+
ros-humble-ament-cmake \
37+
ros-humble-ament-cmake-clang-format \
38+
ros-humble-moveit \
39+
ros-humble-joint-state-broadcaster \
40+
libignition-gazebo6-dev \
41+
ros-humble-joint-trajectory-controller \
42+
ros-humble-ros-ign-gazebo \
43+
ros-humble-ros-gz-bridge \
44+
libeigen3-dev
45+
46+
# Install the various build and test tools
47+
RUN sudo apt install -y \
48+
build-essential \
49+
clang-format \
50+
cmake \
51+
git \
52+
libbullet-dev \
53+
python3-colcon-common-extensions \
54+
python3-flake8 \
55+
python3-pip \
56+
python3-pytest-cov \
57+
python3-rosdep \
58+
python3-setuptools \
59+
python3-vcstool \
60+
wget
61+
62+
# Install some pip packages needed for testing
63+
RUN python3 -m pip install -U \
64+
argcomplete \
65+
flake8-blind-except \
66+
flake8-builtins \
67+
flake8-class-newline \
68+
flake8-comprehensions \
69+
flake8-deprecated \
70+
flake8-docstrings \
71+
flake8-import-order \
72+
flake8-quotes \
73+
pytest-repeat \
74+
pytest-rerunfailures \
75+
pytest
76+
77+
COPY ingenuity_mars_helicopter ${INGENUITY_DIR}/src/ingenuity_mars_helicopter
78+
COPY helicopter_flight_control ${INGENUITY_DIR}/src/helicopter_flight_control
79+
COPY helicopter_flight_simulation ${INGENUITY_DIR}/src/helicopter_flight_simulation
80+
COPY ingenuity_bringup ${INGENUITY_DIR}/src/ingenuity_bringup
81+
COPY ingenuity_description ${INGENUITY_DIR}/src/ingenuity_description
82+
COPY ./entrypoint.sh ${INGENUITY_DIR}/entrypoint.sh
83+
84+
RUN sudo chown -R ${USERNAME}:${USERNAME} ${INGENUITY_DIR}
85+
86+
RUN sudo chmod +x ${INGENUITY_DIR}/entrypoint.sh
87+
88+
ENTRYPOINT ["/home/spaceros-user/ingenuity_helicopter/entrypoint.sh"]
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# NASA Space ROS Sim Summer Sprint Challenge
2+
Team lead freelance username: Barisyaz
3+
Submission title: Ingenuity Flight Simulator
4+
5+
# Ingenuity Flight Simulator
6+
7+
This project simulates the Ingenuity Mars Helicopter using Gazebo and ROS 2 in Space-ROS.
8+
9+
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.
10+
11+
## Structure
12+
13+
Each folder is a ROS 2 package. Each package has their own README.md file explaining the APIs and usage examples.
14+
15+
## Prerequisites
16+
17+
- Docker
18+
- NVIDIA GPU (optional, but recommended for better performance)
19+
20+
## Setup
21+
22+
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).
23+
24+
After ensuring you have the `openrobotics/space_robots_demo` docker image. Go ahead and clone this repo.
25+
26+
1. Clone this repository:
27+
```bash
28+
git clone git@github.com:BarisYazici/demos.git
29+
git checkout feat/ingenuity-helicopter-simulation
30+
31+
```
32+
33+
2. Build the Ingenuity Flight Simulator image:
34+
```bash
35+
cd ingenuity_flight_simulator
36+
./build.sh
37+
```
38+
39+
## Running the Simulation
40+
41+
First run the following to allow GUI passthrough:
42+
```bash
43+
xhost +local:docker
44+
```
45+
46+
To start the simulation, run:
47+
```bash
48+
./run.sh
49+
```
50+
51+
while the simulation is running in another terminal:
52+
53+
```bash
54+
docker exec -it ingenuity_flight_simulator bash
55+
```
56+
57+
to view all the topics coming from the simulator do:
58+
59+
```bash
60+
ign topic -l
61+
```
62+
63+
As an example you can subscribe to the /imu topic published from the ingenuity's body.
64+
65+
```bash
66+
ign topic -et /imu
67+
```
68+
69+
70+
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.
71+
72+
73+
## Contribution to Simulation and Control of Ingenuity
74+
75+
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.
76+
77+
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.
78+
79+
80+
## Demonstration
81+
82+
Here are some GIFs demonstrating the Ingenuity in action:
83+
84+
![Mars dust storm](assets/mars_dust_storm.gif)
85+
*Demonstrate mars dust storm*
86+
87+
![Take-off](assets/altitude_control.gif)
88+
*Take-off *
89+
90+
![Landing](assets/landing.gif)
91+
*Landing*
92+
93+
![martian helicopter](assets/martian_helicopter.png)
94+
*Close up view of Ingenuity*
95+
96+
![rviz visualization](assets/rviz.png)
97+
*RViz visualization integration*
98+
99+
## Architecture
100+
101+
102+
Here's a diagram illustrating the architecture:
103+
104+
```mermaid
105+
graph TD
106+
A[User Input] -->|/alpha_c, /alpha_s| D[Flight Simulation Plugin]
107+
A -->|/desired_altitude| C[Flight Control Plugin]
108+
C -->|/angle_of_attack| D
109+
D -->|Forces & Torques| E[Gazebo Physics Engine]
110+
E -->|Physics Update| F[Ingenuity Model]
111+
F -->|State Feedback| E
112+
E -->|Model State| D
113+
D -->|Telemetry| G[Visualization]
114+
115+
subgraph Gazebo Simulation
116+
E
117+
F
118+
end
119+
120+
subgraph Gazebo Plugins
121+
C
122+
D
123+
end
124+
125+
classDef userInput fill:#f9f,stroke:#333,stroke-width:2px;
126+
classDef gazebo fill:#cfc,stroke:#333,stroke-width:2px;
127+
classDef spaceROS fill:#fcf,stroke:#333,stroke-width:2px;
128+
classDef visualization fill:#ccf,stroke:#333,stroke-width:2px;
129+
130+
class A userInput;
131+
class E,F gazebo;
132+
class C,D spaceROS;
133+
class G visualization;
134+
```
135+
136+
137+
## License
138+
139+
Apache License 2.0
3.49 MB
Loading
4.96 MB
Loading
577 KB
Loading
2.79 MB
Loading
391 KB
Loading
391 KB
Loading
128 KB
Loading

ingenuity_mars_helicopter/build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# !/usr/bin/env bash
2+
3+
4+
docker build -t ingenuity_flight_simulator .
5+
6+
echo ""
7+
echo "##### Done! #####"

0 commit comments

Comments
 (0)