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

manual_control: add topic for sending MANUAL_CONTROL messages #919

Merged
merged 1 commit into from
Jan 14, 2018

Conversation

okalachev
Copy link
Contributor

PX4 supports "overriding" manual control inputs via MANUAL_CONTROL message: https://github.com/PX4/Firmware/blob/master/src/modules/mavlink/mavlink_receiver.cpp#L1559 (did not check for APM).

I added ~manual_control/override topic (not sure about the name, this is the analogy with rc/override), allowing user to control the copter with a "virtual" RC with normalised values. For example:

rostopic pub -r 5 /mavros/manual_control/override mavros_msgs/ManualControl "header:
  seq: 0
  stamp: {secs: 0, nsecs: 0}
  frame_id: ''
x: 0.0
y: 0.0
z: 1000.0
r: 200.0
buttons: 0" 

in POSCTL mode makes the copter fly up and rotate (tested in SITL).

Also, I think 1 is the correct value for queue_size for such topics (rc/override, manual_control/override, etc), because we want to send relevant messages, we don't want to queue them.

@okalachev okalachev changed the title manual_control: add topic for sending MANUAL_CONTROL message manual_control: add topic for sending MANUAL_CONTROL messages Jan 13, 2018
@@ -34,6 +34,7 @@ class ManualControlPlugin : public plugin::PluginBase {
PluginBase::initialize(uas_);

control_pub = manual_control_nh.advertise<mavros_msgs::ManualControl>("control", 10);
control_sub = manual_control_nh.subscribe("override", 1, &ManualControlPlugin::override_cb, this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be called override_sub in case topic name override. Maybe name it send?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, send is better. But, in such case, there'll be two topics, send and control, it's non-obvious, that these are send and receive, actually.

@okalachev
Copy link
Contributor Author

I renamed override to send. I think, the best naming is something like send and receive, but this will break up the compatibility, which is not good.

Copy link
Member

@TSC21 TSC21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TSC21 TSC21 merged commit 7426a6a into mavlink:master Jan 14, 2018
@vooon vooon added this to the Version 0.23 milestone Jan 15, 2018
@mchen0037
Copy link

@okalachev Could you give a brief explanation of how this works? When I use the example you give

rostopic pub -r 5 /mavros/manual_control/override mavros_msgs/ManualControl "header:
  seq: 0
  stamp: {secs: 0, nsecs: 0}
  frame_id: ''
x: 0.0
y: 0.0
z: 1000.0
r: 200.0
buttons: 0" 

My copter flies straight up while spinning about yaw , but if I pass 0 in for z, it just sits there.

Is there a way to pass in normalized RC values?

Thanks!

@okalachev
Copy link
Contributor Author

First, the topic was renamed to send (/mavros/manual_control/send). So it should not work at all :)

@mchen0037
Copy link

Sorry--I just copy-pasted. I'm publishing it to /mavros/manual_control/send

@okalachev
Copy link
Contributor Author

okalachev commented Mar 28, 2018

In PX4, x and y are the pitch and roll sticks, normalized from -1000 to 1000.
z is the throttle stick, normilized from 0 to 1000 (unlike in MAVLink documentation).
r is the yaw stick, normilized from -1000 to 1000.

Don't you have it working this way?

@mchen0037
Copy link

Okay, thanks! I was sending in yaw values into z and throttle into r.

@romaster93
Copy link

@okalachev
Is there any further explanation possible?

I modified the command to 'send'. It is output normally in rostopic ehco manual_control / send. However, the FCU is not responding.

@okalachev
Copy link
Contributor Author

okalachev commented Apr 21, 2020

Sorry, I don't get your question. If you publish values to this topic then the vehicle should behave as it was a real RC.

@romaster93
Copy link

ok.
I will attach a picture

@romaster93
Copy link

romaster93 commented Apr 21, 2020

@okalachev

my env :
px4 firmware
gazebo 9
ubuntu 18.04
ros melodic

i tyed this in each terminal :

roslaunch mavros px4.launch

make px4_sitl_default gazebo

./QGroundControl.AppImage

rosrun test mavkbteleop.py ( https://github.com/romaster93/px4_test/blob/master/mavkbteleop.py )

and All work.

I can takeoff using QGroundControl.

and i checked ' rostopic echo /mavros/rc/out ' :

header :

     seq: 225

     stamp:

         secs: 1587478017

         nsecs: 334894783

     frame_id : ' '

channels : [900, 900, 900, 900, 900, 900, 0 ,0, 0 ,0 ,0 ,0 ,0 ,0 ,0]

check 'rostopic echo /mavros/rc/in :

header:
seq: 194
stamp:
secs: 1587478017
nsecs: 291170812
frame_id: ''
rssi: 100
channels: [1500, 1500, 1500, 1500, 1000, 1000, 1000, 1000, 61566, 21897, 0, 46240, 43647, 32532, 0, 15184, 37888, 32532]

check 'rostopic echo /mavros/rc/override' :

channels: [1500, 1500, 1500, 1500, 1000, 1000, 1000, 1000]

first, I believed that the drone would respond if I modified the override value.
I controlled the override value through mavkbteleop.py.
but, the drone did not move. So while I was looking for a solution, I saw an article In google that responded by tying terminal the ' rosrun mavros mavparm set SYSID_MYGCS 1 ', but it didn't work for me. In px4, SYSID_MYGCS did not exist.

After, I saw your article and tried it. I typed in another terminal.

rostopic pub -r 5 /mavros/manual_control/send mavros_msgs/ManualControl "header:
seq: 0
stamp: {secs: 0, nsecs: 0}
frame_id: ''
x: 0.0
y: 0.0
z: 1000.0
r: 200.0
buttons: 0"

I entered in terminal to confirm that the message was delivered.

rostopic echo mavros/manual_control/send :

header:
seq: 1675
stamp:
secs: 0
nsecs: 0
frame_id: ''
x: 0.0
y: 0.0
z: 1000.0
r: 200.0
buttons: 0

But my drone(in gazebo) did not move on the ground.

I definitely want to launch the drone through the rc value in gazebo. I want to know what my problem is.

thanks....

@okalachev
Copy link
Contributor Author

okalachev commented Apr 22, 2020

Basically you have to arm your drone before it will handle virtual RC commands. Maybe this is the problem?

Also, if you want your drone to fly autonomously, it's generally better to utilize the OFFBOARD mode and setpoint commands.

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

Successfully merging this pull request may close these issues.

None yet

5 participants