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

Is there any way to contorl the gimbal in x500_gimbal #55

Open
brunocentanaro opened this issue Sep 14, 2024 · 4 comments
Open

Is there any way to contorl the gimbal in x500_gimbal #55

brunocentanaro opened this issue Sep 14, 2024 · 4 comments

Comments

@brunocentanaro
Copy link

Hello, I could add x500_gimbal and now seeking help on how to move the gimbal for my needs. I noticed at the end of the file the plugins with the sub-topics for the joints but running gz topic -l I could not find these.

Thanks in advance!

@hamishwillee
Copy link

Perhaps @StefanoColli or @Jaeyoung-Lim can answer your question. Looking at the equivalent PX4 PR PX4/PX4-Autopilot#23382 I'd guess it isn't quite ready for use.

@brunocentanaro
Copy link
Author

Actually I actually kind of got it working with that PR! This are the steps I followed:

  • I applied that pr as a patch for my px4 installation
  • I made the following changes in input_mavlink.cpp
-	if (set_attitude.origin_sysid == control_data.sysid_primary_control &&
-	    set_attitude.origin_compid == control_data.compid_primary_control) {
+	if (true) {
  • and then running
import asyncio
from mavsdk import System

drone = System()

DELAY_FOR_CORRECTING_GIMBAL = 0.3

async def manual_control_drone(my_drone):
    while True:
        await asyncio.sleep(DELAY_FOR_CORRECTING_GIMBAL)
        async for attitude in drone.telemetry.attitude_euler():
            roll = attitude.roll_deg
            pitch = attitude.pitch_deg
            await my_drone.gimbal.set_angles(-roll, -pitch, -180)

async def run_drone():
    await drone.connect(system_address="udp://:14540")
    async for state in drone.core.connection_state():
        if state.is_connected:
            print(f"-- Connected to drone!")
            break
    # Checking if Global Position Estimate is ok
    async for health in drone.telemetry.health():
        if health.is_global_position_ok and health.is_home_position_ok:
            print("-- Global position state is good enough for flying.")
            break
    asyncio.ensure_future(manual_control_drone(drone))


async def run():
    await asyncio.gather(run_drone())

def main():
    asyncio.ensure_future(run())
    asyncio.get_event_loop().run_forever()

I got my gimbal stabilized. I could not have it working with ros topics/messages unfortunately so I don't think I can change the behaviour for the gimbal programatically but for my use case this is mostly fine.

@DronecodeBot
Copy link

This issue has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/how-to-control-the-gimbal-with-ros2-in-gazebo/40727/3

@StefanoColli
Copy link
Contributor

Yes, as @hamishwillee mentioned you will be able to control the x500_gimbal only once this PR gets merged into PX4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants