Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iri_safe_cmd
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
navigation
iri_safe_cmd
Commits
d71f74cf
Commit
d71f74cf
authored
11 years ago
by
Martí Morta Garriga
Browse files
Options
Downloads
Patches
Plain Diff
Use std::min. Changed params
parent
eed025e1
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/safe_cmd_alg_node.h
+4
-0
4 additions, 0 deletions
include/safe_cmd_alg_node.h
src/safe_cmd_alg_node.cpp
+17
-17
17 additions, 17 deletions
src/safe_cmd_alg_node.cpp
with
21 additions
and
17 deletions
include/safe_cmd_alg_node.h
+
4
−
0
View file @
d71f74cf
...
...
@@ -32,6 +32,8 @@
#include
<geometry_msgs/Twist.h>
#include
<sensor_msgs/LaserScan.h>
#include
<algorithm>
// [service client headers]
// [action server client headers]
...
...
@@ -70,6 +72,8 @@ class SafeCmdAlgNode : public algorithm_base::IriBaseAlgorithm<SafeCmdAlgorithm>
float
min_dist_
;
float
max_vel_front_
;
float
max_vel_rear_
;
float
limit_vel_front_
;
float
limit_vel_rear_
;
float
compute_max_velocity_
(
const
sensor_msgs
::
LaserScan
::
ConstPtr
&
scan
)
const
;
public:
...
...
This diff is collapsed.
Click to expand it.
src/safe_cmd_alg_node.cpp
+
17
−
17
View file @
d71f74cf
...
...
@@ -3,9 +3,11 @@
SafeCmdAlgNode
::
SafeCmdAlgNode
(
void
)
:
algorithm_base
::
IriBaseAlgorithm
<
SafeCmdAlgorithm
>
(),
collision_time_
(
1
),
min_dist_
(
0.3
),
max_vel_front_
(
5
),
max_vel_rear_
(
-
5
)
min_dist_
(
0.4
),
max_vel_front_
(
7
),
max_vel_rear_
(
7
),
limit_vel_front_
(
7
),
limit_vel_rear_
(
7
)
{
//init class attributes if necessary
loop_rate_
=
20
;
//in [Hz]
...
...
@@ -39,15 +41,15 @@ void SafeCmdAlgNode::mainNodeThread(void)
if
(
!
alg_
.
config_
.
unsafe
)
{
if
(
Twist_msg_
.
linear
.
x
>
max_vel_front_
)
if
(
Twist_msg_
.
linear
.
x
>
fabs
(
max_vel_front_
)
)
{
Twist_msg_
.
linear
.
x
=
max_vel_front_
;
Twist_msg_
.
linear
.
x
=
fabs
(
max_vel_front_
)
;
ROS_WARN
(
"heading to front obstacle, reducing velocity"
);
}
if
(
Twist_msg_
.
linear
.
x
<
max_vel_rear_
)
if
(
Twist_msg_
.
linear
.
x
<
-
fabs
(
max_vel_rear_
)
)
{
Twist_msg_
.
linear
.
x
=
max_vel_rear_
;
Twist_msg_
.
linear
.
x
=
-
fabs
(
max_vel_rear_
)
;
ROS_WARN
(
"heading to rear obstacle, reducing velocity"
);
}
}
...
...
@@ -98,7 +100,7 @@ void SafeCmdAlgNode::rear_laser_callback(const sensor_msgs::LaserScan::ConstPtr&
//this->alg_.lock();
//this->rear_laser_mutex_.enter();
max_vel_rear_
=
-
compute_max_velocity_
(
msg
);
max_vel_rear_
=
std
::
min
(
compute_max_velocity_
(
msg
)
,
limit_vel_rear_
)
;
//ROS_INFO("Max vel r: %f",max_vel_rear_);
//unlock previously blocked shared variables
...
...
@@ -113,7 +115,7 @@ void SafeCmdAlgNode::front_laser_callback(const sensor_msgs::LaserScan::ConstPtr
//this->alg_.lock();
//this->front_laser_mutex_.enter();
max_vel_front_
=
compute_max_velocity_
(
msg
);
max_vel_front_
=
std
::
min
(
compute_max_velocity_
(
msg
)
,
limit_vel_front_
)
;
//ROS_INFO("Max vel f: %f",max_vel_front_);
//unlock previously blocked shared variables
...
...
@@ -146,16 +148,14 @@ int main(int argc,char *argv[])
float
SafeCmdAlgNode
::
compute_max_velocity_
(
const
sensor_msgs
::
LaserScan
::
ConstPtr
&
scan
)
const
{
float
max_velocity
=
5
;
float
max_velocity
;
for
(
uint
i
=
0
;
i
<
scan
->
ranges
.
size
();
i
++
)
{
if
(
scan
->
ranges
[
i
]
<
min_dist_
)
max_velocity
=
0
;
if
(
scan
->
ranges
[
i
]
/
collision_time_
<
max_velocity
)
max_velocity
=
scan
->
ranges
[
i
]
/
collision_time_
;
}
float
min_range
=
*
std
::
min_element
(
scan
->
ranges
.
begin
(),
scan
->
ranges
.
end
()
);
if
(
min_range
<
min_dist_
)
max_velocity
=
0
;
else
max_velocity
=
min_range
/
collision_time_
;
return
max_velocity
;
}
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