0%

work diary of capstone project

In this blog, I will record the working progress in the capstone project and the problems I faced.

23.10.2016

  • changed the default hover controller. add three new actions PX4TakeoffAction, PX4LandAction and PX4 FlytoAction.

    30.9.2016

  • in statemachine, use file io to read a flight script.
  • in statemachine, timeout failure would be trigered if a state takes too long time.

    28.9.2016

  • modified the mode in states to OFFBOARD to match with PX4.

    5.9.2016

    Hover_Controller:
    Cablibrate the P I D and achieved better control. Proved that the controller structure is ok. But I still need to improve the controller structure itself.

    4.9.2016

    for the hover controller:
  • remove unnecessary files
  • rewrite the waypoint navigation logic
  • try to calibrate PID parameters but strange things always happen and the result gets even worse.

    26.8.2016

  • update the state machine and hover controller, now a simulation is achived but quite ugly.

    24.8.2016

  • update the state machine

    7.8.2016

    hover_controller: in gazebo simulation environment, the hover controller is now able to control a single drone to take off, land and navigate through the way point.

    7.6.2016

  • fix state machine compiling problem

    4.6.2016 - 7.6.2016

  • based on an APM FCU firmware, I started to code a position controller which is able to controll the quadcopter to takeoff ,land and fly through preset waypoints.

    28.5.2016

    mavlink streaming

Working Content: Today I tested the mavlink steaming rate of miniAPM. The original APM3.2.1 firmware support up to 25 Hz of message streaming. This is limited by the software, So I modified the firmware and successfully increased the rate to 50Hz. In fact the rate can be improved to up to 100 Hz. But I’m afraid this will harm the stability of the firmware.
In ArduCopter.pde, The scheduler update rate of gcs_data_stream_send() is set to 50Hz. This function is the regarding to the streaming of message. The function is in GCS_Mavlink.pde.

1
2
3
4
5
6
7
8
9
10
11
 \*  
\* send data streams in the given rate range on both links
\*
static void gcs\_data\_stream\_send(void)
{
for (uint8\_t i=0; i<num\_gcs; i++) {
if (gcs\[i\].initialised) {
gcs\[i\].data\_stream\_send();
}
}
}

In this function data_stream_send() is called, each stream is sent based on the following statement.

1
2
3
4
5
if(stream\_triger(STREAM\_RAW\_SENSORS)) {  
send\_message(MSG\_RAW\_IMU1);
send\_message(MSG\_RAW\_IMU2);
send\_message(MSG\_RAW\_IMU3);
}

The limit occurs in stream_triger(), as shown below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
if (stream\_ticks\[stream\_num\] == 0) {  
// we're triggering now, setup the next trigger point
if (rate > 50) {
rate = 50;
}else if(rate > 25){
stream\_ticks\[stream\_num\] = 0 + stream\_slowdown;
}else {
stream\_ticks\[stream\_num\] = (50 / rate) + stream\_slowdown;
}
return true;
}
// count down at 50Hz
stream\_ticks\[stream\_num\]--;
return false;

This is already my modified version. The stream_ticks is count down at 50 Hz. So when rate > 25, the streaming rate can not increase any more. So when rate > 25, I set the stream_ticks[stream_num] to 0, so they rate will go up to 50 Hz.
Time: 3 hour.

off board switch

Working Content: I figured out how every channel is used in Arducopter. channel 1 ~ channel 4 are used for throttle, roll, pitch, yaw. channel 5 is used for mode switch. channel 6 is optionally used for tuning and camera. channel 7 and above are aux switch for more functions. I think I can add a new auxilary function to switch on and off off-board mode. and connect the receiver’s channel 6 to channel 7. then we can use channel 6 on transmitter to toggle off-board.

24.5.2016

Working Content: I modified the pixy node and add a ros publisher. It doesn’t work at first with rosrun. Latter I found in the official guide of installation that I need to copy the /src/host/linux/pixy.ruls to /etc/udev/ruls.d reference.
Time: 1 hour.

19.5.2016

Working Content: I finally found the way to upgrade the firmware of the miniAPM. Before I tried to use the mission planner to upgrade the miniAPM but the transmission always fail. Today I downloaded an APM Planner to my mac and succesfully upgraded miniAPM to arducopter 3.2.1. In this version “arming” through mavlink is implemented. More over when the mavlink connection is down, the control will fail over to transmitter when RC_OVERRIDE is used. That’s also a good news.
Today I also modified the firmware source code of ArduCopter. I’m trying to enhance the failsafe feature in RC_OVERRIDE. I will enhance the code based on the orignal Arducopter 3.2.1 because that’s the newest firmware supported by miniAPM.
Time: 3 hours.

4.5.2016

Working Content: I tested the mavros arming service to arm the apm. It doesn’t work. But I don’t think it’s a bug of mavros. The mission planner cannot arm the apm neither.
I also tested the rcoverride function of mavros. It worked. The SYSID_MYGCS param of apm must be set to 1, so that the mavros can override the rc. But I found that once you use the rcoverride to take over the transmitter, you cannot use the transmitter to take over the mavros again. This would cause problem when I want to use the transmitter to take over the raspberry pi in emergency.
Improved the pan tilt control of pixy.
Time: 5 hours.

3.5.2016

Working Content: Calibrate the lens distortion (radial and tangental distortion) of the pixy camera. We used the camera_calibration sample code of opencv 2.4.9 to calculate the camera matrix and distortion coefficients. The focus length of pixy camera is adjustable, so every time I adjust the focus length I need to re-calibrate the camera. It’s not convinient.
We use the following equations to calibrate the distortion:
alt text
alt text
The calibrated result is acceptable but not accurate. Because we are not sure the meaning of x, y and r. I’m afraid there are some mistakes in not calculation.
Time: 5 hours.

2.5.2016

Working Content: Assembly and test fly the drone.
Time: 5 hours.

29.4.2016

Working Content: Assembly the drone.
Time: 5 hours.

28.4.2016

Working Content: Assembly the drone; Change the color marker recognition method from four different colors to two different colors.
Time : 5 houts.

8.4.2016

Working Content: update the CMakeList.txt of pixy_node. fix the compiling failure.
Time: 3 hours.

5.4.2016

Working Content: Checkout the mavros and mavlink submodule. fix the conflict of the submodules.
Time: 4 hours.

27.2.2016

Working Content: Improve the simulation environment. The apm sitl firmware is not realistic, and we would like to use PX4 autopilot stack. So I compiled the px4 sitl firmware on linux and upgrade gazebo to version 6.0.
Time :8 hours.

17.2.2016

Working Content: Set up the simulation environment in linux. The simulation environment includes the apm sitl firmware, the ros and gazebo simulation environment. I tested the simulation and it works.
Time: 8 hours.