Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
motion plan
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
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
Romina Parada
motion plan
Commits
6ac1dad4
Commit
6ac1dad4
authored
3 years ago
by
Romina Parada
Browse files
Options
Downloads
Patches
Plain Diff
Add follow left wall
parent
b35630f1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test.py
+22
-20
22 additions, 20 deletions
src/test.py
with
22 additions
and
20 deletions
src/test.py
+
22
−
20
View file @
6ac1dad4
...
@@ -19,11 +19,13 @@ regions_ = {
...
@@ -19,11 +19,13 @@ regions_ = {
}
}
state_
=
0
state_
=
0
state_dir_
=
-
1
state_dict_
=
{
state_dict_
=
{
0
:
'
find the wall
'
,
0
:
'
find the wall
'
,
1
:
'
turn
left
'
,
1
:
'
turn
'
,
2
:
'
follow the wall
'
,
2
:
'
follow the wall
'
,
}
}
state_description_
=
''
def
clbk_laser
(
msg
):
def
clbk_laser
(
msg
):
global
regions_
global
regions_
...
@@ -38,45 +40,45 @@ def clbk_laser(msg):
...
@@ -38,45 +40,45 @@ def clbk_laser(msg):
take_action
()
take_action
()
def
change_state
(
state
):
def
change_state
(
state
):
global
state_
,
state_dict_
global
state_
,
state_dict_
,
state_description_
if
state
is
not
state_
:
if
state
is
not
state_
:
print
(
'
State of Bot - [%s] - %s
'
%
(
state
,
state_dict_
[
state
]))
print
(
'
State of Bot - [%s] -
%s -
%s
'
%
(
state
,
state_dict_
[
state
]
,
state_description_
))
state_
=
state
state_
=
state
def
take_action
():
def
take_action
():
global
regions_
global
regions_
,
state_description_
,
state_dir_
regions
=
regions_
regions
=
regions_
msg
=
Twist
()
msg
=
Twist
()
linear_x
=
0
linear_x
=
0
angular_z
=
0
angular_z
=
0
state_description
=
''
d
=
1.5
d
=
1.5
if
regions
[
'
front
'
]
>
d
and
regions
[
'
fleft
'
]
>
d
and
regions
[
'
fright
'
]
>
d
:
if
regions
[
'
front
'
]
>
d
and
regions
[
'
fleft
'
]
>
d
and
regions
[
'
fright
'
]
>
d
:
state_description
=
'
case 1 - nothing
'
state_description
_
=
'
case 1 - nothing
'
change_state
(
0
)
change_state
(
0
)
elif
regions
[
'
front
'
]
<
d
and
regions
[
'
fleft
'
]
>
d
and
regions
[
'
fright
'
]
>
d
:
elif
regions
[
'
front
'
]
<
d
and
regions
[
'
fleft
'
]
>
d
and
regions
[
'
fright
'
]
>
d
:
state_description
=
'
case 2 - front
'
state_description
_
=
'
case 2 - front
'
change_state
(
1
)
change_state
(
1
)
elif
regions
[
'
front
'
]
>
d
and
regions
[
'
fleft
'
]
>
d
and
regions
[
'
fright
'
]
<
d
:
elif
regions
[
'
front
'
]
>
d
and
regions
[
'
fleft
'
]
>
d
and
regions
[
'
fright
'
]
<
d
:
state_description
=
'
case 3 - fright
'
state_description_
=
'
case 3 - fright
'
state_dir_
=
-
1
change_state
(
2
)
change_state
(
2
)
elif
regions
[
'
front
'
]
>
d
and
regions
[
'
fleft
'
]
<
d
and
regions
[
'
fright
'
]
>
d
:
elif
regions
[
'
front
'
]
>
d
and
regions
[
'
fleft
'
]
<
d
and
regions
[
'
fright
'
]
>
d
:
state_description
=
'
case 4 - fleft
'
state_description_
=
'
case 4 - fleft
'
change_state
(
0
)
state_dir_
=
1
change_state
(
2
)
elif
regions
[
'
front
'
]
<
d
and
regions
[
'
fleft
'
]
>
d
and
regions
[
'
fright
'
]
<
d
:
elif
regions
[
'
front
'
]
<
d
and
regions
[
'
fleft
'
]
>
d
and
regions
[
'
fright
'
]
<
d
:
state_description
=
'
case 5 - front and fright
'
state_description
_
=
'
case 5 - front and fright
'
change_state
(
1
)
change_state
(
1
)
elif
regions
[
'
front
'
]
<
d
and
regions
[
'
fleft
'
]
<
d
and
regions
[
'
fright
'
]
>
d
:
elif
regions
[
'
front
'
]
<
d
and
regions
[
'
fleft
'
]
<
d
and
regions
[
'
fright
'
]
>
d
:
state_description
=
'
case 6 - front and fleft
'
state_description
_
=
'
case 6 - front and fleft
'
change_state
(
1
)
change_state
(
1
)
elif
regions
[
'
front
'
]
<
d
and
regions
[
'
fleft
'
]
<
d
and
regions
[
'
fright
'
]
<
d
:
elif
regions
[
'
front
'
]
<
d
and
regions
[
'
fleft
'
]
<
d
and
regions
[
'
fright
'
]
<
d
:
state_description
=
'
case 7 - front and fleft and fright
'
state_description
_
=
'
case 7 - front and fleft and fright
'
change_state
(
1
)
change_state
(
1
)
elif
regions
[
'
front
'
]
>
d
and
regions
[
'
fleft
'
]
<
d
and
regions
[
'
fright
'
]
<
d
:
elif
regions
[
'
front
'
]
>
d
and
regions
[
'
fleft
'
]
<
d
and
regions
[
'
fright
'
]
<
d
:
state_description
=
'
case 8 - fleft and fright
'
state_description
_
=
'
case 8 - fleft and fright
'
change_state
(
0
)
change_state
(
0
)
else
:
else
:
state_description
=
'
unknown case
'
state_description
=
'
unknown case
'
...
@@ -85,12 +87,12 @@ def take_action():
...
@@ -85,12 +87,12 @@ def take_action():
def
find_wall
():
def
find_wall
():
msg
=
Twist
()
msg
=
Twist
()
msg
.
linear
.
x
=
0.2
msg
.
linear
.
x
=
0.2
msg
.
angular
.
z
=
-
0.3
msg
.
angular
.
z
=
state_dir_
*
0.3
return
msg
return
msg
def
turn
_left
():
def
turn
():
msg
=
Twist
()
msg
=
Twist
()
msg
.
angular
.
z
=
0.3
msg
.
angular
.
z
=
state_dir_
*-
0.3
return
msg
return
msg
def
follow_the_wall
():
def
follow_the_wall
():
...
@@ -105,7 +107,7 @@ def main():
...
@@ -105,7 +107,7 @@ def main():
pub_
=
rospy
.
Publisher
(
'
/cmd_vel
'
,
Twist
,
queue_size
=
1
)
pub_
=
rospy
.
Publisher
(
'
/cmd_vel
'
,
Twist
,
queue_size
=
1
)
sub
=
rospy
.
Subscriber
(
'
/
front/
scan
'
,
LaserScan
,
clbk_laser
)
sub
=
rospy
.
Subscriber
(
'
/scan
'
,
LaserScan
,
clbk_laser
)
rate
=
rospy
.
Rate
(
20
)
rate
=
rospy
.
Rate
(
20
)
while
not
rospy
.
is_shutdown
():
while
not
rospy
.
is_shutdown
():
...
@@ -113,7 +115,7 @@ def main():
...
@@ -113,7 +115,7 @@ def main():
if
state_
==
0
:
if
state_
==
0
:
msg
=
find_wall
()
msg
=
find_wall
()
elif
state_
==
1
:
elif
state_
==
1
:
msg
=
turn
_left
()
msg
=
turn
()
elif
state_
==
2
:
elif
state_
==
2
:
msg
=
follow_the_wall
()
msg
=
follow_the_wall
()
pass
pass
...
...
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