Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iri_action_server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
labrobotica
ros
iri_core
iri_action_server
Commits
f1682d00
Commit
f1682d00
authored
13 years ago
by
Joan Perez Ibarz
Browse files
Options
Downloads
Patches
Plain Diff
adding exceptions to iri action server
parent
a0829841
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+2
-2
2 additions, 2 deletions
CMakeLists.txt
include/iri_action_server/iri_action_server.h
+59
-49
59 additions, 49 deletions
include/iri_action_server/iri_action_server.h
with
61 additions
and
51 deletions
CMakeLists.txt
+
2
−
2
View file @
f1682d00
...
...
@@ -23,9 +23,9 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
# edit the following line to add all the header files of the library
# SET(headers ./include/iri_action_server.h)
#
FIND_PACKAGE(iriutils REQUIRED)
FIND_PACKAGE
(
iriutils REQUIRED
)
#
INCLUDE_DIRECTORIES(${iriutils_INCLUDE_DIR} ${headers})
INCLUDE_DIRECTORIES
(
${
iriutils_INCLUDE_DIR
}
${
headers
}
)
#common commands for building c++ executables and libraries
# rosbuild_add_library(${PROJECT_NAME} SHARED ${sources})
...
...
This diff is collapsed.
Click to expand it.
include/iri_action_server/iri_action_server.h
+
59
−
49
View file @
f1682d00
...
...
@@ -29,6 +29,7 @@
#include
<actionlib/server/simple_action_server.h>
#include
<actionlib/action_definition.h>
#include
"exceptions.h"
/**
* \brief IRI ROS Specific Driver Class
...
...
@@ -146,65 +147,74 @@ void IriActionServer<ActionSpec>::executeCallback(const GoalConstPtr& goal)
{
ROS_DEBUG
(
"IriActionServer::executeCallback::start"
);
// init action
start_action_callback_
(
goal
);
try
{
// init action
start_action_callback_
(
goal
);
// boolean to control action status
bool
is_active
=
true
;
// boolean to control action status
bool
is_active
=
true
;
// while action is active
while
(
is_active
)
{
ROS_DEBUG
(
"IriActionServer::executeCallback::Active!"
);
// check if preempt has been requested
// and if ROS connection is OK
if
(
as_
.
isPreemptRequested
()
||
!
ros
::
ok
()
)
// while action is active
while
(
is_active
)
{
ROS_DEBUG
(
"IriActionServer::executeCallback::PREEMPTED!"
);
is_active
=
false
;
ROS_DEBUG
(
"IriActionServer::executeCallback::Active!"
);
// stop action
stop_action_callback_
();
as_
.
setPreempted
();
}
// check if action has finished
else
if
(
is_finished_callback_
()
)
{
ROS_DEBUG
(
"IriActionServer::executeCallback::FINISH!"
);
is_active
=
false
;
// get action result
ResultPtr
result
(
new
Result
);
get_result_callback_
(
result
);
// action has been successfully accomplished
if
(
has_succeed_callback_
()
)
// check if preempt has been requested
// and if ROS connection is OK
if
(
as_
.
isPreemptRequested
()
||
!
ros
::
ok
()
)
{
ROS_DEBUG
(
"IriActionServer::executeCallback::SUCCEED!"
);
// set action as succeeded
as_
.
setSucceeded
(
*
result
);
ROS_DEBUG
(
"IriActionServer::executeCallback::PREEMPTED!"
);
is_active
=
false
;
// stop action
stop_action_callback_
();
as_
.
setPreempted
();
}
// action needs to be aborted
// check if action has finished
else
if
(
is_finished_callback_
()
)
{
ROS_DEBUG
(
"IriActionServer::executeCallback::FINISH!"
);
is_active
=
false
;
// get action result
ResultPtr
result
(
new
Result
);
get_result_callback_
(
result
);
// action has been successfully accomplished
if
(
has_succeed_callback_
()
)
{
ROS_DEBUG
(
"IriActionServer::executeCallback::SUCCEED!"
);
// set action as succeeded
as_
.
setSucceeded
(
*
result
);
}
// action needs to be aborted
else
{
ROS_DEBUG
(
"IriActionServer::executeCallback::ABORTED!"
);
// set action as aborted
as_
.
setAborted
(
*
result
);
}
}
// action has not finished yet
else
{
ROS_DEBUG
(
"IriActionServer::executeCallback::ABORTED!"
);
// set action as aborted
as_
.
setAborted
(
*
result
);
ROS_DEBUG
(
"IriActionServer::executeCallback::feedback"
);
// get action feedback and publish it
FeedbackPtr
feedback
(
new
Feedback
);
get_feedback_callback_
(
feedback
);
as_
.
publishFeedback
(
*
feedback
);
}
// force loop rate's frequency if convenient
loop_rate_
.
sleep
();
}
// action has not finished yet
else
{
ROS_DEBUG
(
"IriActionServer::executeCallback::feedback"
);
// get action feedback and publish it
FeedbackPtr
feedback
(
new
Feedback
);
get_feedback_callback_
(
feedback
);
as_
.
publishFeedback
(
*
feedback
);
}
// force loop rate's frequency if convenient
loop_rate_
.
sleep
();
}
catch
(
CException
e
)
{
std
::
cout
<<
e
.
what
()
<<
std
::
endl
;
as_
.
setAborted
(
Result
(),
"something went wrong!"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment