Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iri_ana_nav_module
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
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
robots
ana
iri_ana_nav_module
Commits
ef896d2d
Commit
ef896d2d
authored
5 years ago
by
José Enrique Domínguez Vidal
Browse files
Options
Downloads
Patches
Plain Diff
get_distance_to_goal added
parent
347b00f8
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
include/iri_ana_nav_module/iri_ana_nav_module_bt.h
+2
-0
2 additions, 0 deletions
include/iri_ana_nav_module/iri_ana_nav_module_bt.h
src/iri_ana_nav_module_bt.cpp
+48
-0
48 additions, 0 deletions
src/iri_ana_nav_module_bt.cpp
with
50 additions
and
0 deletions
include/iri_ana_nav_module/iri_ana_nav_module_bt.h
+
2
−
0
View file @
ef896d2d
...
@@ -494,6 +494,8 @@ class CIriAnaNavModuleBT
...
@@ -494,6 +494,8 @@ class CIriAnaNavModuleBT
*
*
*/
*/
BT
::
NodeStatus
costmaps_clear
();
BT
::
NodeStatus
costmaps_clear
();
BT
::
NodeStatus
get_distance_to_goal
(
BT
::
TreeNode
&
self
);
/**
/**
* \brief Enable the autoclear of the costmaps
* \brief Enable the autoclear of the costmaps
*
*
...
...
This diff is collapsed.
Click to expand it.
src/iri_ana_nav_module_bt.cpp
+
48
−
0
View file @
ef896d2d
...
@@ -27,6 +27,7 @@ void CIriAnaNavModuleBT::init(IriBehaviorTreeFactory &factory)
...
@@ -27,6 +27,7 @@ void CIriAnaNavModuleBT::init(IriBehaviorTreeFactory &factory)
BT
::
PortsList
costmap_port
=
{
BT
::
InputPort
<
double
>
(
"rate_hz"
)
};
BT
::
PortsList
costmap_port
=
{
BT
::
InputPort
<
double
>
(
"rate_hz"
)
};
BT
::
PortsList
recovery_port
=
{
BT
::
InputPort
<
bool
>
(
"recovery_active"
)
};
BT
::
PortsList
recovery_port
=
{
BT
::
InputPort
<
bool
>
(
"recovery_active"
)
};
BT
::
PortsList
success_port
=
{
BT
::
InputPort
<
bool
>
(
"goal_reached"
)
};
BT
::
PortsList
success_port
=
{
BT
::
InputPort
<
bool
>
(
"goal_reached"
)
};
BT
::
PortsList
distance_port
=
{
BT
::
InputPort
<
double
>
(
"x"
),
BT
::
InputPort
<
double
>
(
"y"
),
BT
::
InputPort
<
double
>
(
"dist_threshold"
)
};
// registry of conditions
// registry of conditions
factory
.
registerSimpleCondition
(
"is_goal_succeded"
,
std
::
bind
(
&
CIriAnaNavModuleBT
::
is_goal_succeded
,
this
,
std
::
placeholders
::
_1
),
success_port
);
factory
.
registerSimpleCondition
(
"is_goal_succeded"
,
std
::
bind
(
&
CIriAnaNavModuleBT
::
is_goal_succeded
,
this
,
std
::
placeholders
::
_1
),
success_port
);
...
@@ -57,6 +58,7 @@ void CIriAnaNavModuleBT::init(IriBehaviorTreeFactory &factory)
...
@@ -57,6 +58,7 @@ void CIriAnaNavModuleBT::init(IriBehaviorTreeFactory &factory)
factory
.
registerSimpleAction
(
"costmaps_enable_auto_clear"
,
std
::
bind
(
&
CIriAnaNavModuleBT
::
costmaps_enable_auto_clear
,
this
,
std
::
placeholders
::
_1
),
costmap_port
);
factory
.
registerSimpleAction
(
"costmaps_enable_auto_clear"
,
std
::
bind
(
&
CIriAnaNavModuleBT
::
costmaps_enable_auto_clear
,
this
,
std
::
placeholders
::
_1
),
costmap_port
);
factory
.
registerSimpleAction
(
"costmaps_disable_auto_clear"
,
std
::
bind
(
&
CIriAnaNavModuleBT
::
costmaps_disable_auto_clear
,
this
));
factory
.
registerSimpleAction
(
"costmaps_disable_auto_clear"
,
std
::
bind
(
&
CIriAnaNavModuleBT
::
costmaps_disable_auto_clear
,
this
));
factory
.
registerSimpleAction
(
"reset_goal_variables"
,
std
::
bind
(
&
CIriAnaNavModuleBT
::
reset_goal_variables
,
this
));
factory
.
registerSimpleAction
(
"reset_goal_variables"
,
std
::
bind
(
&
CIriAnaNavModuleBT
::
reset_goal_variables
,
this
));
factory
.
registerSimpleAction
(
"get_distance_to_goal"
,
std
::
bind
(
&
CIriAnaNavModuleBT
::
get_distance_to_goal
,
this
,
std
::
placeholders
::
_1
),
distance_port
);
// registry of asynchronous actions
// registry of asynchronous actions
factory
.
registerIriAsyncAction
(
"async_go_to_orientation"
,
std
::
bind
(
&
CIriAnaNavModuleBT
::
async_go_to_orientation
,
this
,
std
::
placeholders
::
_1
),
async_orientation_port
);
factory
.
registerIriAsyncAction
(
"async_go_to_orientation"
,
std
::
bind
(
&
CIriAnaNavModuleBT
::
async_go_to_orientation
,
this
,
std
::
placeholders
::
_1
),
async_orientation_port
);
factory
.
registerIriAsyncAction
(
"async_go_to_position"
,
std
::
bind
(
&
CIriAnaNavModuleBT
::
async_go_to_position
,
this
,
std
::
placeholders
::
_1
),
async_position_port
);
factory
.
registerIriAsyncAction
(
"async_go_to_position"
,
std
::
bind
(
&
CIriAnaNavModuleBT
::
async_go_to_position
,
this
,
std
::
placeholders
::
_1
),
async_position_port
);
...
@@ -721,6 +723,52 @@ BT::NodeStatus CIriAnaNavModuleBT::costmaps_clear()
...
@@ -721,6 +723,52 @@ BT::NodeStatus CIriAnaNavModuleBT::costmaps_clear()
return
BT
::
NodeStatus
::
SUCCESS
;
return
BT
::
NodeStatus
::
SUCCESS
;
}
}
BT
::
NodeStatus
CIriAnaNavModuleBT
::
get_distance_to_goal
(
BT
::
TreeNode
&
self
)
{
ROS_INFO
(
"get_distance_to_goal"
);
geometry_msgs
::
Pose
current_pose
=
nav
.
getCurrentPose
();
BT
::
Optional
<
double
>
x_input
=
self
.
getInput
<
double
>
(
"x"
);
BT
::
Optional
<
double
>
y_input
=
self
.
getInput
<
double
>
(
"y"
);
BT
::
Optional
<
double
>
dist_threshold_input
=
self
.
getInput
<
double
>
(
"dist_threshold"
);
if
(
!
x_input
)
{
ROS_ERROR
(
"Incorrect or missing required input [x]"
);
return
BT
::
NodeStatus
::
FAILURE
;
}
if
(
!
y_input
)
{
ROS_ERROR
(
"Incorrect or missing required input [y]"
);
return
BT
::
NodeStatus
::
FAILURE
;
}
if
(
!
dist_threshold_input
)
{
ROS_ERROR
(
"Incorrect or missing required input [dist_threshold]"
);
return
BT
::
NodeStatus
::
FAILURE
;
}
double
x_goal
=
x_input
.
value
();
double
y_goal
=
y_input
.
value
();
double
dist_threshold
=
dist_threshold_input
.
value
();
double
x_current
=
current_pose
.
position
.
x
;
double
y_current
=
current_pose
.
position
.
y
;
ROS_INFO
(
"The current pose is: x-> [%f], y-> [%f], yaw-> [%f]"
,
current_pose
.
position
.
x
,
current_pose
.
position
.
y
,
tf
::
getYaw
(
current_pose
.
orientation
));
float
distance_to_goal
=
sqrt
((
x_goal
-
x_current
)
*
(
x_goal
-
x_current
)
+
(
y_goal
-
y_current
)
*
(
y_goal
-
y_current
));
ROS_INFO
(
"The distance is: %f"
,
distance_to_goal
);
if
(
distance_to_goal
<
dist_threshold
)
{
return
BT
::
NodeStatus
::
FAILURE
;
}
return
BT
::
NodeStatus
::
SUCCESS
;
}
BT
::
NodeStatus
CIriAnaNavModuleBT
::
costmaps_enable_auto_clear
(
BT
::
TreeNode
&
self
)
BT
::
NodeStatus
CIriAnaNavModuleBT
::
costmaps_enable_auto_clear
(
BT
::
TreeNode
&
self
)
{
{
ROS_INFO
(
"costmaps_enable_auto_clear"
);
ROS_INFO
(
"costmaps_enable_auto_clear"
);
...
...
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