Skip to content

Conversation

@Aayush1104
Copy link
Contributor

No description provided.

Copy link
Member

@maxlou05 maxlou05 left a comment

Choose a reason for hiding this comment

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

Reviewed

Sends a STATUSTEXT message to the vehicle.
"""
message_bytes = message.encode("utf-8")
msg = vehicle.message_factory.statustext_encode(severity, message_bytes)
Copy link
Member

Choose a reason for hiding this comment

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

Can you check to make sure there is a target_system and target_component parameter? Please use the ones specified in the example. Also, are you able to test this? Could you write an integration test that just runs this (ie sends a bunch of messages)? You will connect to mission planner just as described in the example, and then see if you can see the messages in mission planner. (Let me know if you need help testing)

Copy link
Member

@maxlou05 maxlou05 left a comment

Choose a reason for hiding this comment

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

Reviewed


def send_statustext_msg(
self,
vehicle: dronekit.Vehicle,
Copy link
Member

Choose a reason for hiding this comment

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

Remove this from the function signature, you should use self.drone as the vehicle.

controller.send_statustext_msg(controller.drone, msg, mavutil.mavlink.MAV_SEVERITY_INFO)
time.sleep(1) # Wait 1 second between messages

controller.drone.close()
Copy link
Member

Choose a reason for hiding this comment

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

Probably don't need this, since I think you're not supposed to access controller.drone outside the class.

Copy link
Member

@maxlou05 maxlou05 left a comment

Choose a reason for hiding this comment

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

Reviewed

controller.send_statustext_msg("")
else:
print("Failed to get odometry")
controller.send_statustext_msg("Failed to get odometry")
Copy link
Member

Choose a reason for hiding this comment

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

Leave this as a regular print, as we would want to see on the terminal what errors we get

controller.send_statustext_msg("alt: " + str(home.altitude))
else:
print("Failed to get home position")
controller.send_statustext_msg("Failed to get home position")
Copy link
Member

Choose a reason for hiding this comment

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

Leave as print

Comment on lines 54 to 58
controller.send_statustext_msg("Downloaded commands:")
for command in commands:
print(command)
controller.send_statustext_msg(str(command))
else:
print("Failed to download commands.")
controller.send_statustext_msg("Failed to download commands.")
Copy link
Member

Choose a reason for hiding this comment

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

Leave these as prints

controller.send_statustext_msg("next waypoint alt: " + str(next_waypoint.altitude))
else:
print("Failed to get next waypoint.")
controller.send_statustext_msg("Failed to get next waypoint.")
Copy link
Member

Choose a reason for hiding this comment

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

leave as print

result, home = controller.get_home_position(TIMEOUT)
if not result:
print("Failed to get home position")
controller.send_statustext_msg("Failed to get home position")
Copy link
Member

Choose a reason for hiding this comment

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

leave as print

result = controller.upload_land_command(home.latitude, home.longitude)
if not result:
print("Could not upload land command.")
controller.send_statustext_msg("Could not upload land command.")
Copy link
Member

Choose a reason for hiding this comment

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

Leave as print

Copy link
Member

@maxlou05 maxlou05 left a comment

Choose a reason for hiding this comment

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

Reviewed

success, controller = FlightController.create("tcp:localhost:5672")
if not success:
print("Failed to connect")
return 1
Copy link
Member

Choose a reason for hiding this comment

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

Could you make this return -1 instead?

Main function.
"""
# Connect to the vehicle
success, controller = FlightController.create("tcp:localhost:5672")
Copy link
Member

Choose a reason for hiding this comment

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

Can you make the address a global variable like in test_flight_controller.py?


for msg in messages:
controller.send_statustext_msg(msg, mavutil.mavlink.MAV_SEVERITY_INFO)
time.sleep(1) # Wait 1 second between messages
Copy link
Member

Choose a reason for hiding this comment

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

Can you make DELAY a global variable like in test_flight_controller.py?

Copy link
Member

@maxlou05 maxlou05 left a comment

Choose a reason for hiding this comment

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

Conditionally approved


for msg in messages:
controller.send_statustext_msg(msg, mavutil.mavlink.MAV_SEVERITY_INFO)
time.sleep(DELAY_TIME) # Wait 1 second between messages
Copy link
Member

Choose a reason for hiding this comment

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

You can remove the comment here

from pymavlink import mavutil

from modules.mavlink.flight_controller import FlightController

Copy link
Member

Choose a reason for hiding this comment

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

Add one more space here (2 spaces to separate import from constants)

@lilyjge lilyjge merged commit c7ab98a into main Dec 25, 2024
1 check passed
@lilyjge lilyjge deleted the send-statustext-msg branch December 25, 2024 02:20
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.

4 participants