Android Question Help w/ Setting WaypointMissionBuilder.HeadingMode

John Calhoun

Member
Licensed User
I am developing a DJI mission app on a Nexus 7 using B4A. It is going great.

I could, however, use some help with setting WaypointMissionBuilder.HeadingMode. At mission start I am initializing the WaypointMissionBuilder, setting the required AutoFlightSpeed and MaxFlightSpeed, and attempting to set the HeadingMode to USING_WAYPOINT_HEADING so I can give the user the option of setting the heading at each waypoint. Code excerpt:


Dim WaypointMissionBuilder As DJIWaypointMissionBuilder

Sub btnStartMission_Click
btnStartMission.Enabled = False
WaypointMissionBuilder.Initialize
WaypointMissionBuilder.AutoFlightSpeed = 10
WaypointMissionBuilder.MaxFlightSpeed = 15
WaypointMissionBuilder.HeadingMode???

How do I set the HeadingMode or am I missing how this is supposed to work?

Thanks...
 

DonManfred

Expert
Licensed User
Longtime User
Please use [CODE]code here...[/CODE] tags when posting code.

codetag001.png

codetag002.png

codetag003.png
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
How do I set the HeadingMode or am I missing how this is supposed to work?
there are no methods to set/get the headingmode in the Libarys code.
You need to use Javaobject to set the Heading. Or you adapt the source and compile a new libarary version.

you can try to add this to WaypointMissionOperatorWrapper.java and compile again....

B4X:
        public WaypointMissionHeadingMode getHeadingMode() {
            return getObject().getHeadingMode();
        }
        public void setHeadingMode(WaypointMissionHeadingMode mode) {
            getObject().headingMode(mode);
        }
        public void setHeadingModeAUTO() {
            getObject().headingMode(WaypointMissionHeadingMode.AUTO);
        }
        public void setHeadingModeCONTROL_BY_REMOTE_CONTROLLER() {
            getObject().headingMode(WaypointMissionHeadingMode.CONTROL_BY_REMOTE_CONTROLLER);
        }
        public void setHeadingModeTOWARD_POINT_OF_INTEREST() {
            getObject().headingMode(WaypointMissionHeadingMode.TOWARD_POINT_OF_INTEREST);
        }
        public void setHeadingModeUSING_INITIAL_DIRECTION() {
            getObject().headingMode(WaypointMissionHeadingMode.USING_INITIAL_DIRECTION);
        }
        public void setHeadingModeUSING_WAYPOINT_HEADING() {
            getObject().headingMode(WaypointMissionHeadingMode.USING_WAYPOINT_HEADING);
        }

There may be a better way to use this enum but i always have problems with enums so i use such code usually...
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
There may be a better way to use this enum but i always have problems with enums so i use such code usually...
Enums are very simple to set with JavaObject. Just treat them as strings:

B4X:
Dim jo As JavaObject = WaypointMissionBuilder
jo.RunMethod("headingMode", Array("USING_WAYPOINT_HEADING"))
 
Upvote 0
Top