-
Notifications
You must be signed in to change notification settings - Fork 986
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
Pixhawk PWM AUX Control #1309
Comments
Were you able to control an aux port with a mavros command? I just started researching the possibility today. |
hai thanks in advance |
Hi @dibukk95 |
Bump for solution? |
@caio-freitas hei, any news on this? |
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_msgs::CommandLong>("/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:
level: 2
name: "mavros: GPS"
message: "No satellites"
hardware_id: "/dev/ttyUSB0:57600"
values:
value: "0"
value: "99.99"
value: "99.99"
level: 0
name: "mavros: Heartbeat"
message: "Normal"
hardware_id: "/dev/ttyUSB0:57600"
values:
value: "0.999983"
value: "Hexarotor"
value: "PX4 Autopilot"
value: "MANUAL"
value: "Standby"
level: 2
name: "mavros: System"
message: "Sensor helth"
hardware_id: "/dev/ttyUSB0:57600"
values:
value: "0x0021000F"
value: "0x000E002F"
value: "Ok"
value: "Ok"
value: "Ok"
value: "Ok"
value: "Fail"
value: "Fail"
value: "33.1"
value: "0.0"
value: "0"
value: "0"
value: "0"
value: "0"
value: "0"
level: 0
name: "mavros: Battery"
message: "Normal"
hardware_id: "/dev/ttyUSB0:57600"
values:
value: "-0.0"
value: "-1.0"
level: 2
name: "mavros: Time Sync"
message: "No events recorded."
hardware_id: "/dev/ttyUSB0:57600"
values:
value: "0.000000"
Check ID
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
The text was updated successfully, but these errors were encountered: