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 option to send MAVLink heartbeat messages #170

Merged
merged 1 commit into from
Nov 2, 2023

Conversation

ddd999
Copy link

@ddd999 ddd999 commented Oct 15, 2023

This allows Rpanion to send out heartbeat messages advertising itself on the MAVLink network as a companion computer which is a component of the vehicle.

The changes to sendData() and the addition of sendHeartbeat() are a first step toward being able to respond to MAVLink commands, and advertising other devices that can accept commands (i.e., cameras).

@stephendade
Copy link
Owner

Nice! I'll have time later in the week to take a look.

Copy link
Owner

@stephendade stephendade left a comment

Choose a reason for hiding this comment

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

Thanks for this - I've done a review on the specific (small) issues).

More generally:

  • Can you switch to using spaces-for-tabs, to maintain consistency with the rest of the codebase
  • There's some failing tests that need to be looked at
  • For any existing functions in mavManage that use sendData, default them to using the minimal.MavComponent.ONBOARD_COMPUTER componentID for consistency.

@@ -240,6 +247,28 @@ class mavManager {
})
}

sendHeartbeat ( type = mavheader.MAV_TYPE_ONBOARD_CONTROLLER,
Copy link
Owner

Choose a reason for hiding this comment

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

type = minimal.MavType.ONBOARD_CONTROLLER

Copy link
Author

Choose a reason for hiding this comment

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

Done

@@ -240,6 +247,28 @@ class mavManager {
})
}

sendHeartbeat ( type = mavheader.MAV_TYPE_ONBOARD_CONTROLLER,
autopilot = mavheader.MAV_AUTOPILOT_INVALID,
Copy link
Owner

Choose a reason for hiding this comment

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

autopilot = minimal.MavAutopilot.INVALID

Copy link
Author

Choose a reason for hiding this comment

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

Done

heartbeatMessage.systemStatus = systemStatus
heartbeatMessage.mavlinkVersion = this.version

this.sendData(heartbeatMessage, system, mavheader.MAV_COMP_ID_ONBOARD_COMPUTER)
Copy link
Owner

Choose a reason for hiding this comment

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

minimal.MavComponent.ONBOARD_COMPUTER

Copy link
Author

Choose a reason for hiding this comment

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

Done

baseMode = 0,
customMode = 0,
systemStatus = 0,
system = this.targetSystem,
Copy link
Owner

Choose a reason for hiding this comment

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

this.targetSystem and this.targetComponent are the flight controller (the target) not Rpanion. Since Rpanion is (assumed to be) on the vehicle, it makes sense to use this.targetSystem. But we'll need our own component ID, not the flight controller's component ID
I think you meant for the component argument to be passed down to line 269? Then use the default component here as minimal.MavComponent.ONBOARD_COMPUTER

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I had changed line 269 to have the component argument passed down but somehow it didn't make it into this commit. Fixed.

@@ -213,17 +215,22 @@ class mavManager {
this.udpStream.bind(this.inudpPort, this.inudpIP)
}

sendData (msg) {
sendData (msg, vehicle = 255, component = 1) {
Copy link
Owner

Choose a reason for hiding this comment

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

Since we can safely assume the Rpanion will always be on the vehicle, just use this.targetSystem instead of an argument in the function.

Copy link
Author

Choose a reason for hiding this comment

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

Done

ddd999 pushed a commit to ddd999/Rpanion-server that referenced this pull request Oct 22, 2023
@ddd999
Copy link
Author

ddd999 commented Oct 22, 2023

Thanks for the review! I believe the latest changes to the branch will resolve the issues that you pointed out, and I've changed my editor setup to hopefully stay consistent with tab formatting.

@stephendade
Copy link
Owner

Thanks for the changes.

There are a few tabs-for-spaces in the PR which you missed.

I missed in my review that I'd like the "Enable Heartbeats" checkbox to be moved down to the "Other Options" section.

Could you also flatten the PR, so it doesn't have any merges?

ddd999 pushed a commit to ddd999/Rpanion-server that referenced this pull request Oct 29, 2023
@ddd999 ddd999 force-pushed the heartbeat branch 4 times, most recently from 5f64149 to 4ecee29 Compare October 29, 2023 02:12
@ddd999
Copy link
Author

ddd999 commented Oct 29, 2023

Thanks for the changes.

There are a few tabs-for-spaces in the PR which you missed.

I missed in my review that I'd like the "Enable Heartbeats" checkbox to be moved down to the "Other Options" section.

Could you also flatten the PR, so it doesn't have any merges?

I think I have taken care of all that now. I'm definitely still learning here so thanks for your patience.

@stephendade
Copy link
Owner

There appear to be some references to a "cameracontroller.js" in./src/Approuter.js? I think you may have merged in a different branch?

@ddd999
Copy link
Author

ddd999 commented Oct 29, 2023

Sorry about that. I thought I had fixed that particular mess-up, but I guess missed a couple of spots. Should be fixed now.

@stephendade
Copy link
Owner

Great. That all looks good! Merging...

@stephendade stephendade merged commit 278fcc1 into stephendade:master Nov 2, 2023
7 checks passed
@ddd999 ddd999 deleted the heartbeat branch November 7, 2023 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants