srmainwaring / ros_gz_rover

An example demonstrating how to use the ROS2 - Gazebo bridge for a skid-steer rover controlled by ArduPilot
Apache License 2.0
16 stars 1 forks source link

Getting weird frame errors when trying to run this simulation #6

Closed ConnorDTaylor closed 1 year ago

ConnorDTaylor commented 1 year ago

Hi Rhys,

I am now trying to learn the interactions between Ardupilot, Gazebo, and ROS2. To do this I figured this package was a good place to start. When I try to run ros2 launch ros_gz_rover rover.launch.py I get an output saying: [rviz2-5] Warning: Invalid frame ID "rear_right_wheel_link" passed to canTransform argument source_frame - frame does not exist [rviz2-5] at line 93 in ./src/buffer_core.cpp [rviz2-5] Warning: Invalid frame ID "front_left_wheel_link" passed to canTransform argument source_frame - frame does not exist [rviz2-5] at line 93 in ./src/buffer_core.cpp

Then when I run ros2 launch ros_gz_rover mavros.launch.py I get these messages: [mavros_node-1] at line 229 in /home/connor/colcon_ws/src/mavros/libmavconn/src/udp.cpp [mavros_node-1] Error: mavconn: udp0: send: channel closed!

When I run the sim_vehicle.py command for the ArudPilot I get the message No JSON sensor message received, resending message

Finally when running the gz sim command I get this message over and over: [GUI] [Dbg] [Gui.cc:340] GUI requesting list of world names. The server may be busy downloading resources. Please be patient.

Sorry for bothering you once again!

srmainwaring commented 1 year ago

@ConnorDTaylor, as the readme says this is quite an advanced example and assumes that you have the dependencies up and running. Are the following working?

Some of the issues you are seeing (udp connections, ArduPilot not receiving JSON messages, etc.) may be resolved by working through the list. If you have tested all of the above we can start investigating what might be up with the rover example which usually starts with trying to bring up the components separately.

ConnorDTaylor commented 1 year ago

So I am going back through thse steps and forgot I was using the caguero/humble_garden branch of ros_gz and the ros2 branch of mavros instead of the ones you list in your instructions. The reason I did this is that I get build errors using the ones in the instructions. From the Mavros provided in the instructions I get these errors:

--- stderr: libmavconn
In file included from /home/connor/colcon_ws/src/mavros/libmavconn/include/mavconn/serial.hpp:22, from /home/connor/colcon_ws/src/mavros/libmavconn/src/serial.cpp:23: /home/connor/colcon_ws/src/mavros/libmavconn/include/mavconn/interface.hpp:51:10: error: #include expects "FILENAME" or 51 | #include | ^ In file included from /home/connor/colcon_ws/src/mavros/libmavconn/src/interface.cpp:19: /home/connor/colcon_ws/src/mavros/libmavconn/include/mavconn/interface.hpp:51:10: error: #include expects "FILENAME" or 51 | #include | ^ /home/connor/colcon_ws/src/mavros/libmavconn/include/mavconn/interface.hpp:52:10: error: #include expects "FILENAME" or 52 | #include | ^ /home/connor/colcon_ws/src/mavros/libmavconn/include/mavconn/interface.hpp:52:10: error: #include expects "FILENAME" or 52 | #include | ^ In file included from /home/connor/colcon_ws/src/mavros/libmavconn/include/mavconn/tcp.hpp:22, from /home/connor/colcon_ws/src/mavros/libmavconn/src/tcp.cpp:19: /home/connor/colcon_ws/src/mavros/libmavconn/include/mavconn/interface.hpp:51:10: error: #include expects "FILENAME" or 51 | #include | ^ /home/connor/colcon_ws/src/mavros/libmavconn/include/mavconn/interface.hpp:52:10: error: #include expects "FILENAME" or 52 | #include | ^ In file included from /home/connor/colcon_ws/build/libmavconn/generated/src/mavlink_helpers.cpp:24: /home/connor/colcon_ws/src/mavros/libmavconn/include/mavconn/interface.hpp:51:10: error: #include expects "FILENAME" or 51 | #include | ^ /home/connor/colcon_ws/src/mavros/libmavconn/include/mavconn/interface.hpp:52:10: error: #include expects "FILENAME" or 52 | #include | ^ In file included from /home/connor/colcon_ws/src/mavros/libmavconn/include/mavconn/udp.hpp:22, from /home/connor/colcon_ws/src/mavros/libmavconn/src/udp.cpp:20: /home/connor/colcon_ws/src/mavros/libmavconn/include/mavconn/interface.hpp:51:10: error: #include expects "FILENAME" or 51 | #include | ^ /home/connor/colcon_ws/src/mavros/libmavconn/include/mavconn/interface.hpp:52:10: error: #include expects "FILENAME" or 52 | #include

From the ros_gz from your instructions I get these errors:

/home/connor/colcon_ws/src/ros_gz/ros_gz_bridge/src/service_factories/ros_gz_interfaces.cpp: In function ‘std::shared_ptr ros_gz_bridge::get_service_factory__ros_gz_interfaces(const string&, const string&, const string&)’: /home/connor/colcon_ws/src/ros_gz/ros_gz_bridge/src/service_factories/ros_gz_interfaces.cpp:44:25: error: ‘Boolean’ is not a member of ‘gz::msgs’ 44 | ignition::msgs::Boolean> | ^~~ /home/connor/colcon_ws/src/ros_gz/ros_gz_bridge/src/service_factories/ros_gz_interfaces.cpp:44:32: error: template argument 3 is invalid 44 | ignition::msgs::Boolean> | ^ /home/connor/colcon_ws/src/ros_gz/ros_gz_bridge/src/service_factories/ros_gz_interfaces.cpp:45:6: error: no matching function for call to ‘make_shared< >(const string&, const char [27], const char [22])’ 40 | return std::make_shared< | ~~~~~ 41 | ServiceFactory< | ~~~ 42 | ros_gz_interfaces::srv::ControlWorld, | ~~~~~~~~~ 43 | ignition::msgs::WorldControl, | ~~~~~~~~~ 44 | ignition::msgs::Boolean> | ~~~~~~~~ 45 | >(ros_type_name, "ignition.msgs.WorldControl", "ignition.msgs.Boolean"); | ~^~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/memory:77, from /home/connor/colcon_ws/src/ros_gz/ros_gz_bridge/src/factories/ros_gz_interfaces.hpp:18, from /home/connor/colcon_ws/src/ros_gz/ros_gz_bridge/src/service_factories/ros_gz_interfaces.cpp:15: /usr/include/c++/11/bits/shared_ptr.h:875:5: note: candidate: ‘template<class _Tp, class ... _Args> std::shared_ptr<_Tp> std::make_shared(_Args&& ...)’ 875 | make_shared(_Args&&... __args) | ^~~ /usr/include/c++/11/bits/shared_ptr.h:875:5: note: template argument deduction/substitution failed: /home/connor/colcon_ws/src/ros_gz/ros_gz_bridge/src/service_factories/ros_gz_interfaces.cpp:45:6: error: template argument 1 is invalid 40 | return std::make_shared< | ~~~~~ 41 | ServiceFactory< | ~~~ 42 | ros_gz_interfaces::srv::ControlWorld, | ~~~~~~~~~ 43 | ignition::msgs::WorldControl, | ~~~~~~~~~ 44 | ignition::msgs::Boolean> | ~~~~~~~~ 45 | >(ros_type_name, "ignition.msgs.WorldControl", "ignition.msgs.Boolean"); | ~^~~~~~~~~~~~~~~~~~ /home/connor/colcon_ws/src/ros_gz/ros_gz_bridge/src/service_factories/ros_gz_interfaces.cpp: At global scope: /home/connor/colcon_ws/src/ros_gz/ros_gz_bridge/src/service_factories/ros_gz_interfaces.cpp:63:25: error: ‘Boolean’ in namespace ‘gz::msgs’ does not name a type 63 | const ignition::msgs::Boolean & gz_rep, | ^~~ /home/connor/colcon_ws/src/ros_gz/ros_gz_bridge/src/service_factories/ros_gz_interfaces.cpp: In function ‘void ros_gz_bridge::convert_gz_to_ros(const GZ_T&, ROS_T&) [with ROS_T = ros_gz_interfaces::srv::ControlWorldResponse<std::allocator >; GZ_T = int]’: /home/connor/colcon_ws/src/ros_gz/ros_gz_bridge/src/service_factories/ros_gz_interfaces.cpp:66:28: error: request for member ‘data’ in ‘gz_rep’, which is of non-class type ‘const int’ 66 | ros_res.success = gz_rep.data(); | ^~~~ gmake[2]: [CMakeFiles/ros_gz_bridge_lib.dir/build.make:104: CMakeFiles/ros_gz_bridge_lib.dir/src/service_factories/ros_gz_interfaces.cpp.o] Error 1 gmake[1]: [CMakeFiles/Makefile2:462: CMakeFiles/ros_gz_bridge_lib.dir/all] Error 2 gmake: *** [Makefile:146: all] Error 2

When using the two mavros and ros_gz branches I was using previously I can build my workspace. I figure using the different branches might be a problem listed in the first issue comment here. Since I can run ArduPilot with SITL and MAVProxy, run Ardupilot with Gazebo, and ROS2 works. Using this package (ros_gz_rover) still eludes me.

FIX FOR THIS: Hi Rhys,

I should have investigated this more before posting here but I sorted out the fix I think. For the mavros error, the fix is simply to delete lines 51 and 52 in the interface.hpp script. I also deleted the line with "else" on it as well. Now this package complies. The ros_gz package needs #include <ignition/msgs/boolean.pb.h> included in the beginning of the ros_gz_interface.cpp script.

I am not dealing with the this make error but I dont think it has anything to do with your packages.

CMake Error at CMakeLists.txt:37 (find_package): By not providing "FindGeographicLib.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "GeographicLib", but CMake did not find one.

Could not find a package configuration file provided by "GeographicLib" with any of the following names:

GeographicLibConfig.cmake
geographiclib-config.cmake

Add the installation prefix of "GeographicLib" to CMAKE_PREFIX_PATH or set "GeographicLib_DIR" to a directory containing one of the above files. If "GeographicLib" provides a separate development package or SDK, be sure it has been installed.

ConnorDTaylor commented 1 year ago

Okay after some work I have found that all of the elements seem to work however when running the ros2 launch mavros.launch.py I am still getting these errors:

[mavros_node-1] Error: mavconn: udp0: sendto: Invalid argument [mavros_node-1] at line 330 in /home/connor/colcon_ws/src/mavros/libmavconn/src/udp.cpp [mavros_node-1] Error: mavconn: udp0: receive: Operation aborted. [mavros_node-1] at line 286 in /home/connor/colcon_ws/src/mavros/libmavconn/src/udp.cpp [mavros_node-1] Error: mavconn: udp0: send: channel closed! [mavros_node-1] at line 229 in /home/connor/colcon_ws/src/mavros/libmavconn/src/udp.cpp [mavros_node-1] Error: mavconn: udp0: send: channel closed!

srmainwaring commented 1 year ago

Hi @ConnorDTaylor, I've been through updating this project for the released version of Gazebo Garden and have checked that everything runs. I cannot reproduce the connection error you are seeing. The mavros launch is fairly sparse - you could try removing the additional config and params for the sensors, but it looks like a connection issue in your environment - not something specific to this example.

I'll close due to no recent activity.