<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://wiki.hshl.de/wiki/index.php?action=history&amp;feed=atom&amp;title=ROS2%3A_Template_to_program_an_Action_Client</id>
	<title>ROS2: Template to program an Action Client - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.hshl.de/wiki/index.php?action=history&amp;feed=atom&amp;title=ROS2%3A_Template_to_program_an_Action_Client"/>
	<link rel="alternate" type="text/html" href="https://wiki.hshl.de/wiki/index.php?title=ROS2:_Template_to_program_an_Action_Client&amp;action=history"/>
	<updated>2026-06-04T00:36:48Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in HSHL Mechatronik</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki.hshl.de/wiki/index.php?title=ROS2:_Template_to_program_an_Action_Client&amp;diff=147550&amp;oldid=prev</id>
		<title>Mirekgoebel am 26. März 2026 um 16:03 Uhr</title>
		<link rel="alternate" type="text/html" href="https://wiki.hshl.de/wiki/index.php?title=ROS2:_Template_to_program_an_Action_Client&amp;diff=147550&amp;oldid=prev"/>
		<updated>2026-03-26T16:03:17Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 26. März 2026, 16:03 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l27&quot;&gt;Zeile 27:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 27:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         # 2) the type of the Action (related to the interface, imported on top of this script&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         # 2) the type of the Action (related to the interface, imported on top of this script&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         # 3) the name of the Action&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         # 3) the name of the Action&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;        # !! 1)-3) must be the same in ActionClient and ActionServer&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         self._action_client = ActionClient(self, InterfaceName, &amp;#039;MyActionClientName&amp;#039;)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         self._action_client = ActionClient(self, InterfaceName, &amp;#039;MyActionClientName&amp;#039;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key mtrwiki:diff:1.41:old-147427:rev-147550:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Mirekgoebel</name></author>
	</entry>
	<entry>
		<id>https://wiki.hshl.de/wiki/index.php?title=ROS2:_Template_to_program_an_Action_Client&amp;diff=147427&amp;oldid=prev</id>
		<title>Mirekgoebel: Die Seite wurde neu angelegt: „Kategorie:ROS2  zurück zum Hauptartikel  &lt;source line lang=&quot;python&quot; style=&quot;font-size:small&quot;&gt; #!/usr/bin/env python # this specifies the interpreter of this script  ### ### Basic example of how to implement an action client ###  # import the ROS2 Python client libraries for nodes and actions import rclpy from rclpy.action import ActionClient from rclpy.node import Node  # import the interfaces used…“</title>
		<link rel="alternate" type="text/html" href="https://wiki.hshl.de/wiki/index.php?title=ROS2:_Template_to_program_an_Action_Client&amp;diff=147427&amp;oldid=prev"/>
		<updated>2026-03-23T09:29:21Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „&lt;a href=&quot;/wiki/index.php/Kategorie:ROS2&quot; title=&quot;Kategorie:ROS2&quot;&gt;Kategorie:ROS2&lt;/a&gt;  &lt;a href=&quot;/wiki/index.php/Overview_and_the_most_important_commands_of_ROS2&quot; title=&quot;Overview and the most important commands of ROS2&quot;&gt;zurück zum Hauptartikel&lt;/a&gt;  &amp;lt;source line lang=&amp;quot;python&amp;quot; style=&amp;quot;font-size:small&amp;quot;&amp;gt; #!/usr/bin/env python # this specifies the interpreter of this script  ### ### Basic example of how to implement an action client ###  # import the ROS2 Python client libraries for nodes and actions import rclpy from rclpy.action import ActionClient from rclpy.node import Node  # import the interfaces used…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Kategorie:ROS2]]&lt;br /&gt;
&lt;br /&gt;
[[Overview_and_the_most_important_commands_of_ROS2|zurück zum Hauptartikel]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source line lang=&amp;quot;python&amp;quot; style=&amp;quot;font-size:small&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/env python # this specifies the interpreter of this script&lt;br /&gt;
&lt;br /&gt;
###&lt;br /&gt;
### Basic example of how to implement an action client&lt;br /&gt;
###&lt;br /&gt;
&lt;br /&gt;
# import the ROS2 Python client libraries for nodes and actions&lt;br /&gt;
import rclpy&lt;br /&gt;
from rclpy.action import ActionClient&lt;br /&gt;
from rclpy.node import Node&lt;br /&gt;
&lt;br /&gt;
# import the interfaces used&lt;br /&gt;
from mypackage.action import InterfaceName&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class MyActionClient(Node):&lt;br /&gt;
&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
        super().__init__(&amp;#039;my_action_client&amp;#039;)&lt;br /&gt;
        # create action client with &lt;br /&gt;
        # 1) self: the node that contains the ActionClient&lt;br /&gt;
        # 2) the type of the Action (related to the interface, imported on top of this script&lt;br /&gt;
        # 3) the name of the Action&lt;br /&gt;
        self._action_client = ActionClient(self, InterfaceName, &amp;#039;MyActionClientName&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
    def send_goal(self, seconds):&lt;br /&gt;
        # Start by creating a Goal() object of the InterfaceName action type&lt;br /&gt;
        goal_msg = InterfaceName.Goal()&lt;br /&gt;
&lt;br /&gt;
        # set a variable&lt;br /&gt;
        goal_msg.some_variable_time = seconds&lt;br /&gt;
&lt;br /&gt;
        # wait for the Action Server to be up and running&lt;br /&gt;
        self._action_client.wait_for_server()&lt;br /&gt;
&lt;br /&gt;
        # send the goal to the Server using the send_goal_async method&lt;br /&gt;
        self._send_goal_future = self._action_client.send_goal_async(&lt;br /&gt;
            goal_msg, feedback_callback=self.feedback_callback)&lt;br /&gt;
&lt;br /&gt;
        # assign a callback method to be triggered when the future is completed&lt;br /&gt;
        self._send_goal_future.add_done_callback(self.goal_response_callback)&lt;br /&gt;
&lt;br /&gt;
    #  this method will be triggered when the goal has been processed&lt;br /&gt;
    def goal_response_callback(self, future):&lt;br /&gt;
        goal_handle = future.result()&lt;br /&gt;
        if not goal_handle.accepted:&lt;br /&gt;
            self.get_logger().info(&amp;#039;Goal rejected :(&amp;#039;)&lt;br /&gt;
            return&lt;br /&gt;
&lt;br /&gt;
        self.get_logger().info(&amp;#039;Goal accepted :)&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
        self._get_result_future = goal_handle.get_result_async()&lt;br /&gt;
        self._get_result_future.add_done_callback(self.get_result_callback)&lt;br /&gt;
&lt;br /&gt;
    # assign a callback method to be triggered when the result is ready&lt;br /&gt;
    def get_result_callback(self, future):&lt;br /&gt;
        result = future.result().result&lt;br /&gt;
        self.get_logger().info(&amp;#039;Result: {0}&amp;#039;.format(result.success))&lt;br /&gt;
        # shut down the node&lt;br /&gt;
        rclpy.shutdown()&lt;br /&gt;
&lt;br /&gt;
    # setting up the feedback&lt;br /&gt;
    def feedback_callback(self, feedback_msg):&lt;br /&gt;
        feedback = feedback_msg.feedback&lt;br /&gt;
        self.get_logger().info(&lt;br /&gt;
           &amp;#039;Received feedback: {0}&amp;#039;.format(feedback.elapsed_time))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def main(args=None):&lt;br /&gt;
    rclpy.init(args=args)&lt;br /&gt;
&lt;br /&gt;
    # creating an instance&lt;br /&gt;
    action_client = MyActionClient()&lt;br /&gt;
&lt;br /&gt;
    # calling its send_goal() method, passing it five seconds as a parameter.&lt;br /&gt;
    action_client.send_goal(5.0)&lt;br /&gt;
&lt;br /&gt;
    # spin the node so that the callback functions are properly executed.&lt;br /&gt;
    rclpy.spin(action_client)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;#039;__main__&amp;#039;:&lt;br /&gt;
    main()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mirekgoebel</name></author>
	</entry>
</feed>