I'm utterly confused by the Gazebo/Ignition simulation programs. I'm currently using ROS2 Foxy with Ubuntu 20.04 and looking forward to controlling an UAV modeled in Gazebo via ROS2. However I'm completely lost even though there's "documentation" (which I've found it to be really mixed up between all the different versions of ROS).
What I've done so far is trying to run this script:
#include <iostream>
#include <ignition/msgs.hh>
int main()
{
ignition::msgs::Vector3d point1;
point1.set_x(1);
point1.set_y(3);
point1.set_z(5);
ignition::msgs::Vector3d point2;
point2.set_x(2);
point2.set_y(4);
point2.set_z(6);
std::cout << "Point1:\n" << point1.DebugString() << std::endl;
std::cout << "Point2:\n" << point2.DebugString() << std::endl;
return 0;
}
However I get the message that the build fails since there is no ignition directory even though I have installed it.
I'd appreciate any help in this matter since I feel I'm completely lost with installations and the CMakeLists.txt file.
Gustavo,
with this CMakeLists.txt
you can compile your code:
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
find_package(gz-cmake3 REQUIRED)
project(message-example)
gz_find_package(gz-msgs9 REQUIRED)
set(GZ_MSGS_VER ${gz-msgs9_VERSION_MAJOR})
add_executable(message-example main.cpp)
set_property(TARGET message-example PROPERTY CXX_STANDARD 17)
target_link_libraries(message-example
PRIVATE gz-msgs${GZ_MSGS_VER}::gz-msgs${GZ_MSGS_VER})
then execute
mkdir build
cd build
cmake ..
./message-example
I don't know which Gazebo version are you using but the version for gz-msgs
might be different:
You can find here some examples related with Gazebo or if you are going to use Gazebo and ROS you should review this other repository ros_gz.