Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.

Conversation

@HermanG05
Copy link
Contributor

Used the following functions in data_encoding and flight_controller.py to send MAVlink messages to the flight controller via the flight interface worker:

  • encode_metadata()
  • encode_position_global()
  • send_statustext_msg()

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

Comment on lines 13 to 16
from ..common.modules.mavlink import flight_controller
from ..common.modules.data_encoding import message_encoding_decoding
from ..common.modules.data_encoding import metadata_encoding_decoding
from ..common.modules import position_global
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 put them in alphabetical order

Comment on lines 67 to 82
result, message_flight_controller = flight_controller.FlightController.create(
address, baud_rate
)
if not result:
local_logger.error("Worker failed to create class object", True)
return

result, metadata = metadata_encoding_decoding.encode_metadata(
f"{worker_name}", coordinates_input_queue.queue.qsize()
)
if not result:
local_logger.error("Failed to encode metadata", True)
return

message_flight_controller.send_statustext_msg(f"{metadata}")

Copy link
Member

Choose a reason for hiding this comment

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

We cannot create another instance of FlightController here, you need to add an input in the FlightInterface.run() method, input the list, and then do this in the FlightInterface class' run() which has a FlightController already.

Comment on lines 88 to 105
coordinate = coordinates_input_queue.queue.get()
if coordinate is None:
local_logger.info("Received type None, exiting")
break

if not isinstance(coordinate, position_global.PositionGlobal):
local_logger.warning(f"Skipping unexpected input: {coordinate}")
continue

result, message = message_encoding_decoding.encode_position_global(
f"{worker_name}", coordinate
)
if not result:
local_logger.error("Failed to encode PositionGlobal object", True)
continue

message_flight_controller.send_statustext_msg(f"{message}")

Copy link
Member

Choose a reason for hiding this comment

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

The way this works is communications will send a list, and you need to edit the last line in communcations.py to return objects_in_world_global rather than the same thing it got as input. This list will be the input into FlightInterface. Then, the metadata message is on how long this list is, and then you send each element of this list (GPS coords) one by one.

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

mp_manager,
QUEUE_MAX_SIZE,
)
communications_to_flight_interface_queue = queue_proxy_wrapper.QueueProxyWrapper(
Copy link
Member

Choose a reason for hiding this comment

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

Add this queue to communication's output queue


output_queue.queue.put(value)
result, metadata = metadata_encoding_decoding.encode_metadata(
f"{worker_name}", len(list_of_messages)
Copy link
Member

Choose a reason for hiding this comment

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

Instead of using a worker_name input, just hard code "communications_worker" here. It's my bad that the common's function doesn't take in the enum as an input, I forgot about that part. We'll change that later, or you can do that right now?

result = self.controller.send_statustext_msg(message)
if not result:
self.__logger.error("Failed to send statustext message", True)
return False, None
Copy link
Member

Choose a reason for hiding this comment

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

Don't need to fail here, just log error. This will make data merge think we didn't get a odometry object

time.sleep(period)

result, value = interface.run()
coordinate = coordinates_input_queue.queue.get()
Copy link
Member

Choose a reason for hiding this comment

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

I think there is a get_no_wait(), and then if it's None, means queue is empty. If queue is empty, skip getting and just run with inputting None for coordinate. Then, flight interface will be able to run without stalling for communications worker.

coordinate = coordinates_input_queue.queue.get()
if coordinate is None:
local_logger.info("Received type None, exiting")
break
Copy link
Member

Choose a reason for hiding this comment

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

Don't exit, just get odometry only (see above) since we'll need to get many odometries before we can send 1 message

@HermanG05 HermanG05 closed this Jan 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants