lastdestination module
Last Destination
This module provides a ROS node that tracks and serves the last destination coordinates based on the latest goal received from a navigation or planning system. The node exposes a service to return the most recent destination coordinates (x, y), and subscribes to a topic for receiving goal messages to update the destination coordinates.
The main functionality involves: 1. Subscribing to a goal topic. 2. Updating destination coordinates when a new goal is received. 3. Exposing a service to return the last known destination coordinates on request.
Dependencies:
rospy: The Python library for ROS (Robot Operating System) interaction.
assignment2_part1.msg: Custom message definitions used in the project.
assignment2_part1.srv: Custom service definitions used in the project.
- lastdestination.clbk_goal(msg)[source]
Callback function for subscribing to the ‘/reaching_goal/goal’ topic.
This function is triggered whenever a new goal message is received on the topic. It updates the global variables holding the last known destination coordinates with the new goal’s position values (x, y).
Parameters: msg (PlanningActionGoal):
The message received from the ‘goal’ topic containing the target position for the goal.
This function updates the global variables ‘last_destination_x’ and ‘last_destination_y’.
- lastdestination.clbk_service(request)[source]
Callback function for the ROS service ‘last_destination’.
This function gets triggered whenever the service is called. It returns the last known destination coordinates (x, y) stored globally. These coordinates are updated whenever a new goal is received from the ‘goal’ topic.
Parameters: request (last_destinationRequest):
The service request object (though unused here).
Returns: last_destinationResponse:
A response object containing the last known x and y coordinates.
This function does not perform any modification to the stored coordinates, it simply returns the most recent ones available.
- lastdestination.main()[source]
Main entry point of the node.
This function initializes the ROS node, sets up the service and the subscriber, and enters the ROS event loop to handle service requests and message reception.
It initializes the ‘last_destination’ service with the callback function ‘clbk_service’. It also subscribes to the ‘/reaching_goal/goal’ topic to listen for new goal messages and calls the ‘clbk_goal’ callback when a new message is received.
This function ensures that the node continues to run, processing service calls and topic messages until the node is shut down.