Intelligent-Quads / iq_tutorials

MIT License
460 stars 252 forks source link

"roslaunch iq_sim apm.launch" fails on Ubuntu 20.04 + ros-noetic + gazebo11 + catkin_make_isolated: #14

Open AJRepo opened 3 years ago

AJRepo commented 3 years ago

Description:

I've been re-doing the setup of a new, virtual (qemu/KVM) machine a few times to try to get a script that creates a good, stable image with ros-noetic, gazebo11 and Ubuntu 20.

The step "Install ROS and Setup Catkin" seemed to go fine with no errors although with the package install of catkin there is no command "catkin" but instead only "catkin_make_isolated" and "catkin_make"

The next step gets into an infinite restart loop with roslaunch iq_sim apm.launch

Example:

$ roslaunch iq_sim apm.launch
... logging to /REDACTED/.ros/log/8053100a-2f2d-11eb-9030-43a91962291d/roslaunch-gaz1-2230.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://gaz1:36233/

SUMMARY
========

CLEAR PARAMETERS
 * /mavros/

PARAMETERS
 * /mavros/cmd/use_comp_id_system_control: False
 * /mavros/conn/heartbeat_mav_type: ONBOARD_CONTROLLER
 * /mavros/conn/heartbeat_rate: 1.0
 * /mavros/conn/system_time_rate: 1.0
 * /mavros/conn/timeout: 10.0
 * /mavros/conn/timesync_rate: 10.0
 * /mavros/distance_sensor/rangefinder_pub/field_of_view: 0.0
 * /mavros/distance_sensor/rangefinder_pub/frame_id: lidar
 * /mavros/distance_sensor/rangefinder_pub/id: 0
 * /mavros/distance_sensor/rangefinder_pub/send_tf: False
 * /mavros/distance_sensor/rangefinder_pub/sensor_position/x: 0.0
 * /mavros/distance_sensor/rangefinder_pub/sensor_position/y: 0.0
 * /mavros/distance_sensor/rangefinder_pub/sensor_position/z: -0.1
 * /mavros/distance_sensor/rangefinder_sub/id: 1
 * /mavros/distance_sensor/rangefinder_sub/orientation: PITCH_270
 * /mavros/distance_sensor/rangefinder_sub/subscriber: True
 * /mavros/fake_gps/eph: 2.0
 * /mavros/fake_gps/epv: 2.0
 * /mavros/fake_gps/fix_type: 3
 * /mavros/fake_gps/geo_origin/alt: 408.0
 * /mavros/fake_gps/geo_origin/lat: 47.3667
 * /mavros/fake_gps/geo_origin/lon: 8.55
 * /mavros/fake_gps/gps_id: 4
 * /mavros/fake_gps/gps_rate: 5.0
 * /mavros/fake_gps/horiz_accuracy: 0.5
 * /mavros/fake_gps/mocap_transform: False
 * /mavros/fake_gps/mocap_withcovariance: False
 * /mavros/fake_gps/satellites_visible: 6
 * /mavros/fake_gps/speed_accuracy: 0.0
 * /mavros/fake_gps/tf/child_frame_id: fix
 * /mavros/fake_gps/tf/frame_id: map
 * /mavros/fake_gps/tf/listen: False
 * /mavros/fake_gps/tf/rate_limit: 10.0
 * /mavros/fake_gps/tf/send: False
 * /mavros/fake_gps/use_hil_gps: True
 * /mavros/fake_gps/use_mocap: True
 * /mavros/fake_gps/use_vision: False
 * /mavros/fake_gps/vert_accuracy: 0.5
 * /mavros/fcu_protocol: v2.0
 * /mavros/fcu_url: udp://127.0.0.1:1...
 * /mavros/gcs_url: 
 * /mavros/global_position/child_frame_id: base_link
 * /mavros/global_position/frame_id: map
 * /mavros/global_position/gps_uere: 1.0
 * /mavros/global_position/rot_covariance: 99999.0
 * /mavros/global_position/tf/child_frame_id: base_link
 * /mavros/global_position/tf/frame_id: map
 * /mavros/global_position/tf/global_frame_id: earth
 * /mavros/global_position/tf/send: False
 * /mavros/global_position/use_relative_alt: True
 * /mavros/image/frame_id: px4flow
 * /mavros/imu/angular_velocity_stdev: 0.0003490659 // 0...
 * /mavros/imu/frame_id: base_link
 * /mavros/imu/linear_acceleration_stdev: 0.0003
 * /mavros/imu/magnetic_stdev: 0.0
 * /mavros/imu/orientation_stdev: 1.0
 * /mavros/landing_target/camera/fov_x: 2.0071286398
 * /mavros/landing_target/camera/fov_y: 2.0071286398
 * /mavros/landing_target/image/height: 480
 * /mavros/landing_target/image/width: 640
 * /mavros/landing_target/land_target_type: VISION_FIDUCIAL
 * /mavros/landing_target/listen_lt: False
 * /mavros/landing_target/mav_frame: LOCAL_NED
 * /mavros/landing_target/target_size/x: 0.3
 * /mavros/landing_target/target_size/y: 0.3
 * /mavros/landing_target/tf/child_frame_id: camera_center
 * /mavros/landing_target/tf/frame_id: landing_target
 * /mavros/landing_target/tf/listen: False
 * /mavros/landing_target/tf/rate_limit: 10.0
 * /mavros/landing_target/tf/send: True
 * /mavros/local_position/frame_id: map
 * /mavros/local_position/tf/child_frame_id: base_link
 * /mavros/local_position/tf/frame_id: map
 * /mavros/local_position/tf/send: False
 * /mavros/local_position/tf/send_fcu: False
 * /mavros/mission/pull_after_gcs: True
 * /mavros/mission/use_mission_item_int: True
 * /mavros/mocap/use_pose: True
 * /mavros/mocap/use_tf: False
 * /mavros/odometry/estimator_type: 3
 * /mavros/odometry/frame_tf/desired_frame: ned
 * /mavros/plugin_blacklist: ['actuator_contro...
 * /mavros/plugin_whitelist: []
 * /mavros/px4flow/frame_id: px4flow
 * /mavros/px4flow/ranger_fov: 0.118682
 * /mavros/px4flow/ranger_max_range: 5.0
 * /mavros/px4flow/ranger_min_range: 0.3
 * /mavros/safety_area/p1/x: 1.0
 * /mavros/safety_area/p1/y: 1.0
 * /mavros/safety_area/p1/z: 1.0
 * /mavros/safety_area/p2/x: -1.0
 * /mavros/safety_area/p2/y: -1.0
 * /mavros/safety_area/p2/z: -1.0
 * /mavros/setpoint_accel/send_force: False
 * /mavros/setpoint_attitude/reverse_thrust: False
 * /mavros/setpoint_attitude/tf/child_frame_id: target_attitude
 * /mavros/setpoint_attitude/tf/frame_id: map
 * /mavros/setpoint_attitude/tf/listen: False
 * /mavros/setpoint_attitude/tf/rate_limit: 50.0
 * /mavros/setpoint_attitude/use_quaternion: False
 * /mavros/setpoint_position/mav_frame: LOCAL_NED
 * /mavros/setpoint_position/tf/child_frame_id: target_position
 * /mavros/setpoint_position/tf/frame_id: map
 * /mavros/setpoint_position/tf/listen: False
 * /mavros/setpoint_position/tf/rate_limit: 50.0
 * /mavros/setpoint_raw/thrust_scaling: 1.0
 * /mavros/setpoint_velocity/mav_frame: LOCAL_NED
 * /mavros/startup_px4_usb_quirk: False
 * /mavros/sys/disable_diag: False
 * /mavros/sys/min_voltage: 10.0
 * /mavros/target_component_id: 1
 * /mavros/target_system_id: 1
 * /mavros/tdr_radio/low_rssi: 40
 * /mavros/time/time_ref_source: fcu
 * /mavros/time/timesync_avg_alpha: 0.6
 * /mavros/time/timesync_mode: MAVLINK
 * /mavros/vibration/frame_id: base_link
 * /mavros/vision_pose/tf/child_frame_id: vision_estimate
 * /mavros/vision_pose/tf/frame_id: map
 * /mavros/vision_pose/tf/listen: False
 * /mavros/vision_pose/tf/rate_limit: 10.0
 * /mavros/vision_speed/listen_twist: True
 * /mavros/vision_speed/twist_cov: True
 * /mavros/wheel_odometry/child_frame_id: base_link
 * /mavros/wheel_odometry/count: 2
 * /mavros/wheel_odometry/frame_id: map
 * /mavros/wheel_odometry/send_raw: True
 * /mavros/wheel_odometry/send_twist: False
 * /mavros/wheel_odometry/tf/child_frame_id: base_link
 * /mavros/wheel_odometry/tf/frame_id: map
 * /mavros/wheel_odometry/tf/send: True
 * /mavros/wheel_odometry/use_rpm: False
 * /mavros/wheel_odometry/vel_error: 0.1
 * /mavros/wheel_odometry/wheel0/radius: 0.05
 * /mavros/wheel_odometry/wheel0/x: 0.0
 * /mavros/wheel_odometry/wheel0/y: -0.15
 * /mavros/wheel_odometry/wheel1/radius: 0.05
 * /mavros/wheel_odometry/wheel1/x: 0.0
 * /mavros/wheel_odometry/wheel1/y: 0.15
 * /rosdistro: noetic
 * /rosversion: 1.15.8

NODES
  /
    mavros (mavros/mavros_node)

auto-starting new master
process[master]: started with pid [2260]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 8053100a-2f2d-11eb-9030-43a91962291d
process[rosout-1]: started with pid [2270]
started core service [/rosout]
process[mavros-2]: started with pid [2274]
[ INFO] [1606315804.818512608]: FCU URL: udp://127.0.0.1:14551@14555
[ INFO] [1606315804.821153129]: udp0: Bind address: 127.0.0.1:14551
[ INFO] [1606315804.821221873]: udp0: Remote address: 0.0.56.219:14550
[ INFO] [1606315804.821436021]: GCS bridge disabled
[ INFO] [1606315804.865430235]: Plugin 3dr_radio loaded
[ INFO] [1606315804.867122847]: Plugin 3dr_radio initialized
[ INFO] [1606315804.867161089]: Plugin actuator_control blacklisted
[ INFO] [1606315804.903559323]: Plugin adsb loaded
[ INFO] [1606315804.905500093]: Plugin adsb initialized
[ INFO] [1606315804.905562280]: Plugin altitude blacklisted
[ INFO] [1606315804.905678536]: Plugin cam_imu_sync loaded
[ INFO] [1606315804.906066625]: Plugin cam_imu_sync initialized
[ INFO] [1606315804.906219487]: Plugin command loaded
[ INFO] [1606315804.915134854]: Plugin command initialized
[ INFO] [1606315804.915332321]: Plugin companion_process_status loaded
[ INFO] [1606315804.916726793]: Plugin companion_process_status initialized
[ INFO] [1606315804.916785327]: Plugin debug_value blacklisted
[ INFO] [1606315804.916901448]: Plugin distance_sensor loaded
[ INFO] [1606315804.921521716]: Plugin distance_sensor initialized
[ INFO] [1606315804.921672775]: Plugin esc_status loaded
[ INFO] [1606315804.922504168]: Plugin esc_status initialized
[ INFO] [1606315804.922672215]: Plugin fake_gps loaded
[ INFO] [1606315804.931661822]: Plugin fake_gps initialized
[ INFO] [1606315804.931684973]: Plugin ftp blacklisted
[ INFO] [1606315804.931772357]: Plugin global_position loaded
[ INFO] [1606315804.944525862]: Plugin global_position initialized
[ INFO] [1606315804.944687367]: Plugin gps_rtk loaded
[ INFO] [1606315804.946301271]: Plugin gps_rtk initialized
[ INFO] [1606315804.946396263]: Plugin gps_status loaded
[ INFO] [1606315804.947713174]: Plugin gps_status initialized
[ INFO] [1606315804.947734749]: Plugin hil blacklisted
[ INFO] [1606315804.947815822]: Plugin home_position loaded
[ INFO] [1606315804.949720982]: Plugin home_position initialized
[ INFO] [1606315804.949862136]: Plugin imu loaded
[ INFO] [1606315804.953833583]: Plugin imu initialized
[ INFO] [1606315804.953938152]: Plugin landing_target loaded
[ INFO] [1606315804.960820755]: Plugin landing_target initialized
[ INFO] [1606315804.960911878]: Plugin local_position loaded
[ INFO] [1606315804.964274491]: Plugin local_position initialized
[ INFO] [1606315804.964371572]: Plugin log_transfer loaded
[ INFO] [1606315804.966123323]: Plugin log_transfer initialized
[ INFO] [1606315804.966220083]: Plugin manual_control loaded
[ INFO] [1606315804.967703598]: Plugin manual_control initialized
[ INFO] [1606315804.967801946]: Plugin mocap_pose_estimate loaded
[ INFO] [1606315804.969557616]: Plugin mocap_pose_estimate initialized
[ INFO] [1606315804.969647556]: Plugin mount_control loaded
[ INFO] [1606315804.971804758]: Plugin mount_control initialized
[ INFO] [1606315804.971907528]: Plugin obstacle_distance loaded
[ INFO] [1606315804.975674566]: Plugin obstacle_distance initialized
[ INFO] [1606315804.975832552]: Plugin odom loaded
[ INFO] [1606315804.977838800]: Plugin odom initialized
[ INFO] [1606315804.977938101]: Plugin onboard_computer_status loaded
[ INFO] [1606315804.979218727]: Plugin onboard_computer_status initialized
[ INFO] [1606315804.979349234]: Plugin param loaded
[ INFO] [1606315804.981109107]: Plugin param initialized
[ INFO] [1606315804.981203290]: Plugin play_tune loaded
[ INFO] [1606315804.982404788]: Plugin play_tune initialized
[ INFO] [1606315804.982428032]: Plugin px4flow blacklisted
[ INFO] [1606315804.982517283]: Plugin rangefinder loaded
[ INFO] [1606315804.982912024]: Plugin rangefinder initialized
[ INFO] [1606315804.983045493]: Plugin rc_io loaded
[ INFO] [1606315804.984978944]: Plugin rc_io initialized
[ INFO] [1606315804.985004453]: Plugin safety_area blacklisted
[ INFO] [1606315804.985094465]: Plugin setpoint_accel loaded
[ INFO] [1606315804.986677320]: Plugin setpoint_accel initialized
[ INFO] [1606315804.987108033]: Plugin setpoint_attitude loaded
[ INFO] [1606315804.997413644]: Plugin setpoint_attitude initialized
[ INFO] [1606315804.997582246]: Plugin setpoint_position loaded
[ INFO] [1606315805.012151960]: Plugin setpoint_position initialized
[ INFO] [1606315805.012388278]: Plugin setpoint_raw loaded
[ INFO] [1606315805.017358015]: Plugin setpoint_raw initialized
[ INFO] [1606315805.017525457]: Plugin setpoint_trajectory loaded
[ INFO] [1606315805.020498421]: Plugin setpoint_trajectory initialized
[ INFO] [1606315805.020658383]: Plugin setpoint_velocity loaded
[ INFO] [1606315805.023883537]: Plugin setpoint_velocity initialized
[ INFO] [1606315805.024108981]: Plugin sys_status loaded
[ INFO] [1606315805.032483696]: Plugin sys_status initialized
[ INFO] [1606315805.032693428]: Plugin sys_time loaded
[ INFO] [1606315805.035563705]: TM: Timesync mode: MAVLINK
[ INFO] [1606315805.036234799]: Plugin sys_time initialized
[ INFO] [1606315805.036439164]: Plugin trajectory loaded
[ INFO] [1606315805.042380394]: Plugin trajectory initialized
[ INFO] [1606315805.042608978]: Plugin vfr_hud loaded
[ INFO] [1606315805.045502833]: Plugin vfr_hud initialized
[ INFO] [1606315805.045578838]: Plugin vibration blacklisted
[ INFO] [1606315805.045705418]: Plugin vision_pose_estimate loaded
[ INFO] [1606315805.050093070]: Plugin vision_pose_estimate initialized
[ INFO] [1606315805.050177689]: Plugin vision_speed_estimate blacklisted
[ INFO] [1606315805.050296292]: Plugin waypoint loaded
[ INFO] [1606315805.053834972]: Plugin waypoint initialized
[ INFO] [1606315805.053906141]: Plugin wheel_odometry blacklisted
[ INFO] [1606315805.054006077]: Plugin wind_estimation loaded
[ INFO] [1606315805.054581538]: Plugin wind_estimation initialized
[ INFO] [1606315805.054685559]: Built-in SIMD instructions: SSE, SSE2
[ INFO] [1606315805.054736808]: Built-in MAVLink package version: 2020.9.10
[ INFO] [1606315805.054784595]: Known MAVLink dialects: common ardupilotmega ASLUAV all autoquad icarous matrixpilot paparazzi standard uAvionix ualberta
[ INFO] [1606315805.054889279]: MAVROS started. MY ID 1.240, TARGET ID 1.1
[ERROR] [1606315805.137677829]: udp0: sendto: Invalid argument
terminate called after throwing an instance of 'std::system_error'
  what():  Resource deadlock avoided
[mavros-2] process has died [pid 2274, exit code -6, cmd /REDACTED/Documents/Software/Drone/catkin_ws/devel_isolated/mavros/lib/mavros/mavros_node __name:=mavros __log:=/REDACTED/.ros/log/8
053100a-2f2d-11eb-9030-43a91962291d/mavros-2.log].
log file: /REDACTED/.ros/log/8053100a-2f2d-11eb-9030-43a91962291d/mavros-2*.log
[mavros-2] restarting process
process[mavros-2]: started with pid [2293]

The program then is in an infinite loop continually getting the udp0 error and then "restarting process"

The error is udp0: sendto: Invalid argument and the URL is obviously bonkers

[ INFO] [1606315804.821221873]: udp0: Remote address: 0.0.56.219:14550

So I looked at changing the apm.launch line that specifies the fcu_url:

<arg name="fcu_url" default="udp://127.0.0.1:14551@14555" />

Results:

I can get roslaunch to start without the udp0 error with these values:

<arg name="fcu_url" default="udp://:14551@14555" />

which gives

[ INFO] [1606316193.264590075]: FCU URL: udp://:14551@:14555
[ INFO] [1606316193.267459718]: udp0: Bind address: 0.0.0.0:14551
[ INFO] [1606316193.267766317]: GCS bridge disabled

note there is no udp0 remote address reported.

or

<arg name="fcu_url" default="udp://127.0.0.1:14551@127.0.0.1:14555" />

which gives

[ INFO] [1606316413.589693112]: FCU URL: udp://127.0.0.1:14551@127.0.0.1:14555
[ INFO] [1606316413.592424358]: udp0: Bind address: 127.0.0.1:14551
[ INFO] [1606316413.592512702]: udp0: Remote address: 127.0.0.1:14555
[ INFO] [1606316413.592789264]: GCS bridge disabled

(note there is a udp0 remote address line)

or

<arg name="fcu_url" default="udp://127.0.0.1:14551@:14555" />

which gives

[ INFO] [1606316558.272979009]: FCU URL: udp://127.0.0.1:14551@:14555
[ INFO] [1606316558.275885652]: udp0: Bind address: 127.0.0.1:14551
[ INFO] [1606316558.276202900]: GCS bridge disabled

(note there is again no remote address line).

I suspect the core issue is probably the newer code requires a ":" in the remote address field for specifying the port.

In all 3 cases, the GUI for gazebo does not start.

Since I'm new to gazebo/ros and also not working with Gazebo9 or ros-melodic any more I didn't want to submit any of those changes as a patch as I don't know enough to know if it is is backwards compatible or if perhaps there is something else I've done wrong.

zdanek commented 3 years ago

I have the same problem. It hangs forever at [ INFO] [1614020735.714864508]: MAVROS started. MY ID 1.240, TARGET ID 1.1

Same is when Ardupilot SITL is run and when it's not. It seems like mavros is somehow waiting to connect to the SITL but it never happens.

Any clues?

aaryanmurgunde commented 2 years ago

@AJRepo This issue is dude to some error with the mavros try reinstalling it by following the guidelines

wildangunawan commented 2 years ago

I have this issue as well. Thank to @AJRepo, I managed to launch MAVROS successfully. I'm following how PX4 launches MAVROS (only the format), you can look at here.

@AJRepo did say that apm.launch didn't start Gazebo which is correct. This is due to the launch file itself doesn't start the Gazebo (refer to how runway.launch does start Gazebo).

In case we want MAVROS and Gazebo to start, we can use this:

<launch>
    <!-- vim: set ft=xml noet : -->
    <!-- Experimental launch script for APM based Drone -->

    <!-- FCU URL format stolen from PX4's launch file -->
    <!-- https://github.com/PX4/PX4-Autopilot/blob/master/launch/mavros_posix_sitl.launch#L25 -->
    <arg name="fcu_url" default="udp://:14551@localhost:14555" />
    <arg name="gcs_url" default="" />
    <arg name="tgt_system" default="1" />
    <arg name="tgt_component" default="1" />
    <arg name="log_output" default="screen" />
    <arg name="respawn_mavros" default="true"/>
    <arg name="mavros_ns" default="/"/>
    <arg name="config_yaml" default="$(find mavros)/launch/apm_config.yaml" />

    <include file="$(find iq_sim)/launch/mavros_node.launch">
        <arg name="pluginlists_yaml" value="$(find mavros)/launch/apm_pluginlists.yaml" />
        <arg name="config_yaml" value="$(arg config_yaml)" />
        <arg name="mavros_ns" value="$(arg mavros_ns)"/>
        <arg name="fcu_url" value="$(arg fcu_url)" />
        <arg name="gcs_url" value="$(arg gcs_url)" />
        <arg name="respawn_mavros" value="$(arg respawn_mavros)"/>
        <arg name="tgt_system" value="$(arg tgt_system)" />
        <arg name="tgt_component" value="$(arg tgt_component)" />
        <arg name="log_output" value="$(arg log_output)" />
    </include>

    <!-- Code to launch Gazebo stolen from runway.launch file -->
    <!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->
    <arg name="gui" default="true"/>
        <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="world_name" value="$(find iq_sim)/worlds/runway.world"/>
        <arg name="gui" value="$(arg gui)"/>
        <!-- more default parameters can be changed here -->
    </include>
</launch>

You can either edit directly at apm.launch or create your own launch file.

ARidwanW commented 1 year ago

That is also a problem for me. I tried the solutions you suggested, but the problem persists. When I try to change fcu to match @wildangunawan 's solution, I get something like @zdanek.

After that, I discovered this video: Ardupilot Mavros connexion

utilizing the fcu:

<arg name="fcu_url" default="tcp://localhost:5762" />

It worked for me, but when I ran square.cpp, the drone did not form a square but instead immediately rotated 180 degrees or faced back after takeoff and advanced 5 meters.

ARidwanW commented 1 year ago

then i try to debug the MAVROS node before change fcu to tcp:

gdb -ex run --args /home/arw/catkin_ws/devel/lib/mavros/mavros_node __name:=mavros then type bt

then i got this:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7405859 in __GI_abort () at abort.c:79
#2  0x00007ffff768e911 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff769a38c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff769a3f7 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff769a6a9 in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff769173f in std::__throw_system_error(int) () from /lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007ffff76c7060 in std::thread::join() () from /lib/x86_64-linux-gnu/libstdc++.so.6
#8  0x00007ffff73698eb in mavconn::MAVConnUDP::close() () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#9  0x00007ffff736a744 in mavconn::MAVConnUDP::do_sendto(bool)::{lambda(boost::system::error_code, unsigned long)#1}::operator()(boost::system::error_code, unsigned long) const () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#10 0x00007ffff736d725 in boost::asio::detail::binder2<mavconn::MAVConnUDP::do_sendto(bool)::{lambda(boost::system::error_code, unsigned long)#1}, boost::system::error_code, unsigned long>::operator()() () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#11 0x00007ffff736d404 in void boost::asio::asio_handler_invoke<boost::asio::detail::binder2<mavconn::MAVConnUDP::do_sendto(bool)::{lambda(boost::system::error_code, unsigned long)#1}, boost::system::error_code, unsigned long> >(boost::asio::detail::binder2<mavconn::MAVConnUDP::do_sendto(bool)::{lambda(boost::system::error_code, unsigned long)#1}, boost::system::error_code, unsigned long>&, ...) () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#12 0x00007ffff736d038 in void boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder2<mavconn::MAVConnUDP::do_sendto(bool)::{lambda(boost::system::error_code, unsigned long)#1}, boost::system::error_code, unsigned long>, {lambda(boost::system::error_code, unsigned long)#1}>(boost::asio::detail::binder2<mavconn::MAVConnUDP::do_sendto(bool)::{lambda(boost::system::error_code, unsigned long)#1}, boost::system::error_code, unsigned long>&, {lambda(boost::system::error_code, unsigned long)#1}&) () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#13 0x00007ffff736cda1 in void boost::asio::detail::asio_handler_invoke<boost::asio::detail::binder2<mavconn::MAVConnUDP::do_sendto(bool)::{lambda(boost::system::error_code, unsigned long)#1}, boost::system::error_code, unsigned long>, {lambda(boost::system::error_code, unsigned long)#1}, boost::system::error_code, unsigned long>(boost::asio::detail::binder2<mavconn::MAVConnUDP::do_sendto(bool)::{lambda(boost::system::error_code, unsigned long)#1}, boost::system::error_code, unsigned long>&, boost::asio::detail::binder2<{lambda(boost::system::error_code, unsigned long)#1}, boost::system::error_code, unsigned long>*) () from /home/arw/catkin_ws/devel/lib/libmavconn.so
--Type <RET> for more, q to quit, c to continue without paging--c
#14 0x00007ffff736ca45 in void boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder2<mavconn::MAVConnUDP::do_sendto(bool)::{lambda(boost::system::error_code, unsigned long)#1}, boost::system::error_code, unsigned long>, mavconn::MAVConnUDP::do_sendto(bool)::{lambda(boost::system::error_code, unsigned long)#1}>(boost::asio::detail::binder2<mavconn::MAVConnUDP::do_sendto(bool)::{lambda(boost::system::error_code, unsigned long)#1}, boost::system::error_code, unsigned long>&, mavconn::MAVConnUDP::do_sendto(bool)::{lambda(boost::system::error_code, unsigned long)#1}&) () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#15 0x00007ffff736c7d8 in void boost::asio::detail::io_object_executor<boost::asio::executor>::dispatch<boost::asio::detail::binder2<mavconn::MAVConnUDP::do_sendto(bool)::{lambda(boost::system::error_code, unsigned long)#1}, boost::system::error_code, unsigned long>, std::allocator<void> >(boost::asio::detail::binder2<mavconn::MAVConnUDP::do_sendto(bool)::{lambda(boost::system::error_code, unsigned long)#1}, boost::system::error_code, unsigned long>&&, std::allocator<void> const&) const () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#16 0x00007ffff736c5c3 in void boost::asio::detail::handler_work<mavconn::MAVConnUDP::do_sendto(bool)::{lambda(boost::system::error_code, unsigned long)#1}, boost::asio::detail::io_object_executor<boost::asio::executor>, boost::asio::executor>::complete<boost::asio::detail::binder2<{lambda(boost::system::error_code, unsigned long)#1}, boost::system::error_code, unsigned long> >(boost::asio::detail::binder2<{lambda(boost::system::error_code, unsigned long)#1}, boost::system::error_code, unsigned long>&, {lambda(boost::system::error_code, unsigned long)#1}&) () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#17 0x00007ffff736c019 in boost::asio::detail::reactive_socket_sendto_op<boost::asio::mutable_buffers_1, boost::asio::ip::basic_endpoint<boost::asio::ip::udp>, mavconn::MAVConnUDP::do_sendto(bool)::{lambda(boost::system::error_code, unsigned long)#1}, boost::asio::detail::io_object_executor<boost::asio::executor> >::do_complete(void*, boost::asio::detail::scheduler_operation*, boost::system::error_code const&, unsigned long) () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#18 0x00007ffff733cd1c in boost::asio::detail::scheduler_operation::complete(void*, boost::system::error_code const&, unsigned long) () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#19 0x00007ffff734132a in boost::asio::detail::scheduler::do_run_one(boost::asio::detail::conditionally_enabled_mutex::scoped_lock&, boost::asio::detail::scheduler_thread_info&, boost::system::error_code const&) () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#20 0x00007ffff7340d64 in boost::asio::detail::scheduler::run(boost::system::error_code&) () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#21 0x00007ffff734172a in boost::asio::io_context::run() () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#22 0x00007ffff73696a8 in mavconn::MAVConnUDP::connect(std::function<void (mavlink::__mavlink_message const*, mavconn::Framing)> const&, std::function<void ()> const&)::{lambda()#1}::operator()() const () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#23 0x00007ffff736dc2b in void std::__invoke_impl<void, mavconn::MAVConnUDP::connect(std::function<void (mavlink::__mavlink_message const*, mavconn::Framing)> const&, std::function<void ()> const&)::{lambda()#1}>(std::__invoke_other, mavconn::MAVConnUDP::connect(std::function<void (mavlink::__mavlink_message const*, mavconn::Framing)> const&, std::function<void ()> const&)::{lambda()#1}&&) () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#24 0x00007ffff736dbcc in std::__invoke_result<mavconn::MAVConnUDP::connect(std::function<void (mavlink::__mavlink_message const*, mavconn::Framing)> const&, std::function<void ()> const&)::{lambda()#1}>::type std::__invoke<mavconn::MAVConnUDP::connect(std::function<void (mavlink::__mavlink_message const*, mavconn::Framing)> const&, std::function<void ()> const&)::{lambda()#1}>(std::__invoke_result&&, (mavconn::MAVConnUDP::connect(std::function<void (mavlink::__mavlink_message const*, mavconn::Framing)> const&, std::function<void ()> const&)::{lambda()#1}&&)...) () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#25 0x00007ffff736db6a in void std::thread::_Invoker<std::tuple<mavconn::MAVConnUDP::connect(std::function<void (mavlink::__mavlink_message const*, mavconn::Framing)> const&, std::function<void ()> const&)::{lambda()#1}> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#26 0x00007ffff736db2b in std::thread::_Invoker<std::tuple<mavconn::MAVConnUDP::connect(std::function<void (mavlink::__mavlink_message const*, mavconn::Framing)> const&, std::function<void ()> const&)::{lambda()#1}> >::operator()() () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#27 0x00007ffff736db00 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<mavconn::MAVConnUDP::connect(std::function<void (mavlink::__mavlink_message const*, mavconn::Framing)> const&, std::function<void ()> const&)::{lambda()#1}> > >::_M_run() () from /home/arw/catkin_ws/devel/lib/libmavconn.so
#28 0x00007ffff76c6de4 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#29 0x00007ffff78cb609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#30 0x00007ffff7502133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
ARidwanW commented 1 year ago

Hello guys, after two weeks I found a solution to this problem! at least for me.

environments:

startsitl.sh

So when you run ~/startsitl.sh you will run sim_vehicle.py where as sim_vehicle.py will run mavproxy.py.

from there (~/startsitl.sh) you can see if mavproxy.py --out is running ip 127.0.0.1.

image

sim_vehicle.py

if it doesn't run ip 127.0.0.1, then you can change the sim_vehicle.py file (use: whereis sim_vehicle.py for the path) by commenting the following line:

for i in instances:
        if not opts.no_extra_ports:
            ports = [p + 10 * i for p in [14550, 14551]]
            for port in ports:
                if under_vagrant():
                    # We're running inside of a vagrant guest; forward our
                    # mavlink out to the containing host OS
                    cmd.extend(["--out", "10.0.2.2:" + str(port)])

                # elif wsl2_host_ip_str:
                #     # We're running WSL2; forward our
                #     # mavlink out to the containing host Windows OS
                #     cmd.extend(["--out", str(wsl2_host_ip_str) + ":" + str(port)])

                else:
                    cmd.extend(["--out", "127.0.0.1:" + str(port)])

then save the file and rerun ~/startsitl.sh and you don't need to change the ip on apm.launch. then try again roslaunch iq_sim apm.launch

I hope this can help! :)

prodrone-liu commented 1 month ago

I was also running into the same problem. Although the <arg name="fcu_url" default="udp://127.0.0.1:14551@:14555" /> did prevent me from looping the error code, I could not rostopic echo the telemetry data like what tutorial did.

By referring the @ARidwanW 's solution, I switched to <arg name="fcu_url" default="udp://:14550@localhost:14555" /> and everything works. Port 14450 is referenced according to the output of sim_vehicle.py -v ArduCopter -f gazebo-iris --console:

SIM_VEHICLE: Run MavProxy
SIM_VEHICLE: "mavproxy.py" "--out" "127.0.0.1:14550" "--master" "tcp:127.0.0.1:5760" "--sitl" "127.0.0.1:5501" "--console"

Once apm.launch is successfully launched, the FCU connection status can be seen by using command rostopic echo -n1 /diagnostics:

status: 
  - 
    level: 0
    name: "mavros: FCU connection"
    message: "connected"
    hardware_id: "udp://:14550@localhost:14555"
    values: 
      - 
        key: "Received packets:"
        value: "1016"
      - 
        key: "Dropped packets:"
        value: "0"
      - 
        key: "Buffer overruns:"
        value: "0"
      - 
        key: "Parse errors:"
        value: "0"
      - 
        key: "Rx sequence number:"
        value: "50"
      - 
        key: "Tx sequence number:"
        value: "0"
      - 
        key: "Rx total bytes:"
        value: "33148"
      - 
        key: "Tx total bytes:"
        value: "2628"
      - 
        key: "Rx speed:"
        value: "5997.000000"
      - 
        key: "Tx speed:"
        value: "500.000000"
  -