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

Added SITL Gazebo #12346

Merged
merged 5 commits into from Feb 18, 2023
Merged

Added SITL Gazebo #12346

merged 5 commits into from Feb 18, 2023

Conversation

ahcorde
Copy link
Contributor

@ahcorde ahcorde commented Feb 10, 2023

Signed-off-by: Alejandro Hernández Cordero ahcorde@gmail.com

Related with this issue #12345

This PR update the current work done in this PR #11303 by @xuhao1 to include SITL Gazebo support.

Where is the right place to locate the documentation?

@github-actions

This comment has been minimized.

@haslinghuis
Copy link
Member

haslinghuis commented Feb 10, 2023

It's a hidden here: https://github.com/betaflight/betaflight/tree/master/src/main/target/SITL

But we'd like to include any updated to documentation on the betaflight.com repo (development section).

Also have been using Gazebo before with SITL (around 2019) it looks much better now. Need some time to get it all running on a test machine. Hopefully Ubuntu 22.04 is sufficient as in the past we had to use older versions of Ubuntu to get ROS running.

@blckmn
Copy link
Member

blckmn commented Feb 10, 2023

AUTOMERGE: (FAIL)

  • github identifies PR as mergeable -> FAIL
  • assigned to a milestone -> PASS
  • cooling off period lapsed -> PASS
  • commit count less or equal to three -> FAIL
  • Don't merge label NOT found -> PASS
  • at least one RN: label found -> PASS
  • Tested label found -> FAIL
  • assigned to an approver -> FAIL
  • approver count at least three -> FAIL

Comment on lines 601 to 602
if (index + pwmRawPkt.motorCount < SIMULATOR_MAX_PWM_CHANNELS)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (index + pwmRawPkt.motorCount < SIMULATOR_MAX_PWM_CHANNELS)
{
if (index + pwmRawPkt.motorCount < SIMULATOR_MAX_PWM_CHANNELS) {

Please check: https://betaflight.com/docs/development/CodingStyle

@haslinghuis
Copy link
Member

Install on fresh 22.04.1 following instructions on https://github.com/osrf/vehicle_gateway

For fresh install some required packages are missing in the instructions:

sudo apt install python3-pip
sudo apt install git
sudo apt install python3-vcstool

Now stuck on

Next, build Gazebo Garden from source, using some specific branches in some repositories that are currently required for this project. The precise arrangement of branches is described in the gazebo.repos file which will be used by the command sequence below. The full instructions are [here](https://gazebosim.org/docs/garden/install_ubuntu_src), and summarized as follows:

mkdir -p ~/vg/gz_ws/src
cd ~/vg/gz_ws
vcs import src < ../vg_ws/src/vehicle_gateway/gazebo.repos
sudo apt install -y $(sort -u $(find . -iname 'packages-'`lsb_release -cs`'.apt' -o -iname 'packages.apt' | grep -v '/\.git/') | sed '/gz\|sdf/d' | tr '\n' ' ')
source /opt/ros/humble/setup.bash
colcon build --merge-install

Now you should have Gazebo available to any terminals that source ~/vg/gz_ws/install/setup.bash
Cloning into '.'...
=== src/gz-sensors (git) ===
Could not checkout ref 'ahcorde/air_speed': fatal: invalid reference: ahcorde/air_speed
=== src/gz-sim (git) ===
Cloning into '.'...
=== src/gz-tools (git) ===
Cloning into '.'...
=== src/gz-transport (git) ===
Cloning into '.'...
=== src/gz-utils (git) ===
Cloning into '.'...
=== src/sdformat (git) ===
Could not checkout ref 'ahcorde/air_speed': fatal: invalid reference: ahcorde/air_speed
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package libogre-next-2.3-dev
E: Couldn't find any package by glob 'libogre-next-2.3-dev'
colcon: command not found

@ahcorde
Copy link
Contributor Author

ahcorde commented Feb 13, 2023

@haslinghuis Thank you for the review.

We will create a Gazebo release this week and this will simplify the instructions too. I will ping you again.

@github-actions

This comment has been minimized.

@ctzsnooze
Copy link
Member

Please provide detailed instructions here in the PR.
They can be updated and clarified as needed.
Then they make a good basis for a wiki entry.

@haslinghuis
Copy link
Member

@ahcorde please rebase

Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@ahcorde ahcorde force-pushed the ahcorde/sitl_gazebo branch 2 times, most recently from e881a1c to c773153 Compare February 15, 2023 22:39
@github-actions

This comment has been minimized.

Copy link
Member

@KarateBrot KarateBrot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mostly have minor suggestions for clean code formatting.

There is one line in pwmWriteMotor() that needs attention, though (see comment about MAX_SUPPORTED_MOTORS).

src/main/sensors/barometer.c Outdated Show resolved Hide resolved
src/main/target/SITL/sitl.c Outdated Show resolved Hide resolved
src/main/target/SITL/sitl.c Outdated Show resolved Hide resolved
src/main/target/SITL/target.h Outdated Show resolved Hide resolved
src/main/target/SITL/target.h Outdated Show resolved Hide resolved
src/main/target/SITL/sitl.c Outdated Show resolved Hide resolved
src/main/msp/msp.c Outdated Show resolved Hide resolved
src/main/target/SITL/sitl.c Outdated Show resolved Hide resolved
src/main/target/SITL/sitl.c Outdated Show resolved Hide resolved
src/main/target/SITL/sitl.c Outdated Show resolved Hide resolved
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@ahcorde ahcorde requested review from KarateBrot and removed request for ledvinap and blckmn February 16, 2023 12:24
@github-actions

This comment has been minimized.

src/main/main.c Outdated Show resolved Hide resolved
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@github-actions
Copy link

Do you want to test this code? Here you have an automated build:
Assets
WARNING: It may be unstable. Use only for testing! See: https://www.youtube.com/watch?v=I1uN9CN30gw for instructions for unified targets!

@blckmn blckmn merged commit 9dc9c51 into betaflight:master Feb 18, 2023
This was referenced Feb 20, 2023
davidbitton pushed a commit to davidbitton/betaflight that referenced this pull request Feb 5, 2024
@astro75
Copy link

astro75 commented Apr 2, 2024

Is there any updated documentation on how to run betaflight with Gazebo?

This doc file looks outdated (7 years old) https://github.com/betaflight/betaflight/blob/master/src/main/target/SITL/README.md

Also found this doc page that looks different from the previous one https://betaflight.com/docs/development/sitl . It links to a recent version of Gazebo, but listed start command is for an old version that does not work with a current version gazebo --verbose ./iris_arducopter_demo.world

Which version of Gazebo should work with Betaflight SITL?

@haslinghuis
Copy link
Member

If latest Gazebo does not work - we love contribution on updating the docs.

@astro75
Copy link

astro75 commented Apr 3, 2024

Figured out that I need to use betaflight_gazebo and betaflight_sim from https://github.com/osrf/vehicle_gateway/tree/main

I will try to run it another day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: COMPLETED
Development

Successfully merging this pull request may close these issues.

None yet

6 participants