-
Notifications
You must be signed in to change notification settings - Fork 37
Using message_encode_decode to send MAVlink messages #245
Using message_encode_decode to send MAVlink messages #245
Conversation
…k messages to flight controller
maxlou05
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed
| 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 |
There was a problem hiding this comment.
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
| 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}") | ||
|
|
There was a problem hiding this comment.
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.
| 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}") | ||
|
|
There was a problem hiding this comment.
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.
maxlou05
left a comment
There was a problem hiding this 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( |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
…code-to-send-MAVlink-message
* Create ultralytics config class * Add configs to target detection pipeline * Organize YAML and improve parsing * Reorder args * Update integration test
…ttps://github.com/UWARG/computer-vision-python into Use-message_encode_decode-to-send-MAVlink-message
…ttps://github.com/UWARG/computer-vision-python into Use-message_encode_decode-to-send-MAVlink-message
…ttps://github.com/UWARG/computer-vision-python into Use-message_encode_decode-to-send-MAVlink-message
Used the following functions in data_encoding and flight_controller.py to send MAVlink messages to the flight controller via the flight interface worker: