cd ~/dev_ws colcon build Run the Action Server 'connect_to_charging_dock_server = action_tutorials_py.connect_to_charging_dock_action_server:main', cd ~/dev_ws/src/action_tutorials/action_tutorials_py/Īdd the following line inside the entry_points block. cd ~/dev_ws/src/action_tutorials/action_tutorials_py/ gedit package.xml # Spin the nodes to execute the callbacksĬonnect_to_charging_dock_action_stroy_node() # Create the Battery State subscriber nodeīattery_state_subscriber = BatteryStateSubscriber()Įxecutor = MultiThreadedExecutor(num_threads=4)Įxecutor.add_node(connect_to_charging_dock_action_server)Įxecutor.add_node(battery_state_subscriber) Self.subscription_battery_state = self.create_subscription(Ĭonnect_to_charging_dock_action_server = ConnectToChargingDockActionServer() # This node subscribes to messages of type Super()._init_('battery_state_subscriber') Subscriber node to the current battery state Result.final_battery_state = feedback_msg.current_battery_state # Create a result message of the action type Self.get_logger().info('Successfully connected to the charging dock!') Self.publisher_cmd_vel.publish(cmd_vel_msg) # Send the velocity command to the robot by publishing to the topicĬmd_vel_ = self.linear_velocityĬmd_vel_ = self.angular_velocity Goal_handle.publish_feedback(feedback_msg) While this_battery_state.power_supply_status != 1: Self.get_logger().info('Executing goal.')įeedback_msg = ConnectToChargingDock.Feedback()įeedback_msg.current_battery_state = this_battery_state Self.publisher_cmd_vel = self.create_publisher(Īction server callback to execute accepted goals. # This node publishes the desired linear and angular velocity of the robot # self, type of action, action name, callback function for executing goals Super()._init_('connect_to_charging_dock_action_server') # Initialize the class using the constructor # Handle Twist messages, linear and angular velocityĬlass ConnectToChargingDockActionServer(Node):Ĭreate a ConnectToChargingDockActionServer class, # Enables publishers, subscribers, and action servers to be in a single nodeįrom rclpy.executors import MultiThreadedExecutor Velocity command to navigate to the charging dock.įrom action_tutorials_interfaces.action import ConnectToChargingDock battery_status – sensor_msgs/BatteryState You can then delete the demos folder.Īction Server to connect to a battery charging dock.Īction is successful when the power_supply_status goes from You only need the action_tutorials folder (which is inside the folder named ‘demos’), so cut and paste that folder into the ~/ dev_ws/src folder using your File Explorer. Open a new terminal window, and clone the action_tutorials repository from GitHub. Let’s take a look at the ROS 2 demo repository so we can examine the sample action they created in their official tutorial. You can find the files for this post here on my Google Drive. The name of our workspace is “dev_ws”, which stands for “development workspace.”
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |