Skip to content

Commit

Permalink
OSDKROS 3.3.1. Introduce backward compatibility for M100.
Browse files Browse the repository at this point in the history
  • Loading branch information
zliDJI committed Aug 4, 2017
1 parent ffc2f08 commit 45ec1b2
Show file tree
Hide file tree
Showing 17 changed files with 490 additions and 132 deletions.
34 changes: 24 additions & 10 deletions ReadMe.md
@@ -1,8 +1,6 @@
# DJI Onboard SDK ROS 3.3
# DJI Onboard SDK ROS 3.3.1

**Version 3.3 was developed to support N3/A3 FW 1.7.5 and above.**

**M100 users please use version 3.2.**
**Version 3.3.1 was developed to support N3/A3 FW 1.7.5 and above, and is backword compatible with M100 FW 1.3.1.**

## Quick Start Guide

Expand All @@ -16,27 +14,43 @@ ROS Wiki can be found [here](http://wiki.ros.org/dji_sdk). Please be sure to rea

| Aircraft/FC | Firmware Package Version | Flight Controller Version | OSDK Version Support |
|--------------- |--------------------------|----------------------------|---------------------- |
| **A3/A3 Pro** | **1.7.1.5** | **3.2.36.8** | **OSDK 3.3 (Current)** |
| **A3/A3 Pro** | **1.7.1.5** | **3.2.36.8** | **OSDK 3.3.1 (Current)** |
| | 1.7.0.5 | 3.2.15.50 | OSDK 3.2 |
| | 1.7.0.0 | 3.2.15.37 | OSDK 3.2 |
| | | | |
| **N3** | **1.7.1.5** | **3.2.36.8** | **OSDK 3.3 (Current)** |
| **N3** | **1.7.1.5** | **3.2.36.8** | **OSDK 3.3.1 (Current)** |
| | 1.7.0.0 | 3.2.15.37 | OSDK 3.2 |
| | | | |
| **M600/M600 Pro** | Coming soon! | Coming soon! | **OSDK 3.3 (Current)** |
| **M600/M600 Pro** | Coming soon! | Coming soon! | **OSDK 3.3.1 (Current)** |
| | 1.0.1.20 | 3.2.15.62 | OSDK 3.2 |
| | 1.0.0.80 | 3.2.15.00 | OSDK 3.2 |
| | | | |
| **M100** | 1.3.1.0 | 3.1.10.0 | OSDK 3.2 |
| **M100** | 1.3.1.0 | 3.1.10.0 | **OSDK 3.3.1 (Current),** |
| | | | and OSDK 3.2 |

## Notes on differences between M100 and A3/N3 setup

Backward compatibility for M100 was brought in version 3.3.1. However, due to the limitations of the flight controller of M100, some new features such as hardware sync, MFIO, on demand telemetry data (subscription) are only supported by A3/N3, and some settings for M100 are different from those for A3/N3.

1. The DJI Assistant 2 for M100 and for A3/N3 are slighly different. Please download DJI Assistant 2 from the corresponding product webpage.

2. The DJI SDK ROS package requires different baud rate for M100 and A3/N3. For M100, set the baud rate to 230400 in DJI Assistant 2's "SDK" tab, and the sdk.launch file; while for A3/N3, use 921600.

3. For M100, on the right side of the "SDK setting" tab of DJI Assistant 2, set the Data Type of ACC and GYRO to "Raw Data", and ALTI to "Data Fusion". The reason is that the raw data of acc and gyro are part of the /dji_sdk/imu message.

4. The flight_status enums for M100 and A3/N3 are different. See dji\_sdk.h for details and demo_flight_control for examples.

5. Some topics are only available on A3/N3: display_mode, angular_velocity_fused, acceleration_ground_fused, trigger_time.

6. The imu topic is published at 400Hz on A3/N3, and at 100Hz on M100.

7. Some services are only available on A3/N3: mfio_config, mfio_set_value, set_hardsyc

## Support

You can get support from DJI and the community with the following methods:

- Github Issues or [gitter.im](https://gitter.im/dji-sdk/Onboard-SDK)
- Send email to dev@dji.com describing your problem and a clear description of your setup
- Post questions on [**Stackoverflow**](http://stackoverflow.com) using [**dji-sdk**](http://stackoverflow.com/questions/tagged/dji-sdk) tag
- [**DJI Forum**](http://forum.dev.dji.com/en)


Expand Down
1 change: 1 addition & 0 deletions dji_sdk/CMakeLists.txt
Expand Up @@ -84,6 +84,7 @@ add_service_files(
MissionHpResetYaw.srv
SendMobileData.srv
SetHardSync.srv
QueryDroneVersion.srv
)

## Generate added messages and services with any dependencies listed here
Expand Down
65 changes: 53 additions & 12 deletions dji_sdk/include/dji_sdk/dji_sdk.h
Expand Up @@ -13,13 +13,26 @@
#define PROJECT_DJI_SDK_H_H
#include <djiosdk/dji_control.hpp>
#include <djiosdk/dji_status.hpp>
#include <djiosdk/dji_version.hpp>
namespace DJISDK {

/*!
* This enum is used with service query_drone_version to
* check if the drone is M100 or not. We only support
* M100 with this particular FW version.
*/
enum DroneFirmwareVersion
{
M100_31 = DJI::OSDK::Version::M100_31,
};

enum FlightControlFlag
{
HORIZONTAL_ANGLE = DJI::OSDK::Control::HORIZONTAL_ANGLE,
HORIZONTAL_VELOCITY = DJI::OSDK::Control::HORIZONTAL_VELOCITY,
HORIZONTAL_POSITION = DJI::OSDK::Control::HORIZONTAL_POSITION,
// Horizontal angular rate is supported only by A3/N3 based platform
// and is NOT supported by M100
HORIZONTAL_ANGULAR_RATE = DJI::OSDK::Control::HORIZONTAL_ANGULAR_RATE,

VERTICAL_VELOCITY = DJI::OSDK::Control::VERTICAL_VELOCITY,
Expand All @@ -36,52 +49,80 @@ enum FlightControlFlag
STABLE_ENABLE = DJI::OSDK::Control::STABLE_ENABLE
};

/*!
* Refer to demo_flight_control.cpp in dji_sdk_demo for how to
* use the display mode.
*/
enum DisplayMode
{
/*! This mode requires the user to manually
* control the aircraft to remain stable in air. */
MODE_MANUAL_CTRL=DJI::OSDK::VehicleStatus::MODE_MANUAL_CTRL,
MODE_MANUAL_CTRL=DJI::OSDK::VehicleStatus::DisplayMode::MODE_MANUAL_CTRL,
/*! In this mode, the aircraft can keep
* attitude stabilization and only use the
* barometer for positioning to control the altitude. <br>
* The aircraft can not autonomously locate and hover stably.*/
MODE_ATTITUDE=DJI::OSDK::VehicleStatus::MODE_ATTITUDE,
MODE_ATTITUDE=DJI::OSDK::VehicleStatus::DisplayMode::MODE_ATTITUDE,

/*! The aircraft is in normal GPS mode. <br>
* In normal GPS mode, the aircraft can
* autonomously locate and hover stably. <br>
* The sensitivity of the aircraft to the
* command response is moderate.
*/
MODE_P_GPS=DJI::OSDK::VehicleStatus::MODE_P_GPS,
MODE_P_GPS=DJI::OSDK::VehicleStatus::DisplayMode::MODE_P_GPS,
/*! In hotpoint mode */
MODE_HOTPOINT_MODE=DJI::OSDK::VehicleStatus::MODE_HOTPOINT_MODE,
MODE_HOTPOINT_MODE=DJI::OSDK::VehicleStatus::DisplayMode::MODE_HOTPOINT_MODE,
/*! In this mode, user can push the throttle
* stick to complete stable take-off. */
MODE_ASSISTED_TAKEOFF=DJI::OSDK::VehicleStatus::MODE_ASSISTED_TAKEOFF,
MODE_ASSISTED_TAKEOFF=DJI::OSDK::VehicleStatus::DisplayMode::MODE_ASSISTED_TAKEOFF,
/*! In this mode, the aircraft will autonomously
* start motor, ascend and finally hover. */
MODE_AUTO_TAKEOFF=DJI::OSDK::VehicleStatus::MODE_AUTO_TAKEOFF,
MODE_AUTO_TAKEOFF=DJI::OSDK::VehicleStatus::DisplayMode::MODE_AUTO_TAKEOFF,
/*! In this mode, the aircraft can land autonomously. */
MODE_AUTO_LANDING=DJI::OSDK::VehicleStatus::MODE_AUTO_LANDING,
MODE_AUTO_LANDING=DJI::OSDK::VehicleStatus::DisplayMode::MODE_AUTO_LANDING,
/*! In this mode, the aircraft can antonomously return the
* last recorded Home Point. <br>
* There are three types of this mode: Smart RTH(Return-to-Home),
* Low Batterry RTH, and Failsafe RTTH. */
MODE_NAVI_GO_HOME=DJI::OSDK::VehicleStatus::MODE_NAVI_GO_HOME,
MODE_NAVI_GO_HOME=DJI::OSDK::VehicleStatus::DisplayMode::MODE_NAVI_GO_HOME,
/*! In this mode, the aircraft is controled by SDK API. <br>
* User can directly define the control mode of horizon
* and vertical directions and send control datas to aircraft. */
MODE_NAVI_SDK_CTRL=DJI::OSDK::VehicleStatus::MODE_NAVI_SDK_CTRL,
MODE_NAVI_SDK_CTRL=DJI::OSDK::VehicleStatus::DisplayMode::MODE_NAVI_SDK_CTRL,

/*! drone is forced to land, might due to low battery */
MODE_FORCE_AUTO_LANDING=DJI::OSDK::VehicleStatus::MODE_FORCE_AUTO_LANDING,
MODE_FORCE_AUTO_LANDING=DJI::OSDK::VehicleStatus::DisplayMode::MODE_FORCE_AUTO_LANDING,
/*! drone will search for the last position where the rc is not lost */
MODE_SEARCH_MODE =DJI::OSDK::VehicleStatus::MODE_SEARCH_MODE,
MODE_SEARCH_MODE =DJI::OSDK::VehicleStatus::DisplayMode::MODE_SEARCH_MODE,
/*! Mode for motor starting. <br>
* Every time user unlock the motor, this will be the first mode. */
MODE_ENGINE_START = DJI::OSDK::VehicleStatus::MODE_ENGINE_START
MODE_ENGINE_START = DJI::OSDK::VehicleStatus::DisplayMode::MODE_ENGINE_START
};

/*!
* Note that the flight status for M100 and A3/N3 are different.
*
* Refer to demo_flight_control.cpp in dji_sdk_demo for how to
* use the flight status.
*
*/
enum FlightStatus
{
STATUS_STOPPED = DJI::OSDK::VehicleStatus::FlightStatus::STOPED,
STATUS_ON_GROUND = DJI::OSDK::VehicleStatus::FlightStatus::ON_GROUND,
STATUS_IN_AIR = DJI::OSDK::VehicleStatus::FlightStatus::IN_AIR
};

enum M100FlightStatus
{
M100_STATUS_ON_GROUND = DJI::OSDK::VehicleStatus::M100FlightStatus::ON_GROUND_STANDBY,
M100_STATUS_TAKINGOFF = DJI::OSDK::VehicleStatus::M100FlightStatus::TAKEOFF,
M100_STATUS_IN_AIR = DJI::OSDK::VehicleStatus::M100FlightStatus::IN_AIR_STANDBY,
M100_STATUS_LANDING = DJI::OSDK::VehicleStatus::M100FlightStatus::LANDING,
M100_STATUS_FINISHED_LANDING = DJI::OSDK::VehicleStatus::M100FlightStatus::FINISHING_LANDING
};

}


Expand Down
15 changes: 13 additions & 2 deletions dji_sdk/include/dji_sdk/dji_sdk_node.h
Expand Up @@ -25,6 +25,7 @@
#include <sensor_msgs/TimeReference.h>
#include <sensor_msgs/BatteryState.h>
#include <std_msgs/UInt8.h>
#include <std_msgs/Float32.h>


//! msgs
Expand Down Expand Up @@ -59,7 +60,7 @@
#include <dji_sdk/MFIOSetValue.h>
#include <dji_sdk/SDKControlAuthority.h>
#include <dji_sdk/SendMobileData.h>

#include <dji_sdk/QueryDroneVersion.h>
//! SDK library
#include <djiosdk/dji_vehicle.hpp>

Expand Down Expand Up @@ -99,6 +100,7 @@ class DJISDKNode
bool initDataSubscribeFromFC();
void cleanUpSubscribeFromFC();
bool validateSerialDevice(LinuxSerialDevice* serialDevice);
bool isM100();
/*!
* @note this function exists here instead of inside the callback function
* due to the usages, i.e. we not only provide service call but also
Expand Down Expand Up @@ -141,6 +143,10 @@ class DJISDKNode
//! Mobile Data Service
bool sendToMobileCallback(dji_sdk::SendMobileData::Request& request,
dji_sdk::SendMobileData::Response& response);
//! Query Drone FW version
bool queryVersionCallback(dji_sdk::QueryDroneVersion::Request& request,
dji_sdk::QueryDroneVersion::Response& response);

bool cameraActionCallback(dji_sdk::CameraAction::Request& request,
dji_sdk::CameraAction::Response& response);
//! mfio service callbacks
Expand Down Expand Up @@ -241,10 +247,12 @@ class DJISDKNode
ros::ServiceServer hotpoint_setSpeed_server;
ros::ServiceServer hotpoint_resetYaw_server;
ros::ServiceServer hotpoint_setRadius_server;

// send data to mobile device
ros::ServiceServer send_to_mobile_server;
//! hardsync service
ros::ServiceServer set_hardsync_server;
//! Query FW version of FC
ros::ServiceServer query_version_server;

//! flight control subscribers
ros::Subscriber flight_control_sub;
Expand All @@ -266,6 +274,7 @@ class DJISDKNode
ros::Publisher flight_status_publisher;
ros::Publisher gps_health_publisher;
ros::Publisher gps_position_publisher;
ros::Publisher height_publisher;
ros::Publisher velocity_publisher;
ros::Publisher from_mobile_data_publisher;
ros::Publisher gimbal_angle_publisher;
Expand Down Expand Up @@ -313,6 +322,8 @@ class DJISDKNode
bool align_time_with_FC;

void alignRosTimeWithFlightController(ros::Time now_time, uint32_t tick);
void setUpM100DefaultFreq(uint8_t freq[16]);
void setUpA3N3DefaultFreq(uint8_t freq[16]);
};

#endif // DJI_SDK_NODE_MAIN_H
5 changes: 4 additions & 1 deletion dji_sdk/msg/Gimbal.msg
@@ -1,5 +1,8 @@
Header header
# ts is the time it takes to achieve the desired angle,
# so the shorter the time, the faster the gimbal rotates.
int32 ts # sec

# Mode is 1 byte size:
# Bit #: | Set to 0: | Set to 1:
# ----------- | ------------------------------------- | -------------------------------------
Expand All @@ -11,6 +14,6 @@ int32 ts # sec
# bit 3 |Pitch invalid bit, the same as bit[1] | Pitch invalid bit, the same as bit[1]
# bit [4:7] | bit [4:7]: reserved, set to be 0 |
uint8 mode
float32 pitch # rads
float32 yaw # rads
float32 pitch # rads
float32 roll # rads

0 comments on commit 45ec1b2

Please sign in to comment.