Step 2
- Open the Motor.action file in IDE and write the following content to it.
# This is an action definition file, which has three parts: the goal
# the result, and the feedback.
# Part 1: the goal.
#
# The angle in degree the robot to turn, sent by client main
float64 angle
---
# Part 2: the result, sent by action server unpon completion
#
# How much time used
duration time_elapsed
# How many updates thrown in total
uint32 updates_n
---
# Part 3: the feedback,to be sent periodically by server
#
# The amount of time elapsed from the start
duration time_elapsed
- The contents of Motor.action defines variables of three categories. The categories are separated by — lines. The first category of variables are related to GOAL, second is related to RESULT and third are related to the FEEDBACK. Here we have the following variable in different categories:
angle
for GOAL, time_elapsed
, updates_n
for RESULT and time_elapsed
for FEEDBACK.
from turtlebot3_console_controller.msg import MotorGoal, MotorResult, MotorFeedback
print("OK, it worked!!!")
Let’s run the above script. Enter the following commands in the SHELL
$ cd ~/catkin_ws/src/turtlebot3_console_controller/src
$ ./node.py
After running the above command you should see the reply OK, it worked!!! in the next line.
And that’s it. We have created a basic action message and verified it works.