Action server : Error
Hi, I try to do my first action server: FollowJointTRajectory, So i did new package (rosactionserver). Next, i copied from: http://docs.ros.org/electric/api/control_msgs/html/action/FollowJointTrajectory.html action file,
# The joint trajectory to follow
trajectory_msgs/JointTrajectory trajectory
# Tolerances for the trajectory. If the measured joint values fall
# outside the tolerances the trajectory goal is aborted. Any
# tolerances that are not specified (by being omitted or set to 0) are
# set to the defaults for the action server (often taken from the
# parameter server).
# Tolerances applied to the joints as the trajectory is executed. If
# violated, the goal aborts with error_code set to
# PATH_TOLERANCE_VIOLATED.
JointTolerance[] path_tolerance
# To report success, the joints must be within goal_tolerance of the
# final trajectory value. The goal must be achieved by time the
# trajectory ends plus goal_time_tolerance. (goal_time_tolerance
# allows some leeway in time, so that the trajectory goal can still
# succeed even if the joints reach the goal some time after the
# precise end time of the trajectory).
#
# If the joints are not within goal_tolerance after "trajectory finish
# time" + goal_time_tolerance, the goal aborts with error_code set to
# GOAL_TOLERANCE_VIOLATED
JointTolerance[] goal_tolerance
duration goal_time_tolerance
---
int32 error_code
int32 SUCCESSFUL = 0
int32 INVALID_GOAL = -1
int32 INVALID_JOINTS = -2
int32 OLD_HEADER_TIMESTAMP = -3
int32 PATH_TOLERANCE_VIOLATED = -4
int32 GOAL_TOLERANCE_VIOLATED = -5
# Human readable description of the error code. Contains complementary
# information that is especially useful when execution fails, for instance:
# - INVALID_GOAL: The reason for the invalid goal (e.g., the requested
# trajectory is in the past).
# - INVALID_JOINTS: The mismatch between the expected controller joints
# and those provided in the goal.
# - PATH_TOLERANCE_VIOLATED and GOAL_TOLERANCE_VIOLATED: Which joint
# violated which tolerance, and by how much.
string error_string
---
Header header
string[] joint_names
trajectory_msgs/JointTrajectoryPoint desired
trajectory_msgs/JointTrajectoryPoint actual
trajectory_msgs/JointTrajectoryPoint error
Next i found fullactionserver.cpp:
#include <ros/ros.h>
#include <actionlib/server/simple_action_server.h>
#include <control_msgs/FollowJointTrajectoryAction.h>
#include <trajectory_msgs/JointTrajectory.h>
class RobotTrajectoryFollower
{
protected:
ros::NodeHandle nh_;
// NodeHandle instance must be created before this line. Otherwise strange error may occur.
actionlib::SimpleActionServer<ros_action_server::FollowJointTrajectoryAction> as_;
std::string action_name_;
public:
RobotTrajectoryFollower(std::string name) :
as_(nh_, name, false),
action_name_(name)
{
//Register callback functions:
as_.registerGoalCallback(boost::bind(&RobotTrajectoryFollower::goalCB, this));
as_.registerPreemptCallback(boost::bind(&RobotTrajectoryFollower::preemptCB, this));
as_.start();
}
~RobotTrajectoryFollower(void)//Destructor
{
}
void goalCB()
{
// accept the new goal
//goal_ = as_.acceptNewGoal()->samples;
}
void preemptCB()
{
ROS_INFO("%s: Preempted", action_name_.c_str());
// set the action state to preempted
as_.setPreempted();
}
};
int main(int argc, char** argv)
{
ros::init(argc, argv, "action_server");
RobotTrajectoryFollower RobotTrajectoryFollower("/full_ctrl/joint_trajectory_action");
ros::spin();
return 0;
}
With this tutorial, i modified CmakeList.txt:
cmake_minimum_required(VERSION 2.8.3)
project(ros_action_server)
## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
actionlib
actionlib_msgs
message_generation
roscpp
std_msgs
)
## System dependencies are found with CMake's conventions
find_package(Boost REQUIRED COMPONENTS system)
## Declare ROS messages, services and actions ##
################################################
## Generate messages in the 'msg' folder
add_message_files(DIRECTORY msg FILES
GripperCommand.msg
JointControllerState.msg
JointJog.msg
JointTolerance.msg
JointTrajectoryControllerState.msg
PidState.msg
FollowJointTrajectoryAction.msg
)
## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )
## Generate actions in the 'action' folder
add_action_files(
FILES
FollowJointTrajectory.action
# Action2.action
)
## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
actionlib_msgs std_msgs
)
################################################
## Declare ROS dynamic reconfigure parameters ##
################################################
## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt):
## * add "dynamic_reconfigure" to
## find_package(catkin REQUIRED COMPONENTS ...)
## * uncomment the "generate_dynamic_reconfigure_options" section below
## and list every .cfg file to be processed
## Generate dynamic reconfigure parameters in the 'cfg' folder
# generate_dynamic_reconfigure_options(
# cfg/DynReconf1.cfg
# cfg/DynReconf2.cfg
# )
###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES ros_action_server
# CATKIN_DEPENDS actionlib actionlib_msgs message_generation roscpp std_msgs
# DEPENDS system_lib
)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
## Declare a C++ library
# add_library(${PROJECT_NAME}
# src/${PROJECT_NAME}/ros_action_server.cpp
# )
## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
add_executable(full_action_server src/full_action_server.cpp)
## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
## target back to the shorter version for ease of user use
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
## Add cmake target dependencies of the executable
## same as for the library above
add_dependencies(full_action_server ${ros_action_server_EXPORTED_TARGETS})
## Specify libraries to link a library or executable target against
target_link_libraries(full_action_server
${catkin_LIBRARIES}
)
#############
## Install ##
#############
# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )
#############
## Testing ##
#############
## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_ros_action_server.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()
## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
next, i tried to compile and i got error:
CMake Error at /home/pawel/catkin_ws/build/ros_action_server/cmake/ros_action_server-genmsg.cmake:3 (message):
Could not find messages which
'/home/pawel/catkin_ws/src/ros_action_server/msg/JointTrajectoryControllerState.msg'
depends on. Did you forget to specify generate_messages(DEPENDENCIES ...)?
Cannot locate message [JointTrajectoryPoint]: unknown package
[trajectory_msgs] on search path [{{'ros_action_server':
['/home/pawel/catkin_ws/src/ros_action_server/msg',
'/home/pawel/catkin_ws/devel/share/ros_action_server/msg'],
'actionlib_msgs': ['/opt/ros/melodic/share/actionlib_msgs/cmake/../msg'],
'std_msgs': ['/opt/ros/melodic/share/std_msgs/cmake/../msg']}}]
Call Stack (most recent call first):
/opt/ros/melodic/share/genmsg/cmake/genmsg-extras.cmake:307 (include)
ros_action_server/CMakeLists.txt:77 (generate_messages)
-- Configuring incomplete, errors occurred!
See also "/home/pawel/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/pawel/catkin_ws/build/CMakeFiles/CMakeError.log".
Makefile:4464: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
I tried to change those files but nothing hapened. I would be gratefout for Your help, Pawel
Asked by Pawel_www on 2019-04-15 11:16:33 UTC
Comments
Did you configure package.xml? I think the first time you use it you have to include that in the package.xml this line
The first time I try that tutorial I have to do that. But later, when I create other packages that use actionlib, I don't have to.
Asked by madlink306 on 2019-06-23 07:11:54 UTC