Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Hochautomatisiertes-Fahren
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Philipp Badenhoop
Hochautomatisiertes-Fahren
Commits
b251ff36
Commit
b251ff36
authored
6 years ago
by
Hoop77
Browse files
Options
Downloads
Patches
Plain Diff
-
parent
149a89b4
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/catkin_ws/src/VeloxProtocolLib/test/TerminalControl.cpp
+9
-0
9 additions, 0 deletions
...s/catkin_ws/src/VeloxProtocolLib/test/TerminalControl.cpp
scripts/remote_control.py
+34
-1
34 additions, 1 deletion
scripts/remote_control.py
with
43 additions
and
1 deletion
modules/catkin_ws/src/VeloxProtocolLib/test/TerminalControl.cpp
+
9
−
0
View file @
b251ff36
...
...
@@ -8,6 +8,7 @@
#include
<fstream>
#include
"ultrasonic/UltrasonicSensor.h"
#include
"tools/StreamMeanFilter.h"
#include
"NetworkingLib/DatagramSender.h"
constexpr
bool
usesPid
{
true
};
...
...
@@ -58,6 +59,7 @@ int readDevId()
int
main
(
int
argc
,
char
**
argv
)
{
using
namespace
veloxProtocol
;
using
namespace
std
::
chrono_literals
;
networking
::
Networking
net
;
std
::
atomic
<
bool
>
monitorSTM
{
false
};
std
::
atomic
<
bool
>
monitorUSS
{
false
};
...
...
@@ -66,6 +68,8 @@ int main(int argc, char ** argv)
std
::
mutex
outputMutex
;
auto
sensor
=
UltrasonicSensor
::
create
(
net
,
readDevId
());
car
::
StreamMeanFilter
streamMeanFilter
{
5
};
auto
timer
=
networking
::
time
::
Timer
::
create
(
net
);
auto
sender
=
networking
::
message
::
DatagramSender
<
std
::
string
>::
create
(
net
);
auto
conn
=
Connection
::
create
(
net
);
conn
->
open
(
"/dev/ttySAC0"
,
...
...
@@ -79,6 +83,11 @@ int main(int argc, char ** argv)
<<
"
\n
Steering Angle: "
<<
conn
->
getMeasuredSteeringAngle
().
get
()
<<
"
\n\n
"
;
},
[]
{});
timer
->
startPeriodicTimeout
(
10ms
,
[
&
]
{
sender
->
send
(
std
::
to_string
(
conn
->
getMeasuredSpeed
().
get
()),
"10.5.33.26"
,
10150
,
1ms
);
});
sensor
->
start
(
[
&
](
auto
distance
)
{
...
...
This diff is collapsed.
Click to expand it.
scripts/remote_control.py
+
34
−
1
View file @
b251ff36
...
...
@@ -2,6 +2,9 @@ import pygame
import
sys
from
pexpect
import
pxssh
from
pygame.locals
import
*
import
threading
import
socket
import
sys
ODROID_HOST_ADDRESS
=
"
10.5.37.177
"
...
...
@@ -94,10 +97,37 @@ class Button:
surf
.
blit
(
text
,
text_rect
)
speedLock
=
threading
.
Lock
()
speed
=
0
def
receive_speed
():
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
server_address
=
(
'
0.0.0.0
'
,
10150
)
sock
.
bind
(
server_address
)
while
True
:
data
,
address
=
sock
.
recvfrom
(
30
)
if
data
:
print
(
data
)
speedLock
.
acquire
()
speed
=
float
(
data
[
4
:])
speedLock
.
release
()
def
renderSpeed
(
surf
):
font
=
pygame
.
font
.
Font
(
None
,
36
)
speedLock
.
acquire
()
text
=
font
.
render
(
str
(
speed
),
True
,
(
10
,
10
,
10
))
speedLock
.
release
()
text_rect
=
text
.
get_rect
()
surf
.
blit
(
text
,
text_rect
)
if
__name__
==
'
__main__
'
:
conn
=
OdroidConnection
(
ODROID_HOST_ADDRESS
,
"
/root/repos/Hochautomatisiertes-Fahren/modules/catkin_ws/src/VeloxProtocolLib/cmake-build-debug/TerminalControl
"
)
conn
.
connect
()
threading
.
Thread
(
target
=
receive_speed
)
FPS
=
60
pygame
.
init
()
fpsClock
=
pygame
.
time
.
Clock
()
...
...
@@ -120,7 +150,7 @@ if __name__ == '__main__':
buttonsSurface
=
buttonsSurface
.
convert
()
buttonsSurface
.
fill
(
BACKGROUND_COLOR
)
SPEED
=
1
SPEED
=
0.6
ANGLE
=
20
ZERO_SPEED
=
0
ZERO_ANGLE
=
-
4
...
...
@@ -184,6 +214,9 @@ if __name__ == '__main__':
button
.
draw
(
buttonsSurface
)
background
.
blit
(
buttonsSurface
,
buttons_rect
)
renderSpeed
(
background
)
screen
.
blit
(
background
,
(
0
,
0
))
pygame
.
display
.
update
()
fpsClock
.
tick
(
FPS
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
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