An actionlib example – battery simulator server-client

In the previous example, you wrote a client that sends goals to the server, which was already implemented as a part of the Gazebo plugin. In this example, let's try to implement ROS actions from scratch. To create an ROS action, follow these steps:

  1. Create a package and create a folder called action inside it.
  2. Create an action file that has the goal, result, and feedback.
  3. Modify the package files and compile the package.
  4. Define a server.
  5. Define a client.

Let's consider an example of a battery simulator. When you power up a robot, the robot runs on a battery supply and eventually loses charge over a certain amount of time, depending on the battery type. Let's simulate the same scenario using a server-client implementation. The simulator will be our server and will be initiated when the robot is powered up. We will use a client to change the state of the battery, either as charging or discharging, based on which the battery server charges or discharges. Hence, let's get on with the steps for implementing our own ROS action.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset