Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mobile_robotics
ADC
ADC_2021
iri_image_inverter
Commits
d390b54a
Commit
d390b54a
authored
Apr 15, 2021
by
Fernando Herrero
Browse files
Change name to iri_image_inverter
parent
d9e1ceb9
Changes
10
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
d390b54a
cmake_minimum_required
(
VERSION 2.8.3
)
project
(
iri_image_
modifi
er
)
project
(
iri_image_
invert
er
)
## Find catkin macros and libraries
find_package
(
catkin REQUIRED
)
...
...
@@ -49,7 +49,7 @@ find_package(catkin REQUIRED COMPONENTS iri_base_algorithm cv_bridge image_trans
# ********************************************************************
# Add the dynamic reconfigure file
# ********************************************************************
generate_dynamic_reconfigure_options
(
cfg/Image
Modifi
er.cfg
)
generate_dynamic_reconfigure_options
(
cfg/Image
Invert
er.cfg
)
# ********************************************************************
# Add run time dependencies here
...
...
@@ -82,7 +82,7 @@ include_directories(${catkin_INCLUDE_DIRS})
# add_library(${PROJECT_NAME} <list of source files>)
## Declare a cpp executable
add_executable
(
${
PROJECT_NAME
}
src/image_
modifi
er_alg.cpp src/image_
modifi
er_alg_node.cpp
)
add_executable
(
${
PROJECT_NAME
}
src/image_
invert
er_alg.cpp src/image_
invert
er_alg_node.cpp
)
# ********************************************************************
# Add the libraries
...
...
README.md
View file @
d390b54a
## Description
The iri_image_
modifi
er project description
The iri_image_
invert
er project description
# ROS Interface
### Topic publishers
...
...
@@ -38,7 +38,7 @@ catkin_make
-
Standalone test
`roslaunch iri_image_
modifi
er test.launch`
`roslaunch iri_image_
invert
er test.launch`
## Disclaimer
...
...
cfg/Image
Modifi
er.cfg
→
cfg/Image
Invert
er.cfg
View file @
d390b54a
...
...
@@ -31,7 +31,7 @@
# Author:
PACKAGE
=
'iri_image_
modifi
er'
PACKAGE
=
'iri_image_
invert
er'
from
dynamic_reconfigure.parameter_generator_catkin
import
*
...
...
@@ -41,4 +41,4 @@ gen = ParameterGenerator()
gen
.
add
(
"rate"
,
double_t
,
0
,
"Main loop rate (Hz)"
,
10.0
,
0.1
,
1000.0
)
gen
.
add
(
"invert"
,
bool_t
,
0
,
"Invert image colors"
,
True
)
exit
(
gen
.
generate
(
PACKAGE
,
"Image
Modifi
erAlgorithm"
,
"Image
Modifi
er"
))
exit
(
gen
.
generate
(
PACKAGE
,
"Image
Invert
erAlgorithm"
,
"Image
Invert
er"
))
include/image_
modifi
er_alg.h
→
include/image_
invert
er_alg.h
View file @
d390b54a
...
...
@@ -22,25 +22,25 @@
// refer to the IRI wiki page for more information:
// http://wikiri.upc.es/index.php/Robotics_Lab
#ifndef _image_
modifi
er_alg_h_
#define _image_
modifi
er_alg_h_
#ifndef _image_
invert
er_alg_h_
#define _image_
invert
er_alg_h_
#include
<iri_image_
modifi
er/Image
Modifi
erConfig.h>
#include
<iri_image_
invert
er/Image
Invert
erConfig.h>
//include image_
modifi
er_alg main library
//include image_
invert
er_alg main library
/**
* \brief IRI ROS Specific Driver Class
*
*
*/
class
Image
Modifi
erAlgorithm
class
Image
Invert
erAlgorithm
{
protected:
/**
* \brief define config type
*
* Define a Config type with the Image
Modifi
erConfig. All driver implementations
* Define a Config type with the Image
Invert
erConfig. All driver implementations
* will then use the same variable type Config.
*/
pthread_mutex_t
access_
;
...
...
@@ -51,10 +51,10 @@ class ImageModifierAlgorithm
/**
* \brief define config type
*
* Define a Config type with the Image
Modifi
erConfig. All driver implementations
* Define a Config type with the Image
Invert
erConfig. All driver implementations
* will then use the same variable type Config.
*/
typedef
iri_image_
modifi
er
::
Image
Modifi
erConfig
Config
;
typedef
iri_image_
invert
er
::
Image
Invert
erConfig
Config
;
/**
* \brief config variable
...
...
@@ -72,7 +72,7 @@ class ImageModifierAlgorithm
* Attributes from the main node driver class IriBaseDriver such as loop_rate,
* may be also overload here.
*/
Image
Modifi
erAlgorithm
(
void
);
Image
Invert
erAlgorithm
(
void
);
/**
* \brief Lock Algorithm
...
...
@@ -116,7 +116,7 @@ class ImageModifierAlgorithm
*/
void
config_update
(
Config
&
config
,
uint32_t
level
=
0
);
// here define all image_
modifi
er_alg interface methods to retrieve and set
// here define all image_
invert
er_alg interface methods to retrieve and set
// the driver parameters
/**
...
...
@@ -125,7 +125,7 @@ class ImageModifierAlgorithm
* This destructor is called when the object is about to be destroyed.
*
*/
~
Image
Modifi
erAlgorithm
(
void
);
~
Image
Invert
erAlgorithm
(
void
);
};
#endif
include/image_
modifi
er_alg_node.h
→
include/image_
invert
er_alg_node.h
View file @
d390b54a
...
...
@@ -22,11 +22,11 @@
// refer to the IRI wiki page for more information:
// http://wikiri.upc.es/index.php/Robotics_Lab
#ifndef _image_
modifi
er_alg_node_h_
#define _image_
modifi
er_alg_node_h_
#ifndef _image_
invert
er_alg_node_h_
#define _image_
invert
er_alg_node_h_
#include
<iri_base_algorithm/iri_base_algorithm.h>
#include
"image_
modifi
er_alg.h"
#include
"image_
invert
er_alg.h"
// [publisher subscriber headers]
#include
<camera_info_manager/camera_info_manager.h>
...
...
@@ -43,7 +43,7 @@
* \brief IRI ROS Specific Algorithm Class
*
*/
class
Image
Modifi
erAlgNode
:
public
algorithm_base
::
IriBaseAlgorithm
<
Image
Modifi
erAlgorithm
>
class
Image
Invert
erAlgNode
:
public
algorithm_base
::
IriBaseAlgorithm
<
Image
Invert
erAlgorithm
>
{
private:
// [publisher attributes]
...
...
@@ -86,7 +86,7 @@ class ImageModifierAlgNode : public algorithm_base::IriBaseAlgorithm<ImageModifi
* This constructor initializes specific class attributes and all ROS
* communications variables to enable message exchange.
*/
Image
Modifi
erAlgNode
(
void
);
Image
Invert
erAlgNode
(
void
);
/**
* \brief Destructor
...
...
@@ -94,7 +94,7 @@ class ImageModifierAlgNode : public algorithm_base::IriBaseAlgorithm<ImageModifi
* This destructor frees all necessary dynamic memory allocated within this
* this class.
*/
~
Image
Modifi
erAlgNode
(
void
);
~
Image
Invert
erAlgNode
(
void
);
protected:
/**
...
...
launch/node.launch
View file @
d390b54a
<?xml version="1.0" encoding="UTF-8"?>
<launch>
<arg
name=
"node_name"
default=
"iri_image_
modifi
er"
/>
<arg
name=
"node_name"
default=
"iri_image_
invert
er"
/>
<arg
name=
"output"
default=
"screen"
/>
<arg
name=
"launch_prefix"
default=
""
/>
<arg
name=
"config_file"
default=
"$(find iri_image_
modifi
er)/config/params.yaml"
/>
<arg
name=
"config_file"
default=
"$(find iri_image_
invert
er)/config/params.yaml"
/>
<arg
name=
"image_in_topic"
default=
"image_in"
/>
<arg
name=
"image_out_topic"
default=
"image_out"
/>
<node
name=
"$(arg node_name)"
pkg =
"iri_image_
modifi
er"
type=
"iri_image_
modifi
er"
pkg =
"iri_image_
invert
er"
type=
"iri_image_
invert
er"
output=
"$(arg output)"
launch-prefix=
"$(arg launch_prefix)"
>
<rosparam
file=
"$(arg config_file)"
command=
"load"
/>
...
...
launch/test.launch
View file @
d390b54a
...
...
@@ -5,17 +5,17 @@
<arg
name=
"launch_prefix"
default=
""
/>
<arg
name=
"dr"
default=
"true"
/>
<include
file=
"$(find iri_image_
modifi
er)/launch/node.launch"
>
<arg
name=
"node_name"
value=
"iri_image_
modifi
er"
/>
<include
file=
"$(find iri_image_
invert
er)/launch/node.launch"
>
<arg
name=
"node_name"
value=
"iri_image_
invert
er"
/>
<arg
name=
"output"
value=
"$(arg output)"
/>
<arg
name=
"launch_prefix"
value=
"$(arg launch_prefix)"
/>
</include>
<node
name=
"rqt_reconfigure_iri_image_
modifi
er"
<node
name=
"rqt_reconfigure_iri_image_
invert
er"
pkg =
"rqt_reconfigure"
type=
"rqt_reconfigure"
if =
"$(arg dr)"
args=
"iri_image_
modifi
er"
>
args=
"iri_image_
invert
er"
>
</node>
</launch>
\ No newline at end of file
</launch>
package.xml
View file @
d390b54a
<?xml version="1.0"?>
<package
format=
"2"
>
<name>
iri_image_
modifi
er
</name>
<name>
iri_image_
invert
er
</name>
<version>
1.0.0
</version>
<description>
The iri_image_
modifi
er package subscribe to an image and republishes it with chosen modifications made on it
</description>
<description>
The iri_image_
invert
er package subscribe to an image and republishes it with chosen modifications made on it
</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
...
...
@@ -19,7 +19,7 @@
<!-- Url tags are optional, but multiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/iri_image_
modifi
er</url> -->
<!-- <url type="website">http://wiki.ros.org/iri_image_
invert
er</url> -->
<!-- Author tags are optional, multiple are allowed, one per tag -->
...
...
src/image_
modifi
er_alg.cpp
→
src/image_
invert
er_alg.cpp
View file @
d390b54a
#include
"image_
modifi
er_alg.h"
#include
"image_
invert
er_alg.h"
Image
Modifi
erAlgorithm
::
Image
Modifi
erAlgorithm
(
void
)
Image
Invert
erAlgorithm
::
Image
Invert
erAlgorithm
(
void
)
{
pthread_mutex_init
(
&
this
->
access_
,
NULL
);
}
Image
Modifi
erAlgorithm
::~
Image
Modifi
erAlgorithm
(
void
)
Image
Invert
erAlgorithm
::~
Image
Invert
erAlgorithm
(
void
)
{
pthread_mutex_destroy
(
&
this
->
access_
);
}
void
Image
Modifi
erAlgorithm
::
config_update
(
Config
&
config
,
uint32_t
level
)
void
Image
Invert
erAlgorithm
::
config_update
(
Config
&
config
,
uint32_t
level
)
{
this
->
lock
();
...
...
@@ -20,4 +20,4 @@ void ImageModifierAlgorithm::config_update(Config& config, uint32_t level)
this
->
unlock
();
}
// Image
Modifi
erAlgorithm Public API
// Image
Invert
erAlgorithm Public API
src/image_
modifi
er_alg_node.cpp
→
src/image_
invert
er_alg_node.cpp
View file @
d390b54a
#include
"image_
modifi
er_alg_node.h"
#include
"image_
invert
er_alg_node.h"
Image
Modifi
erAlgNode
::
Image
Modifi
erAlgNode
(
void
)
:
algorithm_base
::
IriBaseAlgorithm
<
Image
Modifi
erAlgorithm
>
(),
Image
Invert
erAlgNode
::
Image
Invert
erAlgNode
(
void
)
:
algorithm_base
::
IriBaseAlgorithm
<
Image
Invert
erAlgorithm
>
(),
image_camera_manager
(
ros
::
NodeHandle
(
"~image"
)),
it
(
this
->
private_node_handle_
)
{
//init class attributes if necessary
if
(
!
this
->
private_node_handle_
.
getParam
(
"rate"
,
this
->
config_
.
rate
))
{
ROS_WARN
(
"Image
Modifi
erAlgNode::Image
Modifi
erAlgNode: param 'rate' not found"
);
ROS_WARN
(
"Image
Invert
erAlgNode::Image
Invert
erAlgNode: param 'rate' not found"
);
}
else
this
->
setRate
(
this
->
config_
.
rate
);
...
...
@@ -29,7 +29,7 @@ ImageModifierAlgNode::ImageModifierAlgNode(void) :
// [init subscribers]
this
->
image_subscriber_
=
this
->
it
.
subscribeCamera
(
"image_in/image_raw"
,
1
,
&
Image
Modifi
erAlgNode
::
image_callback
,
this
);
this
->
image_subscriber_
=
this
->
it
.
subscribeCamera
(
"image_in/image_raw"
,
1
,
&
Image
Invert
erAlgNode
::
image_callback
,
this
);
pthread_mutex_init
(
&
this
->
image_mutex_
,
NULL
);
...
...
@@ -42,17 +42,17 @@ ImageModifierAlgNode::ImageModifierAlgNode(void) :
// [init action clients]
}
Image
Modifi
erAlgNode
::~
Image
Modifi
erAlgNode
(
void
)
Image
Invert
erAlgNode
::~
Image
Invert
erAlgNode
(
void
)
{
// [free dynamic memory]
pthread_mutex_destroy
(
&
this
->
image_mutex_
);
}
void
Image
Modifi
erAlgNode
::
mainNodeThread
(
void
)
void
Image
Invert
erAlgNode
::
mainNodeThread
(
void
)
{
//lock access to algorithm if necessary
this
->
alg_
.
lock
();
ROS_DEBUG
(
"Image
Modifi
erAlgNode::mainNodeThread"
);
ROS_DEBUG
(
"Image
Invert
erAlgNode::mainNodeThread"
);
// [fill msg structures]
// Initialize the topic message structure
//this->image_Image_msg_.data = my_var;
...
...
@@ -78,9 +78,9 @@ void ImageModifierAlgNode::mainNodeThread(void)
}
/* [subscriber callbacks] */
void
Image
Modifi
erAlgNode
::
image_callback
(
const
sensor_msgs
::
Image
::
ConstPtr
&
msg
,
const
sensor_msgs
::
CameraInfoConstPtr
&
info
)
void
Image
Invert
erAlgNode
::
image_callback
(
const
sensor_msgs
::
Image
::
ConstPtr
&
msg
,
const
sensor_msgs
::
CameraInfoConstPtr
&
info
)
{
//ROS_INFO("Image
Modifi
erAlgNode::image_callback: New Message Received");
//ROS_INFO("Image
Invert
erAlgNode::image_callback: New Message Received");
//use appropiate mutex to shared variables if necessary
//this->alg_.lock();
...
...
@@ -101,12 +101,12 @@ void ImageModifierAlgNode::image_callback(const sensor_msgs::Image::ConstPtr& ms
//this->image_mutex_exit();
}
void
Image
Modifi
erAlgNode
::
image_mutex_enter
(
void
)
void
Image
Invert
erAlgNode
::
image_mutex_enter
(
void
)
{
pthread_mutex_lock
(
&
this
->
image_mutex_
);
}
void
Image
Modifi
erAlgNode
::
image_mutex_exit
(
void
)
void
Image
Invert
erAlgNode
::
image_mutex_exit
(
void
)
{
pthread_mutex_unlock
(
&
this
->
image_mutex_
);
}
...
...
@@ -118,7 +118,7 @@ void ImageModifierAlgNode::image_mutex_exit(void)
/* [action requests] */
void
Image
Modifi
erAlgNode
::
node_config_update
(
Config
&
config
,
uint32_t
level
)
void
Image
Invert
erAlgNode
::
node_config_update
(
Config
&
config
,
uint32_t
level
)
{
this
->
alg_
.
lock
();
if
(
config
.
rate
!=
this
->
getRate
())
...
...
@@ -127,12 +127,12 @@ void ImageModifierAlgNode::node_config_update(Config &config, uint32_t level)
this
->
alg_
.
unlock
();
}
void
Image
Modifi
erAlgNode
::
addNodeDiagnostics
(
void
)
void
Image
Invert
erAlgNode
::
addNodeDiagnostics
(
void
)
{
}
/* main function */
int
main
(
int
argc
,
char
*
argv
[])
{
return
algorithm_base
::
main
<
Image
Modifi
erAlgNode
>
(
argc
,
argv
,
"image_
modifi
er_alg_node"
);
return
algorithm_base
::
main
<
Image
Invert
erAlgNode
>
(
argc
,
argv
,
"image_
invert
er_alg_node"
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment