Skip to content

Conversation

adambrett40
Copy link
Contributor

@adambrett40 adambrett40 commented Feb 24, 2025

Description

  • caching operations are done asynchronously
  • updated ros2 node to run virtual iridium in the background, so the node starts properly in dev mode

Verification

  • Unit test ensures cache is correctly initialized and updated
  • ros2 node retrieves and publishes cached data on startup
    To view what's published on the global_path topic, need to do export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/workspaces/sailbot_workspace/install/lib in the terminal first as below (thanks Sean :))

Resources

@SPDonaghy
Copy link
Contributor

SPDonaghy commented Feb 26, 2025

try running this command in the terminal before launching ros
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/workspaces/sailbot_workspace/install/lib

I'm not sure why this is not on the path anymore, but hopefully this works as a temporary fix!

@adambrett40 adambrett40 marked this pull request as ready for review February 27, 2025 10:01
{
"label": "setup",
"detail": "Set up the workspace",
"type": "shell",
"command": "./scripts/setup.sh",
"problemMatcher": []
}

],
"inputs": [
{
Copy link
Contributor

Choose a reason for hiding this comment

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

could you revert these small formatting changes? they dont seem to be related
if another lead request this be done please include it in another PR

return std::async(std::launch::async, [receivedDataBuffer] {
try {
std::filesystem::path cache{CACHE_PATH};
if (std::filesystem::exists(cache)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

please look into creating the cache file in the constructor of LocalTransceiver, and deleting the file in the destructor of LocalTransceiver

is it possible to clear the file and write it directly instead of creating another file and renaming it? please look into using std::ios::trunc if possible

@@ -337,6 +369,18 @@ custom_interfaces::msg::Path LocalTransceiver::parseInMsg(const std::string & ms
return soln;
}

std::optional<custom_interfaces::msg::Path> LocalTransceiver::getCache()
Copy link
Contributor

Choose a reason for hiding this comment

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

please make this function async as well

@@ -91,6 +104,9 @@ class LocalTransceiverIntf : public NetNode
sub_local_path_data = this->create_subscription<custom_interfaces::msg::LPathData>(
ros_topics::LOCAL_PATH, ROS_Q_SIZE,
std::bind(&LocalTransceiverIntf::sub_local_path_data_cb, this, std::placeholders::_1));

std::thread cache_thread(&LocalTransceiverIntf::getAndPublishCache, this);
Copy link
Contributor

Choose a reason for hiding this comment

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

since the get function is now async, we do not need to launch it in a thread
please take a look at the 2019 answer in https://stackoverflow.com/questions/5645375/how-do-i-make-a-function-asynchronous-in-c

@@ -302,6 +332,8 @@ custom_interfaces::msg::Path LocalTransceiver::receive()
break;
}

cacheGlobalWaypointsAsync(receivedDataBuffer);
Copy link
Contributor

Choose a reason for hiding this comment

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

https://stackoverflow.com/questions/5645375/how-do-i-make-a-function-asynchronous-in-c

try the 2019 answer in the link above and see if that works

Copy link
Contributor

@samdai01 samdai01 left a comment

Choose a reason for hiding this comment

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

see comments

@samdai01 samdai01 requested a review from Jng468 March 15, 2025 17:04
@samdai01 samdai01 added net Network Systems team local transceiver Pertaining to the Network Systems Local Transceiver labels Mar 15, 2025
@SPDonaghy SPDonaghy removed their request for review April 3, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
local transceiver Pertaining to the Network Systems Local Transceiver net Network Systems team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Global Waypoint Cache
3 participants