mavlink / mavros

MAVLink to ROS gateway with proxy for Ground Control Station
Other
847 stars 984 forks source link

Pixhawk PWM AUX Control #1309

Open caio-freitas opened 4 years ago

caio-freitas commented 4 years ago

I've been trying to control a servo PWM motor with a Pixhawk 2.4.8, on AUX1, running PX4 v1.9.2 and ROS Kinetic, and all I could get was an Error LED from the Pixhawk. This is the code: `#include <ros/ros.h>

include <mavros_msgs/CommandBool.h>

include <std_msgs/String.h>

include <mavros_msgs/ActuatorControl.h>

include <mavros_msgs/CommandLong.h>

include <mavros_msgs/CommandLongRequest.h>

std_msgs::String message; mavros_msgs::ActuatorControl servocon;

int main(int argc, char *argv) { ros::init(argc, argv, "servo_control"); ros::NodeHandle nh; ros::Rate rate(20.0); ros::ServiceClient command_client = nh.serviceClient("/mavros/cmd/command"); int index=1; float value=1900; // thruster value int pulse_width = (value + 1) 400 + 1100; mavros_msgs::CommandLong srv; srv.request.command = 184; //because it didn't accept mavros_msgs::CommandLong::CMD_DO_SET_SERVO;// srv.request.param1 = index + 1; // servos are 1-indexed here srv.request.param2 = pulse_width; while (ros::ok()) { bool result = command_client.call(srv); ros::spinOnce(); rate.sleep(); } return 0; } `

Does anyone know why it doesn't work or how to do it work?

MAVROS version and platform

Mavros: 0.29.2 ROS: Kinetic Ubuntu: 16.04.5

Autopilot type and version

[ ] ArduPilot [ X ] PX4

Version: ?3.7.1?

Node logs

It logs nothing

Diagnostics

header: seq: 59 stamp: secs: 1567798296 nsecs: 746577989 frame_id: '' status:

OK. I got messages from 1:1.


Received 481 messages, from 1 addresses sys:comp list of messages 1:1 0, 1, 83, 36, 230, 32, 105, 74, 331, 77, 111, 141, 241, 147, 340, 245, 22, 24, 4, 30

Ken-Thorburn commented 4 years ago

Were you able to control an aux port with a mavros command? I just started researching the possibility today.

dibukk95 commented 4 years ago

hai i am also going through the same for last few days.but i am not able to control the aux via mavros.i tried diiferent msgs & various topics but still not able to do.if you figured it please share.

thanks in advance

purvikpatel commented 3 years ago

Hi @dibukk95 Did you find the solution ?

ntrinite commented 1 year ago

Bump for solution?

tiralonghipol commented 1 year ago

@caio-freitas hei, any news on this?