Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Takeoff and Land #627

Merged
merged 7 commits into from
Dec 11, 2023

Conversation

ericjohnson97
Copy link
Contributor

@ericjohnson97 ericjohnson97 commented Dec 8, 2023

This merge request adds a mini widget that commands takeoff and land for an aerial vehicle.

  • When on ground it shows and commands Takeoff
  • when in air it shows and commands Land

closes #579

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@rafaellehmkuhl
Copy link
Member

Nice addition!
Will start reviewing today and continue tomorrow!

@ericjohnson97
Copy link
Contributor Author

Thanks @rafaellehmkuhl !

for reference I have been using this docker-compose file to test

version: "3.3"
services:
  mavlink2rest:
    image: ericjohnson97/iq_sim_mavlink2rest:t0.11.12
    network_mode: host
    environment:
      - MAVLINK_SRC=udpin:127.0.0.1:14551
      - SERVER_PORT=0.0.0.0:6040

  mavp2p:
    image: ericjohnson97/iq_sim_server_mavp2p:latest
    network_mode: "host"
    environment:
      CMD: "./mavp2p tcpc:127.0.0.1:5760 udpc:127.0.0.1:14550 udpc:127.0.0.1:14551"
    restart: on-failure

  ardupilot:
    image: ericjohnson97/iq_sim_server_ardupilot:Copter-4.2.2 
    network_mode: "host"
    restart: on-failure
    environment:
      VEHICLE: Copter
      MODEL: + 

Copy link
Member

@rafaellehmkuhl rafaellehmkuhl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eric, I have made some change requests that I think can improve on this patch.

Let me also say that it is super exciting receiving this contribution. It's cool to see the codebase being challenged with the addition of a vehicle very different then the ones it was originally built with.

Next thing I'm gonna do is install sitl to start trying quads with cockpit 😄

src/libs/vehicle/ardupilot/ardupilot.ts Outdated Show resolved Hide resolved
src/libs/vehicle/ardupilot/ardupilot.ts Outdated Show resolved Hide resolved
src/libs/vehicle/ardupilot/ardupilot.ts Outdated Show resolved Hide resolved
src/libs/vehicle/ardupilot/ardupilot.ts Outdated Show resolved Hide resolved
takeoff(): boolean {
this.setMode(this.modesAvailable().get('GUIDED') as Modes)
this.arm()
this._takeoff(10)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we wait after setting guided mode and also after arming to send the takeoff command, or is it ok to send them continuously?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be mostly ok

@@ -298,6 +300,8 @@ export abstract class ArduPilotVehicle<Modes> extends Vehicle.AbstractVehicle<Mo

this._isArmed = Boolean(heartbeat.base_mode.bits & MavModeFlag.MAV_MODE_FLAG_SAFETY_ARMED)
this.onArm.emit()
this._flying = heartbeat.system_status.type === MavState.MAV_STATE_ACTIVE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this MAV_STATE_ACTIVE shared between all vehicles? @ES-Alexander maybe can help answering that one.

If so, maybe we can have a better name that also works for subs/boats/rovers, but if we don't find one, flying is also ok. I usually say or subs are flying 😅

src/libs/vehicle/ardupilot/ardupilot.ts Outdated Show resolved Hide resolved
src/libs/vehicle/ardupilot/ardupilot.ts Outdated Show resolved Hide resolved
@ericjohnson97
Copy link
Contributor Author

@rafaellehmkuhl Thanks for the feedback! I have off tomorrow, so I am planning on working through your comments tomorrow

Copy link
Member

@patrickelectric patrickelectric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor request and points.

src/libs/vehicle/ardupilot/ardupilot.ts Outdated Show resolved Hide resolved
src/libs/vehicle/ardupilot/ardupilot.ts Outdated Show resolved Hide resolved
src/libs/vehicle/ardupilot/ardupilot.ts Outdated Show resolved Hide resolved
src/libs/vehicle/ardupilot/ardupilot.ts Outdated Show resolved Hide resolved
Comment on lines +157 to +169
/**
* Takeoff the vehicle
*/
function takeoff(): void {
mainVehicle.value?.takeoff()
}

/**
* Land the vehicle
*/
function land(): void {
mainVehicle.value?.land()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mixed feelings with such functions on mainVehicle, that's not a blocker, but just something for us to have in mind for future rework.

The idea of cockpit is to be generic, the concept of takeoff and landing applies mostly to aerial vehicles, having such functions here in mainVehicle is a bit complicated.

I would recommend in the future for us to have a generic callback map that the vehicle could specify such "logic". We need to put more thought on it, there is now no way for us to check if the vehicle does support such functions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Same thoughts.

But as we don't have discussed yet how to go on that, I think we should just add that now and discuss changes after.

@rafaellehmkuhl
Copy link
Member

@ericjohnson97 I forgot to mention, but I saw the takeoff and land functions were returning booleans instead of void and forgot to comment in the review.

@ericjohnson97
Copy link
Contributor Author

@ericjohnson97 I forgot to mention, but I saw the takeoff and land functions were returning booleans instead of void and forgot to comment in the review.

I was following the arm function as a guide. I was also originally hoping to have the command_ack drive the true false response, but I don't think I will any more.

  /**
   * Arm vehicle
   * @returns {boolean}
   */
  arm(): boolean {
    this._arm(true)
    return true
  }

would you like the functions to be void still?

also I noticed that takeoff is still async, which I now want to change to just be synchronous.

@rafaellehmkuhl
Copy link
Member

@ericjohnson97 I forgot to mention, but I saw the takeoff and land functions were returning booleans instead of void and forgot to comment in the review.

I was following the arm function as a guide. I was also originally hoping to have the command_ack drive the true false response, but I don't think I will any more.


  /**

   * Arm vehicle

   * @returns {boolean}

   */

  arm(): boolean {

    this._arm(true)

    return true

  }



would you like the functions to be void still?

also I noticed that takeoff is still async, which I now want to change to just be synchronous.

Got it. I think you can leave as Boolean and we can review them all together in the future.

I've been trying to stick with the javascript approach (void + throw), but indeed some of our code still has a c++ similar approach (return Boolean).

@ericjohnson97
Copy link
Contributor Author

@rafaellehmkuhl I see. I am more familiar with the c++ methodology. I think the void throw method is fine. I'll change the functions and make takeoff synchronous now

@rafaellehmkuhl
Copy link
Member

@rafaellehmkuhl I see. I am more familiar with the c++ methodology. I think the void throw method is fine. I'll change the functions and make takeoff synchronous now

Cool!
I'm going camping this weekend, so I will be offline, but if no one reviews your PR by monday I will do it.
Again, thanks for the contribution. I'm excited that we will start testing cockpit with UAVs.

@ericjohnson97
Copy link
Contributor Author

@rafaellehmkuhl Have fun! we can resume the review when you get back.

@patrickelectric
Copy link
Member

@ericjohnson97 I forgot to mention, but I saw the takeoff and land functions were returning booleans instead of void and forgot to comment in the review.

I was following the arm function as a guide. I was also originally hoping to have the command_ack drive the true false response, but I don't think I will any more.


  /**

   * Arm vehicle

   * @returns {boolean}

   */

  arm(): boolean {

    this._arm(true)

    return true

  }

would you like the functions to be void still?
also I noticed that takeoff is still async, which I now want to change to just be synchronous.

Got it. I think you can leave as Boolean and we can review them all together in the future.

I've been trying to stick with the javascript approach (void + throw), but indeed some of our code still has a c++ similar approach (return Boolean).

The reason behind that is that a throw can get in an unhandle behavior and there is no checks on the typescript linters to see if you are not dealing with a thrown, creating unsafe code.
A GCS is a critical application, it should be ok to throw for the frontend, but not in vehicle logic, that should be avoided at all.

@patrickelectric patrickelectric changed the title Feature Takeoff and Land Add Takeoff and Land Dec 11, 2023
@patrickelectric patrickelectric merged commit a43b0be into bluerobotics:master Dec 11, 2023
7 checks passed
@rafaellehmkuhl
Copy link
Member

@ericjohnson97 I forgot to mention, but I saw the takeoff and land functions were returning booleans instead of void and forgot to comment in the review.

I was following the arm function as a guide. I was also originally hoping to have the command_ack drive the true false response, but I don't think I will any more.


  /**

   * Arm vehicle

   * @returns {boolean}

   */

  arm(): boolean {

    this._arm(true)

    return true

  }

would you like the functions to be void still?
also I noticed that takeoff is still async, which I now want to change to just be synchronous.

Got it. I think you can leave as Boolean and we can review them all together in the future.
I've been trying to stick with the javascript approach (void + throw), but indeed some of our code still has a c++ similar approach (return Boolean).

The reason behind that is that a throw can get in an unhandle behavior and there is no checks on the typescript linters to see if you are not dealing with a thrown, creating unsafe code. A GCS is a critical application, it should be ok to throw for the frontend, but not in vehicle logic, that should be avoided at all.

Only the calling function will get unhandled, not the entire application. In this case, the takeoff button wouldn't call a takeoff and that's it.

@ES-Alexander ES-Alexander added the docs-needed Change needs to be documented label Dec 12, 2023
ES-Alexander added a commit to ES-Alexander/ardusub-zola that referenced this pull request Dec 12, 2023
ES-Alexander added a commit to ES-Alexander/ardusub-zola that referenced this pull request Dec 12, 2023
ES-Alexander added a commit to ES-Alexander/ardusub-zola that referenced this pull request Dec 12, 2023
ES-Alexander added a commit to ES-Alexander/ardusub-zola that referenced this pull request Dec 13, 2023
ES-Alexander added a commit to bluerobotics/ardusub-zola that referenced this pull request Dec 13, 2023
ES-Alexander added a commit to bluerobotics/ardusub-zola that referenced this pull request Dec 13, 2023
ES-Alexander added a commit to bluerobotics/ardusub-zola that referenced this pull request Dec 13, 2023
@ES-Alexander ES-Alexander added docs-complete Change documentation has been completed and removed docs-needed Change needs to be documented labels Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-complete Change documentation has been completed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Takeoff - Land Widget
4 participants