The code doesn't execute my main function when using DJI OSDK - dji-sdk

I have an N3 with OSDK running on a RPi. I am able to run the telemetry-sample without any problem. However, when I try to make my own program, the program doesn't execute my main function.
I build the program just like the provided samples, using CMAKE. However, the sample runs fine, but mine stops right before entering the main function. Does anyone have an idea as to why this may be happening? Am i missing something?
Here is the output of my program:
argv[1] = UserConfig.txt
Read App ID
User Configuration read successfully.
STATUS/1 # init, L56: Attempting to open device /dev/ttyAMA0 with baudrate 230400...
STATUS/1 # init, L66: ...Serial started successfully.
STATUS/1 # parseDroneVersionInfo, L762: Device Serial No. = [redacted]
STATUS/1 # parseDroneVersionInfo, L764: Hardware = N3
STATUS/1 # parseDroneVersionInfo, L765: Firmware = 3.2.36.8
ERRORLOG/1 # initVirtualRC, L1188: Virtual RC is not supported on this platform!
STATUS/1 # activate, L1398: version 0x3022408
STATUS/1 # activate, L1411: Activation successful
STATUS/1 # verify, L247: Verify subscription successful.
STATUS/1 # initGimbal, L926: Checking if gimbal is connected ...
STATUS/1 # startPackage, L353: Start package 0 result: 0.
STATUS/1 # startPackage, L355: Package 0 info: freq=50, nTopics=1.
STATUS/1 # removePackage, L471: Remove package 0 successful.
STATUS/1 # initGimbal, L970: Gimbal not mounted!
STATUS/1 # reset, L570: Reset Subscription Successful.

Correction, I had copied my CMAKE file from another directory into my new project directory. This caused the CMakeCache to be linked to the old directory and was executing old code.
I updated the CMakeCache to include the new project's directory and everything worked fine.
Leaving this up, in case someone does this mistake too.

Related

failed to add service - already in use error

I compiled SFML library and my app on Raspbian with this tutorial https://github.com/oomek/sfml-pi. After this I moved shared objects and app to buildroot system for Raspberry Pi 4. I chosed DISPMANX version, my goal was to run app without X server.
When I try to run app, I have error failed to add service - already in use?. I know that there was many similar topics, I tried this solutions:
Comment dtoverlay=vc4-kms-v3d in config.txt -> this line didn't existed in my config.
Change gpu_mem to 128 -> any improvement
My config.txt:
# Please note that this is only a sample, we recommend you to change it to fit
# your needs.
# You should override this file using a post-build script.
# See http://buildroot.org/manual.html#rootfs-custom
# and http://elinux.org/RPiconfig for a description of config.txt syntax
# We always use the same names, the real used variant is selected by
# BR2_PACKAGE_RPI_FIRMWARE_{DEFAULT,X,CD} choice
start_file=start.elf
fixup_file=fixup.dat
kernel=zImage
# To use an external initramfs file
#initramfs rootfs.cpio.gz
# Disable overscan assuming the display supports displaying the full resolution
# If the text shown on the screen disappears off the edge, comment this out
disable_overscan=1
# How much memory in MB to assign to the GPU on Pi models having
# 256, 512 or 1024 MB total memory
gpu_mem_256=128
gpu_mem_512=128
gpu_mem_1024=128
gpu_mem_1024=192
gpu_mem=128
# fixes rpi (3B, 3B+, 3A+, 4B and Zero W) ttyAMA0 serial console
dtoverlay=miniuart-bt
On buildroot I set opengl from gst1-plugins-base with dispmanx, gles2, egl and wayland. I didn't set mesa-3d.
Any idea how can I make my app working? Should I add something to my config.txt?

N3 Activation Issue

I have bought a DJI N3 flight controller. I want to use the Onboard SDK on it. But I am facing problems with the activation. I have got the APP ID and Key from the site. I have edited the sdk.launch file and UserConfig.txt in the SDK packages. On running the launch file, I am getting the following result.
trishant#Eurus-Holmes:~/catkin_ws/src$ roslaunch dji_sdk sdk.launch
... logging to /home/trishant/.ros/log/a8788da0-05e8-11e9-89ab-2c6e8522ef61/roslaunch-Eurus-Holmes-27223.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://Eurus-Holmes:41551/
SUMMARY
========
PARAMETERS
* /dji_sdk/align_time: False
* /dji_sdk/app_id: 1066401
* /dji_sdk/app_version: 1
* /dji_sdk/baud_rate: 921600
* /dji_sdk/enc_key: f9b36add116633854...
* /dji_sdk/serial_name: /dev/ttyUSB0
* /dji_sdk/use_broadcast: False
* /rosdistro: kinetic
* /rosversion: 1.12.14
NODES
/
dji_sdk (dji_sdk/dji_sdk_node)
ROS_MASTER_URI=http://localhost:11311
process[dji_sdk-1]: started with pid [27240]
STATUS/1 # init, L55: Attempting to open device /dev/ttyUSB0 with baudrate 921600...
STATUS/1 # init, L65: ...Serial started successfully.
STATUS/1 # parseDroneVersionInfo, L706: Device Serial No. = 0DBDF5E00200BS
STATUS/1 # parseDroneVersionInfo, L708: Hardware = N3
STATUS/1 # parseDroneVersionInfo, L709: Firmware = 3.3.8.39
ERRORLOG/1 # initVirtualRC, L1067: Virtual RC is not supported on this platform!
STATUS/1 # activate, L1277: version 0x3030827
STATUS/1 # getErrorCodeMessage, L656: activate
STATUS/1 # getCMDSetActivationMSG, L705: DJIGO_APP_NOT_CONNECTED_ERROR
ERRORLOG/1 # activate, L1302: Failed to activate please retry SET 0x0 ID 0x1 code 0x4
[ERROR] [1545484435.702713621]: drone activation error
[ERROR] [1545484435.702863772]: Vehicle initialization failed
^C[dji_sdk-1] killing on exit
STATUS/1 # getErrorCodeMessage, L656: removePackage
STATUS/1 # getCMDSetSubscribeMSG, L739: SUBSCRIBER_ILLEGAL_DATA_LENGTH
STATUS/1 # getErrorCodeMessage, L656: removePackage
STATUS/1 # getCMDSetSubscribeMSG, L739: SUBSCRIBER_ILLEGAL_DATA_LENGTH
STATUS/1 # getErrorCodeMessage, L656: removePackage
STATUS/1 # getCMDSetSubscribeMSG, L739: SUBSCRIBER_ILLEGAL_DATA_LENGTH
STATUS/1 # getErrorCodeMessage, L656: removePackage
STATUS/1 # getCMDSetSubscribeMSG, L739: SUBSCRIBER_ILLEGAL_DATA_LENGTH
STATUS/1 # getErrorCodeMessage, L656: reset
STATUS/1 # getCMDSetSubscribeMSG, L739: SUBSCRIBER_ILLEGAL_DATA_LENGTH
shutting down processing monitor...
... shutting down processing monitor complete
done
Am I missing some steps? Is DJI GO compulsory for activation?
I have connected the computer to API pins and followed ROS Onboard instructions (https://developer.dji.com/onboard-sdk/documentation/sample-doc/sample-setup.html#ros-onboard-computer)
Thanks in advance.
The issue is solved. You can activate without the DJI App.

Drone won't take of nor spin its motor with Onboard SDK sample code

I built up my own drone with DJI A3 and Raspberry Pi 3 with Onboard SDK 3.5. I tested the sample code and telemetry one seems ok, but flight control one didn't work. In the simulator of Assistant 2, it runs correctly, but in real life, even its motor didn't spin. here's the console log:
rp1:pi % ./djiosdk-flightcontrol-sample UserConfig.txt
Read App ID
User Configuration read successfully.
STATUS/1 # init, L55: Attempting to open device /dev/ttyAMA0 with baudrate 230400...
STATUS/1 # init, L65: ...Serial started successfully.
STATUS/1 # parseDroneVersionInfo, L630: Device Serial No. = 0670134595
STATUS/1 # parseDroneVersionInfo, L632: Hardware = A3
STATUS/1 # parseDroneVersionInfo, L633: Firmware = 3.2.36.8
ERRORLOG/1 # functionalSetUp, L211: Virtual RC not supported!
STATUS/1 # activate, L1083: version 0x3022408
STATUS/1 # activate, L1096: Activation successful
STATUS/1 # startPackage, L332: Start package 0 result: 0.
STATUS/1 # startPackage, L334: Package 0 info: freq=50, nTopics=1.
STATUS/1 # removePackage, L441: Remove package 0 successful.
STATUS/1 # initGimbal, L804: Gimbal not mounted!
| Available commands: |
| [a] Monitored Takeoff + Landing |
| [b] Monitored Takeoff + Position Control + Landing |
a
STATUS/1 # startPackage, L332: Start package 0 result: 0.
STATUS/1 # startPackage, L334: Package 0 info: freq=10, nTopics=2.
STATUS/1 # getErrorCodeMessage, L644: %&1nZ%&̖nZ
STATUS/1 # getCMDIDTaskMSG, L823: CONTROLLER_MOTOR_ON
ERRORLOG/1 # initPackageFromTopicList, L162: package [0] is being occupied.
it seems vehicle->control->takeoff() returns some error(L87 in the sample code flight_control_sample.cpp), but I have absolutly no idea how to solve this problem.
Help is really appreciated. thanks!
I solved this problem: just calibrate the compass!
the official user manual has a page with information about how to calibrate the compass.

uart-baudrate is changed multiple times during boot

I can not figure out, where the uart, baudrate is changed in the linux kernel.
I am using the adi_uart4.c driver (not in the major 4.14 kernel yet). But it is designed like all the other in driver/tty/serial/
While booting:
CONFIG_BAUDRATE 115200 -> uboot baudrate
earlyprintk=serial,uart0,115200 -> cmdline arg in uboot
console=ttySC0,115200 -> cmdline arg in uboot
??? -> set to 56700
Linux boot output stops, because of baudrate change:
[..]
Freeing unused kernel memory: 1024K
Starting logging: OK
Starting mdev...
Starting watchdog...
Initializing random number generator... done.
Starting network...
/bin/sh: run-parts: not found
Starting inetd: OK
��怘�~3f<��<����f<���3�f��Æ�����`?怘���<f?����`<?����`?<��~<�����������
Thank you #sawdust.
There was an additional userspace change in /etc/inittab
# Put a getty on the serial port
ttySC0::respawn:/sbin/getty -L ttySC0 56700 vt100 # GENERIC_SERIAL

Failed to activate OSDK on DJI M100

I am trying to run the djiosdk-flightcontrol-sample on a M100 drone but I am getting the following output/error:
pi#drone:~/drone/Onboard-SDK-3.3/build/bin $ ./djiosdk-flightcontrol-sample ../../sample/linux/common/UserConfig.txt
Read App ID
User Configuration read successfully.
STATUS/1 # init, L37: Attempting to open device /dev/ttyUSB0 with baudrate 230400...
STATUS/1 # init, L47: ...Serial started successfully.
STATUS/1 # parseDroneVersionInfo, L568: Device Serial No. = 041DE52780
STATUS/1 # parseDroneVersionInfo, L570: Hardware = M100
STATUS/1 # parseDroneVersionInfo, L571: Firmware = 3.1.10.0
STATUS/1 # parseDroneVersionInfo, L574: Version CRC = 0xA6453AAC
STATUS/1 # functionalSetUp, L126: Subscriber not supported!
STATUS/1 # functionalSetUp, L164: MFIO not supported!
ERROR/1 # functionalSetUp, L182: Hardware Sync not supported!
STATUS/1 # activate, L951: version 0x3010A00
STATUS/1 # getErrorCodeMessage, L590: activate
STATUS/1 # getCMDSetActivationMSG, L638: NEW_DEVICE_ERROR
ERROR/1 # activate, L971: Failed to activate please retry SET 0x0 ID 0x1 code 0x3
STATUS/1 # getErrorCodeMessage, L590: setupOSDK
STATUS/1 # getCMDSetActivationMSG, L638: NEW_DEVICE_ERROR
Vehicle not initialized, exiting.
pi#drone:~/drone/Onboard-SDK-3.3/build/bin $
As you can see, the computer can communicate with the M100 via USB:
The M100 is connected to the CPU via the UART_CAN2 cable and a TTL-USB converter.
The OSDK can read/write from/to the M100: (it gets the device serial No, etc)
The App ID and Key are set in the configuration file.
The Assistant is running on another CPU (a Mac)
All transmission rates are different than zero and less than 100Hz at the DJI OSDK configuration page
Everything looks right, but it does not work and gives the obscure message:
Failed to activate please retry SET 0x0 ID 0x1 code 0x3
Any ideas?
From the docs:
Q. The sample says Activation failed! and does not proceed.
A. Please make sure you have DJI Go open and your mobile device connected to the internet, and the correct App ID and Key in your config.json file. Try a couple of times, if it doesn't work, raise a Github issue.
The NEW_DEVICE_ERROR indicates that the activation was unable to verify your app ID and key with the activation server. This could be because the ID and Key do not match, but it is usually because DJI Go is not open or does not have connection to the Internet.
Source: https://github.com/dji-sdk/Onboard-SDK/issues/189#issuecomment-336981568

Resources