@@ -2248,30 +2248,31 @@ def get_action_details(action_type: str) -> dict:
22482248 return result
22492249
22502250
2251+
22512252@mcp .tool (
22522253 description = (
2253- "Get action status for a specific action type . Works only with ROS 2.\n "
2254+ "Get action status for a specific action name . Works only with ROS 2.\n "
22542255 "Example:\n "
2255- "get_action_status('action_tutorials_interfaces/action/Fibonacci ')"
2256+ "get_action_status('/fibonacci ')"
22562257 )
22572258)
2258- def get_action_status (action_type : str ) -> dict :
2259+ def get_action_status (action_name : str ) -> dict :
22592260 """
2260- Get action status for a specific action type . Works only with ROS 2.
2261+ Get action status for a specific action name . Works only with ROS 2.
22612262
22622263 Args:
2263- action_type (str): The action type (e.g., 'action_tutorials_interfaces/action/Fibonacci ')
2264+ action_name (str): The action name (e.g., '/fibonacci ')
22642265
22652266 Returns:
22662267 dict: Contains action status information including active goals and their status.
22672268 """
22682269 # Validate input
2269- if not action_type or not action_type .strip ():
2270- return {"error" : "Action type cannot be empty" }
2270+ if not action_name or not action_name .strip ():
2271+ return {"error" : "Action name cannot be empty" }
22712272
2272- # Extract action name from action type
2273- # For example: 'action_tutorials_interfaces/action/Fibonacci' -> '/fibonacci'
2274- action_name = f"/{ action_type . split ( '/' )[ - 1 ]. lower () } "
2273+ # Ensure action name starts with /
2274+ if not action_name . startswith ( '/' ):
2275+ action_name = f"/{ action_name } "
22752276
22762277 # Try to get action status by subscribing to the status topic
22772278 status_topic = f"{ action_name } /_action/status"
@@ -2290,7 +2291,6 @@ def get_action_status(action_type: str) -> dict:
22902291 send_error = ws_manager .send (message )
22912292 if send_error :
22922293 return {
2293- "action_type" : action_type ,
22942294 "action_name" : action_name ,
22952295 "success" : False ,
22962296 "error" : f"Failed to subscribe to status topic: { send_error } " ,
@@ -2300,7 +2300,6 @@ def get_action_status(action_type: str) -> dict:
23002300 response = ws_manager .receive (timeout = 3.0 )
23012301 if not response :
23022302 return {
2303- "action_type" : action_type ,
23042303 "action_name" : action_name ,
23052304 "success" : False ,
23062305 "error" : "No response from action status topic" ,
@@ -2313,7 +2312,6 @@ def get_action_status(action_type: str) -> dict:
23132312
23142313 if "msg" not in response_data or "status_list" not in response_data ["msg" ]:
23152314 return {
2316- "action_type" : action_type ,
23172315 "action_name" : action_name ,
23182316 "success" : True ,
23192317 "active_goals" : [],
@@ -2342,7 +2340,6 @@ def get_action_status(action_type: str) -> dict:
23422340 })
23432341
23442342 return {
2345- "action_type" : action_type ,
23462343 "action_name" : action_name ,
23472344 "success" : True ,
23482345 "active_goals" : active_goals ,
@@ -2354,7 +2351,6 @@ def get_action_status(action_type: str) -> dict:
23542351 return {"error" : f"Failed to parse status response: { str (e )} " }
23552352 except Exception as e :
23562353 return {
2357- "action_type" : action_type ,
23582354 "action_name" : action_name ,
23592355 "success" : False ,
23602356 "error" : f"Failed to get action status: { str (e )} " ,
0 commit comments