PX4 / PX4-SITL_gazebo-classic

Set of plugins, models and worlds to use with OSRF Gazebo Simulator in SITL and HITL.
http://dev.px4.io/simulation-gazebo.html
375 stars 787 forks source link

Controlling gimbals for multiple vehicles using ROS node in SITL #540

Closed Jaroan closed 4 years ago

Jaroan commented 4 years ago

I want to control the gimbal of two Typhoon H480 models in an offboard SITL setup using the topic /mavros/mount_control/command. I have understood how to implement it for a single model with help from this repo Jaeyoung-Lim/mavros_humantracking. My implementation : Gif Link For multi-UAV simulation, I tried to extend using the appropriate launch file and corresponding topics but I was not able to control the gimbals. They seemed to be unsteady as well. Video I am unable to move even one vehicle’s gimbal for a multi UAV simulation, like in the case of the single-vehicle. Any help and suggestion will be appreciated.

I tried to implement the changes given in the pull request - https://github.com/PX4/sitl_gazebo/pull/469 but I didn’t find a difference in the jitter. Is there something I’m skipping? I've also raised this issue in a Forum topic https://discuss.px4.io/t/controlling-gimbal-for-multiple-vehicles-using-ros-node-in-sitl/17415?u=jaroan :slightly_frowning_face:

GuangyaoSHI commented 2 years ago

@GuangyaoSHI I don't think reverting to an older PX4 version is a solution.

Agreed. I will check their modifications to the gimbal controller plugin and try to find out how to fix the problem.

sbosleo commented 2 years ago

Hello, video streaming won't work for

make px4_sitl gazebo_typhoon_h480

and qgroundcontrol.

Any suggestions? Thanks.

Jaeyoung-Lim commented 2 years ago

@sbosleo Please do not hijack the topic of this thread

You can post a new issue in this repository or ask questions on the public forum discuss.px4.io

BillSiriusLiu commented 2 years ago

@Jaeyoung-Lim

I am now using V1.12.1 PX4 and I notice that in the gimbal controller plugin, the camera_imu bug is fixed. But when I launch two typhoon_h480, only the gimbal of the first drone is controllable. The /uav0/mount_control command and /uav1/mout_control command are properly send, which can be observed in the rostopic. I notice that when the PX4 for uav1 is launching, it prompts a warning that bind failed, address already in use. I used the default launch file for multiple drones. So the address should be proper assigned. I am quite confused why the gimbal of uav1 is not controllable.

INFO [ekf2] starting instance 4, IMU:1 (1310996), MAG:1 (197644) INFO [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 18570 remote port 14550 INFO [ekf2] starting instance 5, IMU:2 (1311004), MAG:1 (197644) INFO [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14580 remote port 14540 INFO [mavlink] mode: Onboard, data rate: 4000 B/s on udp port 14280 remote port 14030 INFO [mavlink] mode: Gimbal, data rate: 400000 B/s on udp port 13030 remote port 13280 INFO [mavlink] mode: Onboard, data rate: 4000 B/s on udp port 14558 remote port 14530 WARN [mavlink] bind failed: Address already in use

The Address already in use is caused by this line: https://github.com/PX4/PX4-Autopilot/blob/7f76761657bafd8b955e6b559932e750c5391975/ROMFS/px4fmu_common/init.d-posix/airframes/6011_typhoon_h480.post#L4 after adding px4_instance to the ports this warning is silenced. But the gimbal still won't work. BTW, I was trying to launch two typhoon_h480 and the gimbal of one of them was not working. However, if I change the model to iris both gimbals are correct. Now I'm using the latest version of autopilot.

And I found in px4-rc.mavlink there are two default gimbal ports udp_onboard_gimbal_port_local=$((13030+px4_instance)) \n udp_onboard_gimbal_port_remote=$((13280+px4_instance)) which are not mentioned in the launch file. And in https://github.com/PX4/PX4-SITL_gazebo/blob/5610c3fb441a2f3babc8ad7a63c8c4ce3e40abfa/src/gazebo_gimbal_controller_plugin.cpp#L751 it seems 13030 is the only port mentioned, so I added an editable port argument both in the launch file and typhoon_h480.sdf.jinja and set them to 13030 and 13031, and now both gimbals fails. LOL Does this have anything to do with this issue?

aluminium8 commented 1 year ago

gazebo_gimbal_controller_plugin.cpp needs the arg "udp_gimbal_port_remote"( https://github.com/PX4/PX4-SITL_gazebo-classic/blob/e3722bf9132567e8dd08b7ed6df2986e21a6ec18/src/gazebo_gimbal_controller_plugin.cpp#L360-L365. but typhoon_h480.sdf don't have it.

<udp_gimbal_port_remote>13031</udp_gimbal_port_remote> under <plugin name='gimbal_controller' filename='libgazebo_gimbal_controller_plugin.so'> in typhoon_h480_1.sdf, I think I need to write

ParamDeshpande commented 1 year ago

@aluminium8 thanks for the update, this worked for me, I'm using PX4 version v1.13.3 I made the changes to the .sdf file and to the .sdf.jinja file with

<udp_gimbal_port_remote>{{ udp_onboard_gimbal_port_remote }}</udp_gimbal_port_remote>

to typhoon_h480.sdf.jinja

    <plugin name='gimbal_controller' filename='libgazebo_gimbal_controller_plugin.so'>
      <udp_gimbal_port_remote>{{ udp_onboard_gimbal_port_remote }}</udp_gimbal_port_remote>
      <joint_yaw>typhoon_h480::cgo3_vertical_arm_joint</joint_yaw>
      <joint_roll>typhoon_h480::cgo3_horizontal_arm_joint</joint_roll>
      <joint_pitch>typhoon_h480::cgo3_camera_joint</joint_pitch>

I tested changes by also adding this to a separate .sdf file ( eg typhoon_h480_1.sdf ) changed the respective ports and this worked. ` 13031 `

after this i was able to control a gimbal for an arbitary ID, on px4 sitl, I launched all nodes separately and was controlling this without mavros on px4> shell

px4>  gimbal test yaw 10

Just updating this SITL_gazebo-classic repo didn't help, I also needed to make this change to individually control gimbals.

@Jaeyoung-Lim I had tried using human tracking repo but was unable to control gimbals individually using mavros, only one was responsive. I am yet to try if they are stable / responsive after adding the above changes As @aluminium8 pointed out in this issue both the models also went haywire.

shupx commented 1 year ago

@ParamDeshpande Thanks for your sharing. Your method applys for the latest PX4 v1.14 but not for v1.13.3.

Because the gazebo_gimbal_controller_plugin used by PX4 v1.13.3 does not have a udp_gimbal_port_remote element. Instead, it used a fixed udp port 13030. The udp_gimbal_port_remote element is added by the commit cc8f33d for "gazebo_gimbal_controller_plugin.cpp", which is adpoted by the gazebo simulation part of PX4 v1.14

Similar issue discussion: https://github.com/PX4/PX4-SITL_gazebo-classic/issues/940