epsilonorion / roscopter

ROS to Ardupilot Mega communication
18 stars 19 forks source link

How to enable control under ROS Hydro? #5

Closed lanyusea closed 10 years ago

lanyusea commented 10 years ago

To enable control, run the roscopter node with --enable-control=true option.

But when I try

>rosrun roscopter driver.py --device=/dev/ttyUSB0 --baudrate=57600 --enable-control=true

Usage: roscopter.py [options]
driver.py: error: no such option: --enable-control

also I cannot use roscopter.py because I'm using hydro.

what should I do to enable control, or is it default enabled?

epsilonorion commented 10 years ago

I mainly use the code in hydro, so it should be fine. The problem is that a lot of updates happened over the past month before I graduated and I did not have a chance to update the wiki. If you look at the python file, the names of the variables have changed a bit. I will have time tomorrow to finish updating the code and then update the wiki.

lanyusea commented 10 years ago

Yes, you are right. I checked the code of driver.py, the parameter‘s name is --enable-rc-control and --enable-waypoint-control instead of --enable-control. Both of them are default True. Sorry I didn't do that before because I'm not familiar with python and only used roscpp. Thanks for your awesome work!

lanyusea commented 10 years ago

Sorry to reopen that issue again, I have some question about the example:

rostopic pub /apm/send_rc roscopter/RC "channel: [1500, 1500, 1500, 1500, 1800, 1500, 1500, 1500]" -1

rostopic pub /apm/send_rc roscopter/RC "channel: [0, 0, 0, 0, 0, 0, 0, 0]" -1
  1. Does the -1 in the end just mean end of command?

2.To give control back to RC, publish "0" for the corresponding channel Does it mean, if I want to use ROS control the yaw while others are still handled by the controller, I should use command: rostopic pub /apm/send_rc roscopter/RC "channel: [0, 0, 0, X, 0, 0, 0, 0]" -1? or this command is just used after I use another one in advance, so I can tell the copter the control form ROS is finished?

3.A value of "-1" for a corresponding channel means no change should be made to that channels current value. I'm wondering if I set the channel value to -1, both of the controller and ROS cannot change its value or only the ROS cannot change it, I can still use controller for that channel?

Thanks.

tonybaltovski commented 10 years ago

The -1 means once mode, its the same as --once. I believe that is it not the controller, rather the receiver that gets control back but I have not tested this.

lanyusea commented 10 years ago

Thank you @tonybaltovski , you're right, -1 means "once", which lasts for 3 seconds.

I tested the code after removing propellers.

My guess is right. ROS has a higher priority than the rc controller.

Once we publish the rc value using ROS, the rc controller cannot control that channel any more until we send value 0 to that channel.

The -1 makes the value unchanged if you just want to modify other values but don't want to type the same value for current channel again.

At first I just want to know if I can use this way to make my copter armed then change its state to AUTO with the pre-set waypoints.

Now it seems I can do that.

(I asked that question yesterday without testing by myself because I was not allowed to remove the propellers at that moment. Sorry about that.)