PX4 / PX4-Autopilot

PX4 Autopilot Software
https://px4.io
BSD 3-Clause "New" or "Revised" License
8.56k stars 13.55k forks source link

[Bug] ninja: error: unknown target 'gz_x500' when installing PX4 Simulator #22119

Closed idorobotics closed 1 year ago

idorobotics commented 1 year ago

Describe the bug

Describe the bug

Following the latest PX4 Gazebo Simulation instructions installs Gazebo Garden but the PX4 simulator cannot be run. The error when running make px4_sitl gz_x500 is ninja: error: unknown target 'gz_x500'. The error is the same for all available models.

ROS 2 works fine on its own. Gazebo Garden also works fine on its own.

Performing a make clean on PX4 Autopilot and running the install script and make does not solve the problem.

To Reproduce

  1. Installed PX4 (main branch) and ROS 2 humble using the steps here: https://docs.px4.io/main/en/ros/ros2_comm.html#humble
  2. Installed Gazebo Garden using the steps here: https://docs.px4.io/main/en/sim_gazebo_gz/
  3. run make px4_sitl gz_x500 and the output is ninja: error: unknown target 'gz_x500'
  4. run make --trace px4_sitl gz_x500 (output below)
Makefile:232: target 'px4_sitl' does not exist
# check if the desired cmake configuration matches the cache then CMAKE_CACHE_CHECK stays empty
# change to build folder which fails if it doesn't exist and CACHED_CMAKE_OPTIONS stays empty
# fetch all previously configured and cached options from the build folder and transform them into the OPTION=VALUE format without type (e.g. :BOOL)
# transform the options in CMAKE_ARGS into the OPTION=VALUE format without -D
# find each currently desired option in the already cached ones making sure the complete configured string value is the same
# if the complete list of desired options is found in the list of verified options we don't need to reconfigure and CMAKE_CACHE_CHECK stays empty
# make sure to start from scratch when switching from GNU Make to Ninja
if [ Ninja = "Ninja" ] && [ -e "~/PX4_software/PX4-Autopilot/build/px4_sitl_default"/Makefile ]; then rm -rf "~/PX4_software/PX4-Autopilot/build/px4_sitl_default"; fi
# make sure to start from scratch if ninja build file is missing
if [ Ninja = "Ninja" ] && [ ! -f "~/PX4_software/PX4-Autopilot/build/px4_sitl_default"/build.ninja ]; then rm -rf "~/PX4_software/PX4-Autopilot/build/px4_sitl_default"; fi
# only excplicitly configure the first build, if cache file already exists the makefile will rerun cmake automatically if necessary
if [ ! -e "~/PX4_software/PX4-Autopilot/build/px4_sitl_default"/CMakeCache.txt ] || [  ]; then mkdir -p "~/PX4_software/PX4-Autopilot/build/px4_sitl_default" && cd "~/PX4_software/PX4-Autopilot/build/px4_sitl_default" && cmake "~/PX4_software/PX4-Autopilot" -G"Ninja" -DCONFIG=px4_sitl_default || (rm -rf "~/PX4_software/PX4-Autopilot/build/px4_sitl_default"); fi
# run the build for the specified target
cmake --build "~/PX4_software/PX4-Autopilot/build/px4_sitl_default" --  gz_x500
ninja: error: unknown target 'gz_x500'
make: *** [Makefile:232: px4_sitl] Error 1

Expected behavior

Run PX4 simulator in Gazebo Garden

Screenshot / Media

No response

Flight Log

No flight report - cannot run simulator

Software Version

Main branch from https://github.com/PX4/PX4-Autopilot

Flight controller

No physical hardware connected.

Vehicle type

None

How are the different components wired up (including port information)

No response

Additional context

No response

dagar commented 1 year ago

Can you give this a try?

idorobotics commented 1 year ago

Worked well, thanks! I think the issue was that following the instructions to first set up ROS 2 requires running make px4_sitl but the Gazebo setup instructions expect you to run make px4_sitl gz_x500 instead.

sanaosheng commented 3 months ago

Worked well, thanks! I think the issue was that following the instructions to first set up ROS 2 requires running make px4_sitl but the Gazebo setup instructions expect you to run make px4_sitl gz_x500 instead.

why I can run "make px4_sitl"seccessfully,but then failed to run "make px4_sitl gz_x500" anyway.