Example code for autonomous take off and land

Hello, I want to achieve an autonomous take off and land of my copter using Odroid XU4 connected through serial port. Could someone share a small code for me to understand this, what are the parameters needed to achieve this. I have found one on the PX4 website, could this be used for APM as well. Thanks

Your vehicle needs to be in GUIDED mode for automatic takeoff. What have you tried so far? Are you using dronekit-python are you using something else?

Hi Lars, My main aim is to implement collision avoidance using ultrasonic sensors. So far I am able to communicate with the FC via mavproxy on the odroid. The reason I asked for a sample C++ code for autonomous take off land is to get familiar with the structure and parameters that are necessary for offboard control of the drone. Thanks

Have you looked at these:
http://discuss.ardupilot.org/t/basic-obstacle-stop-system-build-log-and-firmware/14454
http://ardupilot.org/dev/docs/code-overview-object-avoidance.html

Hi ppoirier, Thanks for the links, will check it out.