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

Merge ignition-edifice into main #20

Merged
merged 32 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5a0614e
JSON: initial steps to convert ardupilot_gazebo to use the SITL JSON …
srmainwaring Jan 19, 2021
ee0bc5d
JSON: add stand alone example to test SITL JSON socket interface
srmainwaring Jan 20, 2021
28a77b7
JSON: update add c++ socket example
srmainwaring Jan 21, 2021
af6ed39
JSON: update ArduPilotPlugin to use the SITL JSON interface
srmainwaring Jan 21, 2021
9cfdca0
JSON: replace jsoncpp with rapidjson
srmainwaring Jan 22, 2021
c281221
JSON: update socket timeout in ArduPilotPlugin
srmainwaring Jan 22, 2021
e5ee968
JSON: refactor param names, move loading of sensor params to separate…
srmainwaring Jan 23, 2021
930c9e2
JSON: enable check for STIL JSON protocol magic
srmainwaring Jan 23, 2021
c8154eb
JSON: update class documentation
srmainwaring Jan 23, 2021
a4379cb
JSON: additional checks for frame ordering and frame synchronisation
srmainwaring Jan 23, 2021
666163c
JSON: revert the deprecation of the fdm_port_in parameter
srmainwaring Jan 24, 2021
860f599
Models: remove the xml namespace from the iris model <sdf> element
srmainwaring Jan 24, 2021
1f5a851
JSON: add optional servo limits params to each servo controller
srmainwaring Jan 27, 2021
7c02d89
JSON: update CMakeLists.txt
srmainwaring Feb 23, 2021
c42e626
JSON: add install instructions
srmainwaring Feb 23, 2021
1f66d6f
JSON: remove socket and JSON examples
srmainwaring Apr 27, 2021
201509d
[IGN] migrate plugin using the json backend to ignition-edifice
srmainwaring Aug 23, 2021
fc7b7f7
[IGN] ensure the imu name is captured correctly
srmainwaring Aug 23, 2021
dc5a49b
[IGN] update iris_with_standoffs model to use additional sdf params f…
srmainwaring Aug 23, 2021
db7d05a
[IGN] update iris_with_standoffs model to use force controlled joints
srmainwaring Sep 14, 2021
9ac286e
[IGN] remove commented code and adjust formatting
srmainwaring Sep 14, 2021
81ec53b
[Iris] update colours for quadcopter model
srmainwaring Sep 14, 2021
fd00f11
[Zephyr] add zephyr plane model and demo world (#1)
srmainwaring Sep 16, 2021
49a5e52
[IGN] update the frame conversion calculation to use pose composition…
srmainwaring Sep 20, 2021
cda31ad
[Iris] add example for Iris based upon the edifice-demo depot world (#4)
srmainwaring Sep 20, 2021
56a6faf
[IGN] bug fix - last controller update time should not be updated if …
srmainwaring Sep 22, 2021
3b0dc18
Add support for lock-step simulation (#6)
srmainwaring Sep 22, 2021
1043016
fixed git URL
tridge Dec 2, 2021
f340685
fixed git URL
tridge Dec 2, 2021
a4c01f3
Merge pull request #3 from tridge/pr-readme
peterbarker Dec 2, 2021
10ea0ef
Merge pull request #4 from tridge/pr-ig-readme
srmainwaring Dec 2, 2021
a805ef2
Ensure the model base link is set to the correct model
srmainwaring Jan 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
274 changes: 107 additions & 167 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,170 +1,110 @@
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)

#============================================================================
# Initialize the project
#============================================================================
project(ardupilot_sitl_gazebo)


#######################
## Find Dependencies ##
#######################

find_package(gazebo REQUIRED)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GAZEBO_CXX_FLAGS}")

if("${GAZEBO_VERSION}" VERSION_LESS "8.0")
message(FATAL_ERROR "You need at least Gazebo 8.0. Your version: ${GAZEBO_VERSION}")
else()
message("Gazebo version: ${GAZEBO_VERSION}")
endif()

###### COMPILE RULES ######
include(CheckCXXCompilerFlag)

macro(filter_valid_compiler_flags)
foreach(flag ${ARGN})
CHECK_CXX_COMPILER_FLAG(${flag} R${flag})
if(${R${flag}})
set(VALID_CXX_FLAGS "${VALID_CXX_FLAGS} ${flag}")
endif()
endforeach()
endmacro()

set(CMAKE_CXX_EXTENSIONS off) # see gazebo CMakeList

if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo Profile Check" FORCE)
endif (NOT CMAKE_BUILD_TYPE)

# Build type link flags
set (CMAKE_LINK_FLAGS_RELEASE " " CACHE INTERNAL "Link flags for release" FORCE)
set (CMAKE_LINK_FLAGS_RELWITHDEBINFO " " CACHE INTERNAL "Link flags for release with debug support" FORCE)
set (CMAKE_LINK_FLAGS_DEBUG " " CACHE INTERNAL "Link flags for debug" FORCE)
set (CMAKE_LINK_FLAGS_PROFILE " -pg" CACHE INTERNAL "Link flags for profile" FORCE)
set (CMAKE_LINK_FLAGS_COVERAGE " --coverage" CACHE INTERNAL "Link flags for static code coverage" FORCE)

set (CMAKE_C_FLAGS_RELEASE "")
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND NOT MSVC)
# -s doesn't work with clang or Visual Studio, see alternative in link below:
# http://stackoverflow.com/questions/6085491/gcc-vs-clang-symbol-strippingu
set (CMAKE_C_FLAGS_RELEASE "-s")
endif()

if (NOT MSVC)
set (CMAKE_C_FLAGS_RELEASE " ${CMAKE_C_FLAGS_RELEASE} -O3 -DNDEBUG ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for release" FORCE)
set (CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})

set (CMAKE_C_FLAGS_RELWITHDEBINFO " -g -O2 ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for release with debug support" FORCE)
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO})

set (CMAKE_C_FLAGS_DEBUG " -ggdb3 ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for debug" FORCE)
set (CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})

set (CMAKE_C_FLAGS_PROFILE " -fno-omit-frame-pointer -g -pg ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for profile" FORCE)
set (CMAKE_CXX_FLAGS_PROFILE ${CMAKE_C_FLAGS_PROFILE})

set (CMAKE_C_FLAGS_COVERAGE " -g -O0 -Wformat=2 --coverage -fno-inline ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for static code coverage" FORCE)
set (CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE}")
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# -fno-default-inline -fno-implicit-inline-templates are unimplemented, cause errors in clang
# -fno-elide-constructors can cause seg-faults in clang 3.4 and earlier
# http://llvm.org/bugs/show_bug.cgi?id=12208
set (CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -fno-default-inline -fno-implicit-inline-templates -fno-elide-constructors")
endif()
endif()

#####################################
# Set all the global build flags
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}")
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}")

# Compiler-specific C++11 activation.
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (NOT (GCC_VERSION VERSION_GREATER 4.7))
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.8 or greater.")
endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CLANG_VERSION)
if (NOT (CLANG_VERSION VERSION_GREATER 3.2))
message(FATAL_ERROR "${PROJECT_NAME} requires clang 3.3 or greater.")
endif ()

if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
if (MSVC_VERSION LESS 1800)
message(FATAL_ERROR "${PROJECT_NAME} requires VS 2013 or greater.")
endif ()
else ()
message(FATAL_ERROR "Your C++ compiler does not support C++11.")
endif ()

set(WARN_LEVEL "-Wall")
filter_valid_compiler_flags(${WARN_LEVEL}
-Wextra -Wno-long-long -Wno-unused-value -Wfloat-equal -Wshadow
-Wswitch-default -Wmissing-include-dirs -pedantic)
if (UNIX AND NOT APPLE)
filter_valid_compiler_flags(-fvisibility=hidden -fvisibility-inlines-hidden)
endif()

set(UNFILTERED_FLAGS "-std=c++14")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VALID_CXX_FLAGS} ${UNFILTERED_FLAGS}")

###########
## Build ##
###########

include_directories(
${PROJECT_SOURCE_DIR}
include
${GAZEBO_INCLUDE_DIRS}
)

link_libraries(
${GAZEBO_LIBRARIES}
)

link_directories(
${GAZEBO_LIBRARY_DIRS}
)

set (plugins_single_header
ArduPilotPlugin
ArduCopterIRLockPlugin
GimbalSmall2dPlugin
)

add_library(ArduCopterIRLockPlugin SHARED src/ArduCopterIRLockPlugin.cc)
target_link_libraries(ArduCopterIRLockPlugin ${GAZEBO_LIBRARIES})

add_library(ArduPilotPlugin SHARED src/ArduPilotPlugin.cc)
target_link_libraries(ArduPilotPlugin ${GAZEBO_LIBRARIES})

if("${GAZEBO_VERSION}" VERSION_LESS "8.0")
add_library(GimbalSmall2dPlugin SHARED src/GimbalSmall2dPlugin.cc)
target_link_libraries(GimbalSmall2dPlugin ${GAZEBO_LIBRARIES})
install(TARGETS GimbalSmall2dPlugin DESTINATION ${GAZEBO_PLUGIN_PATH})
endif()

install(TARGETS ArduCopterIRLockPlugin DESTINATION ${GAZEBO_PLUGIN_PATH})
install(TARGETS ArduPilotPlugin DESTINATION ${GAZEBO_PLUGIN_PATH})

install(DIRECTORY models DESTINATION ${GAZEBO_MODEL_PATH}/..)
install(DIRECTORY worlds DESTINATION ${GAZEBO_MODEL_PATH}/..)

# uninstall target
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)

add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
#------------------------------------------------------------------------
# Compile as C++14

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

#============================================================================
# Find ignition-cmake
#============================================================================
find_package(ignition-cmake2 2.8.0 REQUIRED)
set(IGN_CMAKE_VER ${ignition-cmake2_VERSION_MAJOR})

#============================================================================
# Search for project-specific dependencies
#============================================================================

# ign_find_package(sdformat11 REQUIRED VERSION 11.2.2)
# set(SDF_VER ${sdformat11_VERSION_MAJOR})

#--------------------------------------
# Find ignition-common
# ign_find_package(ignition-common4 REQUIRED COMPONENTS all)
# set(IGN_COMMON_VER ${ignition-common4_VERSION_MAJOR})

#--------------------------------------
# Find ignition-gazebo
ign_find_package(ignition-gazebo5 REQUIRED)
set(IGN_GAZEBO_VER ${ignition-gazebo5_VERSION_MAJOR})

#--------------------------------------
# Find ignition-math
# ign_find_package(ignition-math6 REQUIRED VERSION 6.8)
# set(IGN_MATH_VER ${ignition-math6_VERSION_MAJOR})

#--------------------------------------
# Find ignition-msgs
# ign_find_package(ignition-msgs7 REQUIRED VERSION 7.1)
# set(IGN_MSGS_VER ${ignition-msgs7_VERSION_MAJOR})

#--------------------------------------
# Find ignition-physics
# ign_find_package(ignition-physics4 REQUIRED)
# set(IGN_PHYSICS_VER ${ignition-physics4_VERSION_MAJOR})

#--------------------------------------
# Find ignition-plugin
# ign_find_package(ignition-plugin1 REQUIRED)
# set(IGN_PLUGIN_VER ${ignition-plugin1_VERSION_MAJOR})

#--------------------------------------
# Find ignition-sensors
# ign_find_package(ignition-sensors5 REQUIRED)
# set(IGN_SENSORS_VER ${ignition-sensors5_VERSION_MAJOR})

#--------------------------------------
# Find RapidJSON
find_package(RapidJSON REQUIRED)

#======================================
# Find Qt
# find_package(Qt5 REQUIRED COMPONENTS
# Core
# Gui
# Qml
# Quick
# QuickControls2
# Widgets
# )

add_library(ArduPilotPlugin
SHARED
src/ArduPilotPlugin.cc
src/Socket.cpp
)

target_include_directories(ArduPilotPlugin PUBLIC
# ${PROJECT_SOURCE_DIR}
include
# ${SDFORMAT-INCLUDE_DIRS}
# ${IGNITION-COMMON_INCLUDE_DIRS}
${IGNITION-GAZEBO_INCLUDE_DIRS}
# ${IGNITION-MATH_INCLUDE_DIRS}
# ${IGNITION-MSGS_INCLUDE_DIRS}
# ${IGNITION-PHYSICS_INCLUDE_DIRS}
# ${IGNITION-SENSORS_INCLUDE_DIRS}
# ${IGNITION-TRANSPORT_INCLUDE_DIRS}
# ${RAPIDJSON_INCLUDE_DIRS}
)

target_link_libraries(ArduPilotPlugin PUBLIC
# ${SDFORMAT-LIBRARIES}
# ${IGNITION-COMMON_LIBRARIES}
${IGNITION-GAZEBO_LIBRARIES}
# ${IGNITION-MATH_LIBRARIES}
# ${IGNITION-MSGS_LIBRARIES}
# ${IGNITION-PHYSICS_LIBRARIES}
# ${IGNITION-SENSORS_LIBRARIES}
# ${IGNITION-TRANSPORT_LIBRARIES}
# Qt5::Core
# Qt5::Gui
# Qt5::Qml
# Qt5::Quick
)
56 changes: 56 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Install

## Ubtunu 18.04

Gazebo11 is required.

```bash
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install libgazebo11
$ sudo apt-get install libgazebo11-dev
$ sudo apt-get install gazebo11
```

If you are seeing errors like:

```bash
$ gazebo --verbose
Gazebo multi-robot simulator, version 11.3.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org

[Msg] Waiting for master.
Gazebo multi-robot simulator, version 11.3.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org

[Msg] Waiting for master.
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 192.168.1.170
[Err] [RTShaderSystem.cc:478] Unable to find shader lib. Shader generating will fail.[Wrn] [SystemPaths.cc:459] File or path does not exist [""] [worlds/empty.world]
[Err] [Server.cc:444] Could not open file[worlds/empty.world]
[Wrn] [Server.cc:359] Falling back on worlds/empty.world
[Wrn] [SystemPaths.cc:459] File or path does not exist [""] [worlds/empty.world]
[Err] [Server.cc:444] Could not open file[worlds/empty.world]
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 192.168.1.170
[Err] [RTShaderSystem.cc:478] Unable to find shader lib. Shader generating will fail.
```

You may need to update your `~/.bashrc`:

```bash
# Gazebo
- source /usr/share/gazebo-9/setup.sh
+ source /usr/share/gazebo-11/setup.sh
```

RapidJSON is required:

```
$ sudo apt-get update
$ sudo apt-get install rapidjson-dev
```
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ sudo apt-get install libgazeboX-dev
````

````
git clone https://github.com/khancyr/ardupilot_gazebo
git clone https://github.com/ArduPilot/ardupilot_gazebo
cd ardupilot_gazebo
mkdir build
cd build
Expand Down
Loading