Forum Replies Created
-
@alexanderb – really interesting. Thanks for sharing!
-
etutill
MemberAugust 10, 2021 at 7:54 am in reply to: If you were to design a habitat on the moon, what would it look like ?@EdenBuch – Great question. Nasa is thinking about this as well…. :
https://www.nasa.gov/feature/langley/a-new-home-on-mars-nasa-langley-s-icy-concept-for-living-on-the-red-planet -
Hey Ryan – One of the ways that vines “know” where to grow is by growing away from light or towards darkness. This is a tropism (biological effect on a plant caused by external stimuli). I’m pretty much paraphrasing wikipedia here, but, in the case of a vine, if there is a taller object near by that is blocking light, a vine would grow towards the absence of light until it reaches the object, and then grow up it. The many of the biological processes involved hinge on plant hormone production/balance. Lots of good info here for a jumping off point. https://en.wikipedia.org/wiki/Phototropism
-
Hi @janiefoz , I just found this site, but, so far it appears to be a pretty good resource for robotics related information for children (and adults):
https://www.nationalroboticsweek.org/Resources -
Now that it moves properly I need to see how well it follows lines.
-
because the rasptank has a hdmi port, usb ports and wifi I’ve edited the move.py file in two different ways.
1. By connecting to the hdmi port and using a bluetooth mouse/keyboard and editing the move.py file on the raspberrypi locally using the raspbian operating system
2. The much faster option is connecting wirelessly via ssh to the tank while it is powered up and editing the move.py file using vi through the command line interface. It’s a pain at first (I’m really rusty), but, once I got used to making a lot of changes, it made it a lot faster to make a quick file change, run the robot program, test the changes, figure out if my change was garbage, make another change, test it again, and again….
-
I havn’t even tested the cool features on this machine yet, so, more to come. @katejackson
-
-
pi@raspberrypi:~/adeept_rasptank/server $ cat move.py
#!/usr/bin/env python3
# File name : move.py
# Description : Control Motor
# Product : GWR
# Website : http://www.gewbot.com
# Author : William
# Date : 2019/07/24
import time
import RPi.GPIO as GPIO
# motor_EN_A: Pin7 | motor_EN_B: Pin11
# motor_A: Pin8,Pin10 | motor_B: Pin13,Pin12
Motor_A_EN = 4
Motor_B_EN = 17
Motor_A_Pin1 = 14
Motor_A_Pin2 = 15
Motor_B_Pin1 = 27
Motor_B_Pin2 = 18
Dir_forward = 0
Dir_backward = 1
left_forward = 1
left_backward = 0
right_forward = 1
right_backward= 0
pwm_A = 0
pwm_B = 0
def motorStop():#Motor stops
GPIO.output(Motor_A_Pin1, GPIO.LOW)
GPIO.output(Motor_A_Pin2, GPIO.LOW)
GPIO.output(Motor_B_Pin1, GPIO.LOW)
GPIO.output(Motor_B_Pin2, GPIO.LOW)
GPIO.output(Motor_A_EN, GPIO.LOW)
GPIO.output(Motor_B_EN, GPIO.LOW)
def setup():#Motor initialization
global pwm_A, pwm_B
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(Motor_A_EN, GPIO.OUT)
GPIO.setup(Motor_B_EN, GPIO.OUT)
GPIO.setup(Motor_A_Pin1, GPIO.OUT)
GPIO.setup(Motor_A_Pin2, GPIO.OUT)
GPIO.setup(Motor_B_Pin1, GPIO.OUT)
GPIO.setup(Motor_B_Pin2, GPIO.OUT)
motorStop()
try:
pwm_A = GPIO.PWM(Motor_A_EN, 1000)
pwm_B = GPIO.PWM(Motor_B_EN, 1000)
except:
pass
def motor_left(status, direction, speed):#Motor 2 positive and negative rotation
if status == 0: # stop
GPIO.output(Motor_B_Pin1, GPIO.LOW)
GPIO.output(Motor_B_Pin2, GPIO.LOW)
GPIO.output(Motor_B_EN, GPIO.LOW)
else:
if direction == Dir_backward:
GPIO.output(Motor_B_Pin1, GPIO.LOW)
GPIO.output(Motor_B_Pin2, GPIO.HIGH)
pwm_B.start(100)
pwm_B.ChangeDutyCycle(speed)
elif direction == Dir_forward:
GPIO.output(Motor_B_Pin1, GPIO.HIGH)
GPIO.output(Motor_B_Pin2, GPIO.LOW)
pwm_B.start(0)
pwm_B.ChangeDutyCycle(speed)
def motor_right(status, direction, speed):#Motor 1 positive and negative rotation
if status == 0: # stop
GPIO.output(Motor_A_Pin1, GPIO.LOW)
GPIO.output(Motor_A_Pin2, GPIO.LOW)
GPIO.output(Motor_A_EN, GPIO.LOW)
else:
if direction == Dir_forward:#
GPIO.output(Motor_A_Pin1, GPIO.LOW)
GPIO.output(Motor_A_Pin2, GPIO.HIGH)
pwm_A.start(100)
pwm_A.ChangeDutyCycle(speed)
elif direction == Dir_backward:
GPIO.output(Motor_A_Pin1, GPIO.HIGH)
GPIO.output(Motor_A_Pin2, GPIO.LOW)
pwm_A.start(0)
pwm_A.ChangeDutyCycle(speed)
return direction
def move(speed, direction, turn, radius=0.6): # 0 < radius <= 1
#speed = 100
if direction == ‘forward’:
if turn == ‘right’:
motor_left(0, left_backward, int(speed*radius))
motor_right(1, right_forward, speed)
elif turn == ‘left’:
motor_left(1, left_forward, speed)
motor_right(0, right_backward, int(speed*radius))
else:
motor_left(1, left_backward, speed)
motor_right(1, right_backward, speed)
elif direction == ‘backward’:
if turn == ‘right’:
motor_left(0, left_forward, int(speed*radius))
motor_right(1, right_backward, speed)
elif turn == ‘left’:
motor_left(1, left_backward, speed)
motor_right(0, right_forward, int(speed*radius))
else:
motor_left(1, left_forward, speed)
motor_right(1, right_forward, speed)
elif direction == ‘no’:
if turn == ‘right’:
motor_left(1, left_backward, speed)
motor_right(1, right_forward, speed)
elif turn == ‘left’:
motor_left(1, left_forward, speed)
motor_right(1, right_backward, speed)
else:
motorStop()
else:
pass
def destroy():
motorStop()
GPIO.cleanup() # Release resource
if __name__ == ‘__main__’:
try:
speed_set = 60
setup()
move(speed_set, ‘forward’, ‘no’, 0.8)
time.sleep(1.3)
motorStop()
destroy()
except KeyboardInterrupt:
destroy()
pi@raspberrypi:~/adeept_rasptank/server $
-
OK. So I finally put my money where my mouth is and started messing with the code to make this robot respond to commands correctly. It took me a bit to figure out, but, there are a couple of different ways you can do this:
– As described above you can adjust the parameters. In my quest for the “right” settings I made a lot of changes to the variable values that didn’t work.
– Eventually instead of messing with the direction variables, I adjusted the methods.
– I’ll paste in the “before” move.py file code that was turning correctly but went forward when commanded backwards and vice versa.
– Then I’ll paste in the “after” move.py file code with the changes that enabled the robot to respond to my commands correctly.
– For fun you can root out the changes I made – if your into that
-
I saved the “before” code before I started making changes in case I really bungled the original file with my adjustments…
-
# “before” code
# file before I changed pin settings…
#!/usr/bin/env python3
# File name : move.py
# Description : Control Motor
# Product : GWR
# Website : http://www.gewbot.com
# Author : William
# Date : 2019/07/24
import time
import RPi.GPIO as GPIO
# motor_EN_A: Pin7 | motor_EN_B: Pin11
# motor_A: Pin8,Pin10 | motor_B: Pin13,Pin12
Motor_A_EN = 4
Motor_B_EN = 17
Motor_A_Pin1 = 14
Motor_A_Pin2 = 15
Motor_B_Pin1 = 27
Motor_B_Pin2 = 18
Dir_forward = 0
Dir_backward = 1
left_forward = 0
left_backward = 1
right_forward = 0
right_backward= 1
pwm_A = 0
pwm_B = 0
def motorStop():#Motor stops
GPIO.output(Motor_A_Pin1, GPIO.LOW)
GPIO.output(Motor_A_Pin2, GPIO.LOW)
GPIO.output(Motor_B_Pin1, GPIO.LOW)
GPIO.output(Motor_B_Pin2, GPIO.LOW)
GPIO.output(Motor_A_EN, GPIO.LOW)
GPIO.output(Motor_B_EN, GPIO.LOW)
def setup():#Motor initialization
global pwm_A, pwm_B
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(Motor_A_EN, GPIO.OUT)
GPIO.setup(Motor_B_EN, GPIO.OUT)
GPIO.setup(Motor_A_Pin1, GPIO.OUT)
GPIO.setup(Motor_A_Pin2, GPIO.OUT)
GPIO.setup(Motor_B_Pin1, GPIO.OUT)
GPIO.setup(Motor_B_Pin2, GPIO.OUT)
motorStop()
try:
pwm_A = GPIO.PWM(Motor_A_EN, 1000)
pwm_B = GPIO.PWM(Motor_B_EN, 1000)
except:
pass
def motor_left(status, direction, speed):#Motor 2 positive and negative rotation
if status == 0: # stop
GPIO.output(Motor_B_Pin1, GPIO.LOW)
GPIO.output(Motor_B_Pin2, GPIO.LOW)
GPIO.output(Motor_B_EN, GPIO.LOW)
else:
if direction == Dir_backward:
GPIO.output(Motor_B_Pin1, GPIO.HIGH)
GPIO.output(Motor_B_Pin2, GPIO.LOW)
pwm_B.start(100)
pwm_B.ChangeDutyCycle(speed)
elif direction == Dir_forward:
GPIO.output(Motor_B_Pin1, GPIO.LOW)
GPIO.output(Motor_B_Pin2, GPIO.HIGH)
-
-
-
Walking around the lake next to my house. Sometimes I lose track of the number of laps…
-
I love trampolines! Super dangerous, but, so much fun and such a great workout and so good for developing balance and spacial awareness (in my opinion).