Skip to content
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/libs)

set(ADVANCED_SENSING 1)
# set(ADVANCED_SENSING 0)
set(WAYPT2_CORE 1)

if (ADVANCED_SENSING)
Expand Down
5 changes: 5 additions & 0 deletions UserConfig.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
app_id : 1117356
app_key : b5e83f46d3819a2e96746c17c0dfdfb52b48619c81ca9b7b80cf7e8e00bef01f
device : /dev/ttyUSB0
baudrate : 1000000
acm_port : /dev/ttyACM0
2,758 changes: 2,758 additions & 0 deletions logs/1697602029_log.txt

Large diffs are not rendered by default.

13,342 changes: 13,342 additions & 0 deletions logs/1697605742_log.txt

Large diffs are not rendered by default.

14,515 changes: 14,515 additions & 0 deletions logs/anomaly.txt

Large diffs are not rendered by default.

9,098 changes: 9,098 additions & 0 deletions logs/baseline.txt

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions osdk-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,16 +317,16 @@ install(TARGETS ${PROJECT_NAME}
)
]]

install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/linker/${ARCH}/lib/libdji-linker.a
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" COMPONENT shlib
)

install(TARGETS ${PROJECT_NAME}
EXPORT djiosdkTargets
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" COMPONENT shlib
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_PREFIX}/include" COMPONENT dev
)
# install(FILES
# ${CMAKE_CURRENT_SOURCE_DIR}/linker/${ARCH}/lib/libdji-linker.a
# DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" COMPONENT shlib
# )

# install(TARGETS ${PROJECT_NAME}
# EXPORT djiosdkTargets
# ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" COMPONENT shlib
# PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_PREFIX}/include" COMPONENT dev
# )

#install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/advanced-sensing-2.0.3
# DESTINATION ${OSDK_LIB_ARCH_DIR} )
Expand Down
3 changes: 2 additions & 1 deletion osdk-core/advanced-sensing/platform/inc/linux_usb_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>
#include <libusb.h>
// #include <libusb.h>
#include <libusb-1.0/libusb.h>

#include "dji_hard_driver.hpp"

Expand Down
2 changes: 1 addition & 1 deletion osdk-core/api/inc/dji_flight_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class FlightController {
YawLogic yawLogic;
HorizontalCoordinate horizontalCoordinate;
StableMode stableMode;
} JoystickMode;
} JoystickMode;

/*! @brief
*
Expand Down
1 change: 1 addition & 0 deletions osdk-core/modules/inc/filemgr/impl/mmap_file_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <unistd.h>
#include <memory>
#include <atomic>
#include <string>

namespace DJI {
namespace OSDK {
Expand Down
1 change: 1 addition & 0 deletions osdk-core/modules/src/filemgr/impl/mmap_file_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "mmap_file_buffer.hpp"
#include "dji_log.hpp"
#include <string.h>
#include <cstdio>

namespace DJI {
namespace OSDK {
Expand Down
3 changes: 2 additions & 1 deletion osdk-core/modules/src/flight/dji_flight_joystick_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ void FlightJoystick::getControlMode(ControlMode &controlMode) {
void FlightJoystick::joystickAction() {
if(flightLink)
flightLink->sendDirectly(OpenProtocolCMD::CMDSet::Control::control,
(void *)(&this->ctrlData), sizeof(CtrlData));
// (void *)(&this->ctrlData), sizeof(CtrlData));
&this->ctrlData, sizeof(CtrlData));
else
DERROR(" flight Link is NULL");

Expand Down
5 changes: 4 additions & 1 deletion sample/core/inc/flight_sample.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include <dji_linux_helpers.hpp>
#include <dji_vehicle.hpp>
#include "fuzzer.hpp"

class FlightSample {
public:
Expand Down Expand Up @@ -157,6 +158,9 @@ class FlightSample {
void velocityAndYawRateCtrl(const Vector3f &offsetDesired, float yawRate, uint32_t timeMs);

void emergencyBrake(void);
static Vector3f quaternionToEulerAngle(const Telemetry::Quaternion &quat);

void fuzz(Fuzzer &fuzzer, uint32_t timeMs);

private:
Vehicle *vehicle;
Expand All @@ -168,7 +172,6 @@ class FlightSample {
const Telemetry::GPSFused& origin,
const float32_t& targetHeight,
const float32_t& originHeight);
static Vector3f quaternionToEulerAngle(const Telemetry::Quaternion &quat);
static void horizCommandLimit(float speedFactor, float& commandX, float& commandY);

bool motorStartedCheck();
Expand Down
81 changes: 77 additions & 4 deletions sample/core/src/flight_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*/

#include "flight_sample.hpp"
#include "fuzzer.hpp"
#include <cmath>

using namespace DJI::OSDK;
Expand Down Expand Up @@ -142,6 +143,8 @@ void FlightSample::velocityAndYawRateCtrl(const Vector3f &offsetDesired,
OsdkOsal_GetTimeMs(&currentTime);
elapsedTimeInMs = currentTime - originTime;

///////////////////////////////////////// Original Mode ////////////////////////////////////////////////////////////////////

FlightController::JoystickMode joystickMode = {
FlightController::HorizontalLogic::HORIZONTAL_VELOCITY,
FlightController::VerticalLogic::VERTICAL_VELOCITY,
Expand All @@ -151,7 +154,26 @@ void FlightSample::velocityAndYawRateCtrl(const Vector3f &offsetDesired,
};

vehicle->flightController->setJoystickMode(joystickMode);

///////////////////////////////////////// Fuzzed Mode ////////////////////////////////////////////////////////////////////

// Fuzzer fuzzer = Fuzzer();
// fuzzer.initializeModeGrammar();
// FlightController::JoystickMode joystickMode = fuzzer.generateModeWithGrammar();

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////// Original Cmd ////////////////////////////////////////////////////////////////////

FlightController::JoystickCommand joystickCommand = {offsetDesired.x, offsetDesired.y, offsetDesired.z,yawRate};

///////////////////////////////////////// Fuzzed Cmd ////////////////////////////////////////////////////////////////////

// FlightController::JoystickCommand joystickCommand = fuzzer.generateCommandWithGrammar(joystickMode);

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

vehicle->flightController->setJoystickMode(joystickMode);
vehicle->flightController->setJoystickCommand(joystickCommand);

while(elapsedTimeInMs <= timeMs)
Expand All @@ -163,10 +185,61 @@ void FlightSample::velocityAndYawRateCtrl(const Vector3f &offsetDesired,
}
}

void FlightSample::emergencyBrake()
{
vehicle->flightController->emergencyBrakeAction();
}
void FlightSample::fuzz(Fuzzer &fuzzer, uint32_t timeMs) {
uint32_t originTime = 0;
uint32_t currentTime = 0;
uint32_t elapsedTimeInMs = 0;
OsdkOsal_GetTimeMs(&originTime);
OsdkOsal_GetTimeMs(&currentTime);
elapsedTimeInMs = currentTime - originTime;

///////////////////////////////////////// Original Mode ////////////////////////////////////////////////////////////////////

FlightController::JoystickMode joystickMode = {
FlightController::HorizontalLogic::HORIZONTAL_VELOCITY,
FlightController::VerticalLogic::VERTICAL_VELOCITY,
FlightController::YawLogic::YAW_RATE,
FlightController::HorizontalCoordinate::HORIZONTAL_GROUND,
FlightController::StableMode::STABLE_ENABLE,
};

// vehicle->flightController->setJoystickMode(joystickMode);

///////////////////////////////////////// Fuzzed Mode ////////////////////////////////////////////////////////////////////

// FlightController::JoystickMode joystickMode = fuzzer.generateModeWithGrammar();

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////// Original Cmd ////////////////////////////////////////////////////////////////////

// FlightController::JoystickCommand joystickCommand = {-5000, -5000, 50, 0};

///////////////////////////////////////// Fuzzed Cmd ////////////////////////////////////////////////////////////////////

FlightController::JoystickCommand joystickCommand = fuzzer.generateCommandWithGrammar(joystickMode);
// joystickCommand.yaw = 0;
// joystickCommand.y = 0;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

vehicle->flightController->setJoystickMode(joystickMode);
vehicle->flightController->setJoystickCommand(joystickCommand);

while(elapsedTimeInMs <= timeMs)
{
vehicle->flightController->joystickAction();
usleep(20000);
OsdkOsal_GetTimeMs(&currentTime);
elapsedTimeInMs = currentTime - originTime;
}

}

void FlightSample::emergencyBrake()
{
vehicle->flightController->emergencyBrakeAction();
}

bool FlightSample::moveByPositionOffset(const Vector3f& offsetDesired,
float yawDesiredInDeg,
Expand Down
30 changes: 15 additions & 15 deletions sample/platform/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,18 @@ else()
endif()

#add_subdirectory(camera-gimbal)
add_subdirectory(flight-control)
add_subdirectory(mfio)
add_subdirectory(missions)
add_subdirectory(mobile)
add_subdirectory(telemetry)
add_subdirectory(logging)
add_subdirectory(time-sync)
add_subdirectory(payload-3rd-party)
add_subdirectory(payloads)
add_subdirectory(advanced-sensing)
add_subdirectory(hms)
add_subdirectory(battery)
add_subdirectory(mop)


# add_subdirectory(flight-control)
add_subdirectory(fuzzer)
# add_subdirectory(mfio)
# add_subdirectory(missions)
# add_subdirectory(mobile)
# add_subdirectory(logging)
# add_subdirectory(time-sync)
# add_subdirectory(payload-3rd-party)
# add_subdirectory(payloads)
# add_subdirectory(advanced-sensing)
# add_subdirectory(hms)
# add_subdirectory(battery)
# add_subdirectory(mop)
# add_subdirectory(telemetry)
add_subdirectory(testing)
5 changes: 0 additions & 5 deletions sample/platform/linux/common/UserConfig.txt

This file was deleted.

22 changes: 18 additions & 4 deletions sample/platform/linux/flight-control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,33 @@ project(djiosdk-flightcontrol-sample)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -g -O0")

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../core/inc)

FILE(GLOB SOURCE_FILES *.hpp *.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../common/dji_linux_environment.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../common/dji_linux_helpers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../../core/src/flight_sample.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../hal/*.c
${CMAKE_CURRENT_SOURCE_DIR}/../osal/*.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../core/src/flight_sample.cpp
${LINKER_HEADER_SRC}
)

if (OSDK_HOTPLUG)
FILE(GLOB SOURCE_FILES ${SOURCE_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/../hal/hotplug/*.c)
endif ()

add_executable(${PROJECT_NAME} ${SOURCE_FILES})
# add_executable(${PROJECT_NAME} ${SOURCE_FILES})
add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES})

# for flight functions
target_include_directories(
${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../../../core/inc
${CMAKE_CURRENT_SOURCE_DIR}
)

target_link_libraries(
${PROJECT_NAME}
PUBLIC
djiosdk-core
djiosdk-fuzzer
)
35 changes: 35 additions & 0 deletions sample/platform/linux/fuzzer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# cd ~/Documents/Onboard-SDK/build/ && make clean && cmake .. && make && cd ~/Documents/Onboard-SDK/build/bin/ && ./djiosdk-testing

cmake_minimum_required(VERSION 2.8)
project(djiosdk-fuzzer)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -g -O0")
set(BOOST_INCLUDEDIR /usr/include)

find_package(Boost)

FILE(GLOB SOURCE_FILES
*.hpp
*.cpp
# ${CMAKE_CURRENT_SOURCE_DIR}/../../../../osdk-core/api/src/dji_flight_controller.cpp
)

add_library(${PROJECT_NAME} ${SOURCE_FILES})

target_include_directories(
${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}

# the apis are already part of djiosdk-core which is already been added by upper CMake
# ${CMAKE_CURRENT_SOURCE_DIR}/../../../../osdk-core/api/inc # mode struct
# ${CMAKE_CURRENT_SOURCE_DIR}/../../../../osdk-core/modules/inc/flight # enums
)

target_link_libraries(
${PROJECT_NAME}
PUBLIC
djiosdk-core
# djiosdk-flightcontrol-sample
# boost
)
Loading