Skip to content
Josh Weaver edited this page Mar 14, 2014 · 33 revisions
  1. ROSCOPTER
(NOTE) There are other pages in the wiki that may be useful

ROS interface for Arducopter using Mavlink 1.0 interface. credit to both https://code.google.com/p/roscopter/ and https://github.com/aletty/roscopter

Currently it supports controlling the arducopter by overriding the RC command, and it publishes all the sensor data.

Also adding waypoint command code. This code is still in the development stage and is currently being tested. Use at own risk.

Table of Contents

Building

Fuerte

  * Checkout repo
  * Checkout and build mavlink in the roscopter folder, or create a symlink to your existing mavlink build. The `roscopter/mavlink` folder should point to the built mavlink folder.
  * Mavlink can be checked-out from : git clone https://github.com/mavlink/mavlink.git
  * To setup Mavlink, navigate to the "pymavlink" folder and run the command "sudo python setup.py install".
  * Build roscopter using `rosmake`.

Groovy or Hydro

  * Checkout repo
  * Navigate to repo folder ('roscopter')
  * Navigate to scripts folder and run command "chmod 777 driver.py"
  * Navigate back to repo folder
  * Checkout mavlink using submodule (shown below), or create a symlink to an existing mavlink build. 
    * Run command 'git submodule init'
    * Run command 'git submodule update'
  * To build mavlink, navigate to the "pymavlink" folder and run the command "sudo python setup.py install".
  * Navigate back to Catkin folder and run 'catkin_make'.
  * (Optional) To get the most recent Mavlink code perform the following:
    * Navigate to mavlink folder
    * Change branch to desired branch
    * Run "git pull"

Running

rosrun roscopter driver.py --device=/dev/ttyUSB0 --baudrate=57600

  * `--device` specifies the serial device. It could be `/dev/ACMx` or `/dev/ttyUSBx`. 
  * `--baudrate` specifies the baudrate. This should be 57600 if you are using XBee to talk to the APM, and 115200 if you are using a direct wired connection. 
  

Getting sensor data

Roscopter publishes sensor and other state data on the following topics:

  * /attitude : imu information
  * /gps :gps fix
  * /rc : value of current raw rc input
  * /state : shows wether the copter is armed or not, and the current mode 
  * /vfr_hud : airspeed, groundspeed, heading, throttle, alt, climb
  * /raw_imu : raw imu information
  * /status : battery voltage, current, remaining
  * /filtered_pos : position data from APM filter - latitude, longitude, altitude (mm), relative alt, heading
  * /controller_output : roll, pitch, bearing from controller
  * /current_mission : curr_waypt, waypt_dist, waypt_bearing (absolute)
  * /mission_item : seq, current, autocontinue, params, x,y,z (Structured MAVLink item response)

Control

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

nodes/roscopter.py --device=/dev/ttyUSB0 --baudrate=57600 --enable-control=true

Currently the only way of controlling the arducopter is by publishing to `/send_rc` topic. It takes raw RC channel values (between 1000-2000), and uses them to override the values received from the RC controller. To give control back to RC, publish "0" for the corresponding channel. A value of "-1" for a corresponding channel means no change should be made to that channels current value. To send the -1, the value given for the channel should be "65535".

rostopic pub -1 send_rc roscopter/RC "{channel:[1000,]}"

Note: 1000-2000 is the standard PPM Modulation scheme; some receivers/transmitters might violate this specification.

Commands

Various commands may be sent to the APM through the '/command' service. Constants exists within the command service to specify the specific commands that may be sent. You may references these constants when calling the '/command' service, or you may use the exact integer that represents the command. Currently, the commands are as follows:

  1. CMD_LAUNCH = 1
  2. CMD_LAND = 2
  3. CMD_ARM = 3
  4. CMD_DISARM = 4
  5. CMD_SET_STABILIZE = 5
  6. CMD_SET_ALT_HOLD = 6
  7. CMD_SET_AUTO = 7
  8. CMD_SET_LOITER = 8
  9. CMD_SET_LAND = 9
  10. RETURN_RC_CONTROL = 10

Channels:

For Quad frames:

  1. Roll
  2. Pitch
  3. Throttle
  4. Yaw
  5. Change APM Mode
  6. Optional
  7. Optional
  8. Optional
For Hex frames:
  1. Roll
  2. Pitch
  3. Throttle
  4. Yaw
  5. Change APM Mode
  6. Optional
  7. Optional
  8. Optional
Clone this wiki locally