Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CPS_project_group13
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Hierck, J.J. (Jelle, Student M-BME,M-EMSYS)
CPS_project_group13
Commits
1a41c6b3
Commit
1a41c6b3
authored
4 years ago
by
SiccoColijn
Browse files
Options
Downloads
Patches
Plain Diff
fixed some stuff
parent
c3b64a43
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mappingbot/driving.py
+16
-13
16 additions, 13 deletions
mappingbot/driving.py
with
16 additions
and
13 deletions
mappingbot/driving.py
+
16
−
13
View file @
1a41c6b3
...
...
@@ -3,14 +3,15 @@ import RPi.GPIO as GPIO
import
time
from
encoder
import
Encoder
#import PWMoutputFunction
GPIO
.
cleanup
()
# GPIO Mode (BOARD / BCM)
GPIO
.
setmode
(
GPIO
.
BCM
)
print
(
GPIO
.
VERSION
)
LEFTMOTORFORWARDPIN
=
12
LEFTMOTORBACKWARDPIN
=
13
RIGHTMOTORFORWARDPIN
=
20
RIGHTMOTORBACKWARDPIN
=
26
LEFTMOTORFORWARDPIN
=
20
LEFTMOTORBACKWARDPIN
=
26
RIGHTMOTORFORWARDPIN
=
12
RIGHTMOTORBACKWARDPIN
=
13
GPIO
.
setup
(
LEFTMOTORFORWARDPIN
,
GPIO
.
OUT
)
GPIO
.
setup
(
LEFTMOTORBACKWARDPIN
,
GPIO
.
OUT
)
GPIO
.
setup
(
RIGHTMOTORFORWARDPIN
,
GPIO
.
OUT
)
...
...
@@ -23,16 +24,18 @@ class Driving:
self
.
setpointPulseCuntRight
=
0
self
.
currentPulseCountLeft
=
0
self
.
currentPulseCountRight
=
0
self
.
directionLeftWheel
=
True
#true = forward
self
.
directionRightWheel
=
True
#true = forward
self
.
directionLeftWheel
=
True
#
true = forward
self
.
directionRightWheel
=
True
#
true = forward
self
.
pulsesPerRotation
=
40
self
.
pulsesPer45DegreeCarRotation
=
10
self
.
speed
=
0
#speed in PWM
percentage
self
.
rotationspeed
=
0.2
#speed in PWM
percentag
e
self
.
speed
=
0
#
speed in PWM
dutycycle, ranges from 0 to 100
self
.
rotationspeed
=
0.2
#
speed in PWM
dutycycl
e
self
.
leftPWM
=
0
self
.
rightPWM
=
0
self
.
encoderLeft
=
Encoder
(
name
=
"
encoder1
"
,
encoder_pin
=
23
)
self
.
encoderRight
=
Encoder
(
name
=
"
encoder1
"
,
encoder_pin
=
24
)
self
.
encoderLeft
=
Encoder
(
name
=
"
encoderLeft
"
,
encoder_pin
=
23
)
self
.
encoderRight
=
Encoder
(
name
=
"
encoderRight
"
,
encoder_pin
=
24
)
self
.
encoderLeft
.
init_callback
()
self
.
encoderRight
.
init_callback
()
def
stop
(
self
):
self
.
speed
=
0
...
...
@@ -82,6 +85,7 @@ class Driving:
def
getPWM
(
self
,):
self
.
currentPulseCountLeft
=
self
.
encoderLeft
.
get_pulse_count
()
self
.
currentPulseCountRight
=
self
.
encoderRight
.
get_pulse_count
()
print
(
"
pulseCnt:
"
+
str
(
self
.
currentPulseCountLeft
)
+
"
setpoint:
"
+
str
(
self
.
setpointPulseCountLeft
))
if
self
.
currentPulseCountLeft
>=
self
.
setpointPulseCountLeft
:
self
.
leftPWM
=
0
...
...
@@ -126,7 +130,7 @@ try:
leftPinB
.
start
(
0
)
rightPinF
.
start
(
0
)
rightPinB
.
start
(
0
)
motor
.
driveForward
(
30
,
1
)
motor
.
driveForward
(
30
,
50
)
while
True
:
# Update PWM to motordriver according to getPWM()
...
...
@@ -144,7 +148,6 @@ try:
else
:
rightPinB
.
ChangeDutyCycle
(
rightDC
)
rightPinF
.
ChangeDutyCycle
(
0
)
#print(leftDC)
time
.
sleep
(
0.1
)
...
...
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