Skip to content

Commit

Permalink
fixed usage of action and services
Browse files Browse the repository at this point in the history
  • Loading branch information
alekskl01 committed Feb 21, 2024
1 parent 7367a6a commit 4feb58d
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions navigation/waypoint_manager/scripts/waypoint_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@
from rclpy.action import ActionClient
from rclpy.node import Node

from vortex_msgs.msg import (
LosPathFollowingAction,
LosPathFollowingGoal,
LosPathFollowingResult,
LosPathFollowingFeedback,
)
from vortex_msgs.action import LosPathFollowing

from vortex_msgs.srv import Waypoint, WaypointRequest, WaypointResponse
from vortex_msgs.srv import Waypoint
from nav_msgs.msg import Path
from geometry_msgs.msg import PoseStamped, Point


class WaypointManager:
class WaypointManager(Node):
"""
Nodes created:
WaypointManager
Expand All @@ -29,7 +24,7 @@ def __init__(self):
self.waypoint_list = []

## Action client
self.action_client = ActionClient(LosPathFollowingAction, 'guidance/los_action_server')
self.action_client = ActionClient(LosPathFollowing, 'guidance/los_action_server')
while not self.action_client.wait_for_service(timeout_sec=1.0):
self.get_logger().info('Action server not available, waiting again...')

Expand All @@ -50,7 +45,7 @@ def add_waypoint_to_list(self, req):
self.path.poses.append(newpose)
self.path_pub.publish(self.path)

return WaypointResponse(True)
return Waypoint.Response(True)

def remove_waypoint_from_list(self, req):
self.waypoint_list.remove(req)
Expand All @@ -64,7 +59,7 @@ def spin(self):
index_waypoint_k = 0
while rclpy.ok():
if len(self.waypoint_list) >= 2 and index_waypoint_k < len(self.waypoint_list) - 1:
goal = LosPathFollowingGoal()
goal = LosPathFollowing.Goal()
self.get_logger().info("define goal to send to los_guidance_node")

goal.waypoints[0].x = self.waypoint_list[self.index_waypoint_k][0]
Expand Down

0 comments on commit 4feb58d

Please sign in to comment.