Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wolf_ros_vision
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
mobile_robotics
wolf_projects
wolf_ros
wolf_ros_vision
Commits
46f7bf3c
Commit
46f7bf3c
authored
3 years ago
by
Joan Solà Ortega
Browse files
Options
Downloads
Patches
Plain Diff
Fix constness, add method, order class declaration
parent
b51b3cc7
No related branches found
Branches containing commit
No related tags found
2 merge requests
!3
After cmake and const refactor
,
!1
Resolve "Publisher for visual odometry"
Pipeline
#9673
canceled
3 years ago
Stage: license
Stage: build_and_test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/publisher_vision.h
+24
-22
24 additions, 22 deletions
include/publisher_vision.h
src/publisher_vision.cpp
+19
-14
19 additions, 14 deletions
src/publisher_vision.cpp
with
43 additions
and
36 deletions
include/publisher_vision.h
+
24
−
22
View file @
46f7bf3c
...
@@ -56,6 +56,26 @@ enum COLORFEATURES {BLUE = 0,
...
@@ -56,6 +56,26 @@ enum COLORFEATURES {BLUE = 0,
class
PublisherVisionDebug
:
public
Publisher
class
PublisherVisionDebug
:
public
Publisher
{
{
public:
PublisherVisionDebug
(
const
std
::
string
&
_unique_name
,
const
ParamsServer
&
_server
,
const
ProblemPtr
_problem
);
WOLF_PUBLISHER_CREATE
(
PublisherVisionDebug
);
virtual
~
PublisherVisionDebug
(){};
void
initialize
(
ros
::
NodeHandle
&
nh
,
const
std
::
string
&
topic
)
override
;
bool
ready
()
override
;
void
publishDerived
()
override
;
protected
:
ProcessorVisualOdometryPtr
processor_vision_
;
CaptureBasePtr
last_capture_
;
image_transport
::
Publisher
publisher_image_
;
image_transport
::
ImageTransport
img_transport_
;
private
:
private
:
/*
/*
Function that search for the maximum and minimum of features in one track in the track matrix
Function that search for the maximum and minimum of features in one track in the track matrix
...
@@ -73,29 +93,11 @@ class PublisherVisionDebug : public Publisher
...
@@ -73,29 +93,11 @@ class PublisherVisionDebug : public Publisher
*/
*/
void
showTracks
(
cv
::
Mat
_image
,
const
TrackMatrix
&
_track_matrix
,
CaptureBasePtr
_cap_img
,
COLORFEATURES
_color_of_features
,
bool
_show_track_ID
);
void
showTracks
(
cv
::
Mat
_image
,
const
TrackMatrix
&
_track_matrix
,
CaptureBasePtr
_cap_img
,
COLORFEATURES
_color_of_features
,
bool
_show_track_ID
);
Eigen
::
Matrix
<
double
,
2
,
1
>
getPixelLandmark
(
LandmarkBasePtr
_lmk
,
CaptureBasePtr
_capture
);
Eigen
::
Vector2d
getPixelLandmark
(
const
LandmarkBasePtr
_lmk
,
const
CaptureBasePtr
_capture
)
const
;
Eigen
::
Matrix
<
double
,
3
,
4
>
getProjectionMatrix
(
CaptureBasePtr
_capture
);
Eigen
::
Matrix
<
double
,
3
,
4
>
getProjectionMatrix
(
const
CaptureBasePtr
_capture
)
const
;
Eigen
::
Matrix
<
double
,
4
,
4
>
getT_c_w
(
CaptureBasePtr
_capture
);
Eigen
::
Isometry3d
getTcw
(
const
CaptureBasePtr
_capture
)
const
;
Eigen
::
Matrix4d
getTcwMatrix
(
const
CaptureBasePtr
_capture
)
const
;
protected:
ProcessorVisualOdometryPtr
processor_vision_
;
CaptureBasePtr
last_capture_
;
public:
image_transport
::
Publisher
publisher_image_
;
image_transport
::
ImageTransport
it_
;
PublisherVisionDebug
(
const
std
::
string
&
_unique_name
,
const
ParamsServer
&
_server
,
const
ProblemPtr
_problem
);
WOLF_PUBLISHER_CREATE
(
PublisherVisionDebug
);
virtual
~
PublisherVisionDebug
(){};
void
initialize
(
ros
::
NodeHandle
&
nh
,
const
std
::
string
&
topic
)
override
;
bool
ready
()
override
;
void
publishDerived
()
override
;
};
};
WOLF_REGISTER_PUBLISHER
(
PublisherVisionDebug
)
WOLF_REGISTER_PUBLISHER
(
PublisherVisionDebug
)
...
...
This diff is collapsed.
Click to expand it.
src/publisher_vision.cpp
+
19
−
14
View file @
46f7bf3c
...
@@ -45,7 +45,7 @@ PublisherVisionDebug::PublisherVisionDebug(const std::string &_unique_name,
...
@@ -45,7 +45,7 @@ PublisherVisionDebug::PublisherVisionDebug(const std::string &_unique_name,
Publisher
(
_unique_name
,
_server
,
_problem
),
Publisher
(
_unique_name
,
_server
,
_problem
),
processor_vision_
(
nullptr
),
processor_vision_
(
nullptr
),
last_capture_
(
nullptr
),
last_capture_
(
nullptr
),
it_
(
ros
::
NodeHandle
())
i
mg_transpor
t_
(
ros
::
NodeHandle
())
{
{
// if user do not provide processor's name, first processor of type PublisherVisionDebug is taken
// if user do not provide processor's name, first processor of type PublisherVisionDebug is taken
auto
processor_name
=
getParamWithDefault
<
std
::
string
>
(
_server
,
prefix_
+
"/processor_name"
,
""
);
auto
processor_name
=
getParamWithDefault
<
std
::
string
>
(
_server
,
prefix_
+
"/processor_name"
,
""
);
...
@@ -70,8 +70,8 @@ PublisherVisionDebug::PublisherVisionDebug(const std::string &_unique_name,
...
@@ -70,8 +70,8 @@ PublisherVisionDebug::PublisherVisionDebug(const std::string &_unique_name,
void
PublisherVisionDebug
::
initialize
(
ros
::
NodeHandle
&
nh
,
const
std
::
string
&
topic
)
void
PublisherVisionDebug
::
initialize
(
ros
::
NodeHandle
&
nh
,
const
std
::
string
&
topic
)
{
{
it_
=
image_transport
::
ImageTransport
(
nh
);
i
mg_transpor
t_
=
image_transport
::
ImageTransport
(
nh
);
publisher_image_
=
it_
.
advertise
(
topic
,
10
);
publisher_image_
=
i
mg_transpor
t_
.
advertise
(
topic
,
10
);
}
}
bool
PublisherVisionDebug
::
ready
()
bool
PublisherVisionDebug
::
ready
()
...
@@ -215,9 +215,12 @@ std::vector<int> PublisherVisionDebug::colorTrackAndFeatures(int _nb_feature_in_
...
@@ -215,9 +215,12 @@ std::vector<int> PublisherVisionDebug::colorTrackAndFeatures(int _nb_feature_in_
color
[
2
]
=
color
[
0
];
color
[
2
]
=
color
[
0
];
break
;
break
;
case
CYAN
:
case
CYAN
:
{
int
col_tmp
=
color
[
2
];
color
[
2
]
=
color
[
0
];
color
[
2
]
=
color
[
0
];
color
[
0
]
=
color
[
1
];
color
[
0
]
=
color
[
1
];
color
[
1
]
=
color
[
2
];
color
[
1
]
=
col_tmp
;
}
break
;
break
;
case
GREY
:
case
GREY
:
color
[
2
]
=
color
[
0
];
color
[
2
]
=
color
[
0
];
...
@@ -320,23 +323,25 @@ void PublisherVisionDebug::showTracks(cv::Mat _image,
...
@@ -320,23 +323,25 @@ void PublisherVisionDebug::showTracks(cv::Mat _image,
}
}
}
}
Eigen
::
Matrix
<
double
,
4
,
4
>
PublisherVisionDebug
::
getT
_c_w
(
CaptureBasePtr
_capture
)
Eigen
::
Isometry3d
PublisherVisionDebug
::
getT
cw
(
const
CaptureBasePtr
_capture
)
const
{
{
auto
state
=
_capture
->
getProblem
()
->
getState
(
_capture
->
getTimeStamp
());
auto
state
=
_capture
->
getProblem
()
->
getState
(
_capture
->
getTimeStamp
());
auto
pos
=
state
[
'P'
];
auto
pos
=
state
[
'P'
];
auto
orientation
=
state
[
'O'
].
data
();
auto
orientation
=
state
[
'O'
].
data
();
Transform
<
double
,
3
,
Isometry
>
T_w_r
=
Translation
<
double
,
3
>
(
pos
)
*
Quaterniond
(
orientation
);
Eigen
::
Isometry
3d
T_w_r
=
Translation
<
double
,
3
>
(
pos
)
*
Quaterniond
(
orientation
);
Transform
<
double
,
3
,
Isometry
>
T_r_c
=
Translation
<
double
,
3
>
(
_capture
->
getSensorP
()
->
getState
())
Eigen
::
Isometry
3d
T_r_c
=
Translation
<
double
,
3
>
(
_capture
->
getSensorP
()
->
getState
())
*
Quaterniond
(
_capture
->
getSensorO
()
->
getState
().
data
());
*
Quaterniond
(
_capture
->
getSensorO
()
->
getState
().
data
());
Transform
<
double
,
3
,
Isometry
>
T_c_w
=
(
T_w_r
*
T_r_c
).
inverse
();
return
(
T_w_r
*
T_r_c
).
inverse
();
Eigen
::
Matrix
<
double
,
4
,
4
>
T_c_w_Matrix
(
T_c_w
.
matrix
());
}
return
T_c_w_Matrix
;
Eigen
::
Matrix4d
PublisherVisionDebug
::
getTcwMatrix
(
const
CaptureBasePtr
_capture
)
const
{
return
getTcw
(
_capture
).
matrix
();
}
}
Eigen
::
Matrix
<
double
,
3
,
4
>
PublisherVisionDebug
::
getProjectionMatrix
(
CaptureBasePtr
_capture
)
Eigen
::
Matrix
<
double
,
3
,
4
>
PublisherVisionDebug
::
getProjectionMatrix
(
const
CaptureBasePtr
_capture
)
const
{
{
auto
k
(
_capture
->
getSensor
()
->
getIntrinsic
()
->
getState
());
auto
k
(
_capture
->
getSensor
()
->
getIntrinsic
()
->
getState
());
Eigen
::
Matrix
<
double
,
3
,
4
>
P
;
Eigen
::
Matrix
<
double
,
3
,
4
>
P
;
...
@@ -346,12 +351,12 @@ Eigen::Matrix<double, 3, 4> PublisherVisionDebug::getProjectionMatrix(CaptureBas
...
@@ -346,12 +351,12 @@ Eigen::Matrix<double, 3, 4> PublisherVisionDebug::getProjectionMatrix(CaptureBas
return
P
;
return
P
;
}
}
Eigen
::
Matrix
<
double
,
2
,
1
>
PublisherVisionDebug
::
getPixelLandmark
(
LandmarkBasePtr
_lmk
,
CaptureBasePtr
_capture
)
Eigen
::
Vector2d
PublisherVisionDebug
::
getPixelLandmark
(
const
LandmarkBasePtr
_lmk
,
const
CaptureBasePtr
_capture
)
const
{
{
auto
pos
=
_lmk
->
getP
()
->
getState
();
auto
pos
=
_lmk
->
getP
()
->
getState
();
Eigen
::
Matrix
<
double
,
3
,
1
>
pixel_position3
=
getProjectionMatrix
(
_capture
)
*
getT
_c_w
(
_capture
)
*
pos
;
Eigen
::
Vector3d
pixel_position3
=
getProjectionMatrix
(
_capture
)
*
getT
cwMatrix
(
_capture
)
*
pos
;
Eigen
::
Matrix
<
double
,
2
,
1
>
pixel_position
;
Eigen
::
Vector2d
pixel_position
;
pixel_position
<<
pixel_position3
(
0
)
/
pixel_position3
(
2
),
pixel_position3
(
1
)
/
pixel_position3
(
2
);
pixel_position
<<
pixel_position3
(
0
)
/
pixel_position3
(
2
),
pixel_position3
(
1
)
/
pixel_position3
(
2
);
return
pixel_position
;
return
pixel_position
;
...
...
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