add car supports for unsupported devices

added support for tto usecar accessory with devices normally unsupported.  You may control it via the command line.  Unsupported devices will not work using the car app.
This commit is contained in:
Alfonso Gamboa
2022-07-14 13:56:47 -07:00
parent 3fa72158e7
commit 84c893e593
6 changed files with 133 additions and 6 deletions

View File

@@ -0,0 +1,113 @@
#!/bin/sh
echo "=== CAR CONTROL over COMMAND LINE! ==="
echo "CAR: car_control.sh"
echo "CAR: car_control.sh constant"
echo "CAR: car_control.sh constant low_speed"
echo "CAR: car_control.sh low_speed"
echo "CAR: w: forward "
echo "CAR: d: reverse"
echo "CAR: a: turn wheel left"
echo "CAR: d: turn wheel right"
echo "CAR: q: forward left"
echo "CAR: e: forward right"
echo "CAR: z: reverse left"
echo "CAR: c: reverse right"
echo "CAR: x: all stop"
echo "CAR: use 1 to quit ASAP!"
echo -e ""
echo "Ready!"
trap control_c SIGINT
control_c()
{
echo -ne "\xaa\x55\x43\x06\x29\x80\x80\x00\x02\x71" > /dev/ttyUSB0
echo "control-c KILL"
pkill -9 -f car_control.sh
}
#idle background loop
while true; do
echo -ne "\xaa\x55\x43\x06\x29\x80\x80\x00\x02\x71" > /dev/ttyUSB0
#fw sends 0.2
sleep 0.2
done &
while true; do
if [ "$1" == "constant" ]; then
read -s -n1 -t 0.05 input
else
read -rsn1 input
fi
if [ "$input" = "w" ]; then
#forward
if [ "$1" == "low_speed" ] || [ "$2" == "low_speed" ]; then
echo -ne "\xaa\x55\x43\x06\x29\x80\xca\x00\x02\xbb" > /dev/ttyUSB0
else
echo -ne "\xaa\x55\x43\x06\x29\x80\xe3\x00\x02\xd4" > /dev/ttyUSB0
fi
elif [ "$input" = "s" ]; then
#reverse
if [ "$1" == "low_speed" ] || [ "$2" == "low_speed" ]; then
echo -ne "\xaa\x55\x43\x06\x29\x80\x3b\x00\x02\x2c" > /dev/ttyUSB0
else
echo -ne "\xaa\x55\x43\x06\x29\x80\x36\x00\x02\x27" > /dev/ttyUSB0
fi
elif [ "$input" = "a" ]; then
#left
echo -ne "\xaa\x55\x43\x06\x29\x76\x81\x00\x02\x68" > /dev/ttyUSB0
elif [ "$input" = "d" ]; then
#right
echo -ne "\xaa\x55\x43\x06\x29\x8a\x81\x00\x02\x7c" > /dev/ttyUSB0
elif [ "$input" = "q" ]; then
#forward left
if [ "$1" == "low_speed" ] || [ "$2" == "low_speed" ]; then
echo -ne "\xaa\x55\x43\x06\x29\x76\xca\x00\x02\xb1" > /dev/ttyUSB0
else
echo -ne "\xaa\x55\x43\x06\x29\x76\xe3\x00\x02\xca" > /dev/ttyUSB0
fi
elif [ "$input" = "e" ]; then
#forward right
if [ "$1" == "low_speed" ] || [ "$2" == "low_speed" ]; then
echo -ne "\xaa\x55\x43\x06\x29\x8a\xca\x00\x02\xc5" > /dev/ttyUSB0
else
echo -ne "\xaa\x55\x43\x06\x29\x8a\xe3\x00\x02\xde" > /dev/ttyUSB0
fi
elif [ "$input" = "z" ]; then
#reverse left
if [ "$1" == "low_speed" ] || [ "$2" == "low_speed" ]; then
echo "low speed"
echo -ne "\xaa\x55\x43\x06\x29\x76\x3b\x00\x02\x22" > /dev/ttyUSB0
else
echo "hi speed"
echo -ne "\xaa\x55\x43\x06\x29\x76\x36\x00\x02\x1d" > /dev/ttyUSB0
fi
elif [ "$input" = "c" ]; then
#reverse right
if [ "$1" == "low_speed" ] || [ "$2" == "low_speed" ]; then
echo -ne "\xaa\x55\x43\x06\x29\x8a\x3b\x00\x02\x36" > /dev/ttyUSB0
else
echo -ne "\xaa\x55\x43\x06\x29\x8a\x36\x00\x02\x31" > /dev/ttyUSB0
fi
elif [ "$input" = "c" ]; then
echo -ne "\xaa\x55\x43\x06\x29\x80\x80\x00\x02\x71" > /dev/ttyUSB0
elif [ "$input" = "1" ]; then
#exit
echo -ne "\xaa\x55\x43\x06\x29\x80\x80\x00\x02\x71" > /dev/ttyUSB0
pkill -9 -f car_control.sh
break
fi
done

View File

@@ -139,7 +139,7 @@ if [[ "$DISABLE_MOTOR" == "true" ]]; then
fi
#Enable serial driver for car
if [ -f /opt/wz_mini/tmp/.CAR ]; then
if [ -f /opt/wz_mini/tmp/.CAR ] || [[ "$ENABLE_CAR_DRIVER" == "true"]]; then
modprobe cp210x
fi

View File

@@ -1 +1 @@
Wed Jul 13 06:14:04 PM PDT 2022
Thu Jul 14 01:55:48 PM PDT 2022

View File

@@ -91,6 +91,7 @@ ENABLE_MP4_WRITE="false"
NIGHT_DROP_DISABLE="false"
DISABLE_MOTOR="false"
ENABLE_FSCK_ON_BOOT="false"
ENABLE_CAR_DRIVER="false"
#####DEBUG#####
#drops you to a shell via serial, doesn't load app_init.sh