Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iri_base_algorithm
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_base_algorithm
Commits
9a4724b4
Commit
9a4724b4
authored
14 years ago
by
Joan Perez Ibarz
Browse files
Options
Downloads
Patches
Plain Diff
updating iri_base_algorithm with dynamic_reconfigure
parent
f3085f29
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+13
-6
13 additions, 6 deletions
CMakeLists.txt
include/iri_base_algorithm/iri_base_algorithm.h
+57
-19
57 additions, 19 deletions
include/iri_base_algorithm/iri_base_algorithm.h
manifest.xml
+1
-2
1 addition, 2 deletions
manifest.xml
with
71 additions
and
27 deletions
CMakeLists.txt
+
13
−
6
View file @
9a4724b4
cmake_minimum_required
(
VERSION 2.4.6
)
include
(
$ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake
)
set
(
PROJECT_NAME iri_base_algorithm
)
# Set the build type. Options are:
# Coverage : w/ debug symbols, w/o optimization, w/ code-coverage
# Debug : w/ debug symbols, w/o optimization
...
...
@@ -16,15 +18,20 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set
(
LIBRARY_OUTPUT_PATH
${
PROJECT_SOURCE_DIR
}
/lib
)
#uncomment if you have defined messages
#rosbuild_genmsg()
#uncomment if you have defined services
#rosbuild_gensrv()
# edit the following line to add all the source code files of the library
# SET(sources ./src/iri_base_driver.cpp)
# edit the following line to add all the header files of the library
# SET(headers ./include/iri_base_algorithm/iri_base_algorithm.h)
# FIND_PACKAGE(iriutils REQUIRED)
# INCLUDE_DIRECTORIES(${iriutils_INCLUDE_DIR} ${headers})
#common commands for building c++ executables and libraries
#rosbuild_add_library(${PROJECT_NAME}
src/example.cpp
)
#
rosbuild_add_library(${PROJECT_NAME}
SHARED ${sources}
)
#target_link_libraries(${PROJECT_NAME} another_library)
#rosbuild_add_boost_directories()
#rosbuild_link_boost(${PROJECT_NAME} thread)
#rosbuild_add_executable(example examples/example.cpp)
#target_link_libraries(example ${PROJECT_NAME})
# target_link_libraries(${PROJECT_NAME} ${iriutils_LIBRARY})
This diff is collapsed.
Click to expand it.
include/iri_base_algorithm/iri_base_algorithm.h
+
57
−
19
View file @
9a4724b4
...
...
@@ -2,11 +2,14 @@
#define _IRI_BASE_ALGORITHM_H
#include
<ros/ros.h>
// #include <boost/bind.hpp>
#include
<dynamic_reconfigure/server.h>
// iri-utils thread server
#include
"threadserver.h"
#include
"exceptions.h"
//check me out
// namespace algorithm_base
// {
...
...
@@ -17,15 +20,23 @@
template
<
class
Algorithm
>
class
IriBaseAlgorithm
{
public:
//check me out
typedef
typename
Algorithm
::
Config
Config
;
protected:
Algorithm
alg
;
CThreadServer
*
thread_server
;
std
::
string
main_thread_id
;
Algorithm
alg
_
;
CThreadServer
*
thread_server
_
;
std
::
string
main_thread_id
_
;
ros
::
NodeHandle
node_handle_
;
ros
::
NodeHandle
private_node_handle_
;
ros
::
Rate
loop_rate
;
//check me out
dynamic_reconfigure
::
Server
<
Config
>
dsrv_
;
// dynamic_reconfigure::Server<Config>::CallbackType cb;
ros
::
Rate
loop_rate_
;
static
const
unsigned
int
DEFAULT_RATE
=
10
;
//[Hz]
public:
...
...
@@ -33,11 +44,12 @@ class IriBaseAlgorithm
~
IriBaseAlgorithm
();
protected:
// void addDiagnostics(void);
void
reconfigureCallback
(
Config
&
config
,
uint32_t
level
);
void
addDiagnostics
(
void
);
// void addOpenedTests(void);
// void addStoppedTests(void);
// void addRunningTests(void);
//
virtual void addNodeDiagnostics(void) = 0;
virtual
void
addNodeDiagnostics
(
void
)
=
0
;
// virtual void addNodeOpenedTests(void) = 0;
// virtual void addNodeStoppedTests(void) = 0;
// virtual void addNodeRunningTests(void) = 0;
...
...
@@ -46,20 +58,45 @@ class IriBaseAlgorithm
};
//check me out
template
<
class
Algorithm
>
IriBaseAlgorithm
<
Algorithm
>::
IriBaseAlgorithm
()
:
private_node_handle_
(
"~"
),
loop_rate
(
DEFAULT_RATE
)
IriBaseAlgorithm
<
Algorithm
>::
IriBaseAlgorithm
()
:
private_node_handle_
(
"~"
),
dsrv_
(
ros
::
NodeHandle
(
"~"
)),
loop_rate
_
(
DEFAULT_RATE
)
{
// create the status thread
this
->
thread_server
=
CThreadServer
::
instance
();
this
->
main_thread_id
=
"main_thread"
;
this
->
thread_server
_
=
CThreadServer
::
instance
();
this
->
main_thread_id
_
=
"main_thread"
;
this
->
thread_server
->
create_thread
(
this
->
main_thread_id
);
this
->
thread_server
->
attach_thread
(
this
->
main_thread_id
,
this
->
mainThread
,
this
);
this
->
thread_server
->
start_thread
(
this
->
main_thread_id
);
this
->
thread_server
_
->
create_thread
(
this
->
main_thread_id
_
);
this
->
thread_server
_
->
attach_thread
(
this
->
main_thread_id
_
,
this
->
mainThread
,
this
);
this
->
thread_server
_
->
start_thread
(
this
->
main_thread_id
_
);
//check me out
// dynamic_reconfigure::Server<Config>::CallbackType cb;
// = boost::bind(&IriBaseAlgorithm<Algorithm>::reconfigureCallback, this, _1, _2);
dsrv_
.
setCallback
(
boost
::
bind
(
&
IriBaseAlgorithm
<
Algorithm
>::
reconfigureCallback
,
this
,
_1
,
_2
));
// initialize class attributes
}
template
<
class
Algorithm
>
IriBaseAlgorithm
<
Algorithm
>::~
IriBaseAlgorithm
()
{
this
->
thread_server_
->
kill_thread
(
this
->
main_thread_id_
);
}
template
<
class
Algorithm
>
void
IriBaseAlgorithm
<
Algorithm
>::
reconfigureCallback
(
Config
&
config
,
uint32_t
level
)
{
//check me out
alg_
.
config_
=
config
;
}
template
<
class
Algorithm
>
void
IriBaseAlgorithm
<
Algorithm
>::
addDiagnostics
(
void
)
{
addNodeDiagnostics
();
}
template
<
class
Algorithm
>
void
*
IriBaseAlgorithm
<
Algorithm
>::
mainThread
(
void
*
param
)
{
...
...
@@ -68,27 +105,28 @@ void *IriBaseAlgorithm<Algorithm>::mainThread(void *param)
while
(
ros
::
ok
())
{
iriNode
->
mainNodeThread
();
iriNode
->
loop_rate
.
sleep
();
iriNode
->
loop_rate
_
.
sleep
();
}
pthread_exit
(
NULL
);
}
template
<
class
Algorithm
>
IriBaseAlgorithm
<
Algorithm
>::~
IriBaseAlgorithm
()
namespace
algorithm_base
{
this
->
thread_server
->
kill_thread
(
this
->
main_thread_id
);
}
template
<
class
AlgImplTempl
>
int
main
(
int
argc
,
char
**
argv
,
std
::
string
name
)
{
ros
::
init
(
argc
,
argv
,
name
);
//check me out
AlgImplTempl
algImpl
;
return
ros
::
spin
();
//check me out
ros
::
spin
();
return
0
;
}
//
}
}
#endif
This diff is collapsed.
Click to expand it.
manifest.xml
+
1
−
2
View file @
9a4724b4
...
...
@@ -13,8 +13,7 @@
<depend
package=
"dynamic_reconfigure"
/>
<export>
<cpp
cflags=
"-I${prefix}/include"
lflags=
"-Wl,-rpath,${prefix}/lib -L${prefix}/lib -liri_base_algorithm"
/>
<cpp
cflags=
"-I${prefix}/include"
/>
</export>
</package>
...
...
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