nusrobomaster / PX4-Autopilot

PX4 Autopilot Software
https://px4.io
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

PWM Control as a module #21

Open thebirdgr opened 3 years ago

thebirdgr commented 3 years ago

Purpose: To write custom modules that can control PWM.

Currently I understand that there is a systemcmd to control the PWM pins. But this requires active CLI interaction. A module that can do this on a loop is desired.

What I've done so far: We've written a module called move_motor to test out out theories. We are able to subscribe to and publish topics in that module. However we're not sure how to control the PWM from inside the module.

I've tried the following: using rover_pos_control, reverse engineering the pwm or even using actuator_control. I still can't figure it out.

For rover_pos_control, I'm able to change the actuator_control topic messages and can see the changes on QGroundControl. But gimbal shows no change.

For trying the exact lines used for the pwm systemcmd, it just crashes the board. I think it's because I'm referencing too many classes in the same module (a theory).

I saw the pwm_out documentation, and it says that changing actuator_control value alone should trigger the pwm signals, however none of the pins moved the gimbal. Nor did I have a voltmeter to test.

I believe the actuator_control topic should do the heavy lifting, but I might not be doing it right. Would need some consultation for this.