Authors:
- 陳麒麟
- 曾裕翔
- 林庭琮
- 鍾博丞
Advising professor:
- 蘇文鈺
Type | Description |
---|---|
A | Rear-wheel drive, front-wheel steering |
B | Rear-wheel drive |
C | Four-wheel drive with robot arm |
D | Mecanum wheel |
The image in this repository pros_car
is deprecated. Use pros_ai_image
instead.
The Dockerfile here is to test new feature based on ghcr.io/otischung/pros_ai_image:latest
.
The docker image in this project has the following 4 features shown above.
Keyboard
Car_<A,B,C,D>_serial_reader
Car_<A,B,C,D>_serial_writer
RandomAI
arm_reader
arm_writer
cv_bridge
: Convert the compressed ROS image to OpenCV image format.
pros_app contains the following features.
RPLidar
Camera
SLAM
pros_AI contains Car_B_AI
.
pros_AI_image is the repository which creates the entire base docker image.
You can clone it by using HTTPS
git clone https://github.com/otischung/pros_car
You must add the user to the docker group to get permission for docker.
usermod -a -G docker <username>
You can pull the docker image by the following command. This image is automatically built by GitHub Actions CI and it contains two versions of OS type, including amd64 and arm64.
docker pull ghcr.io/otischung/pros_ai_image:latest
After building the image, execute the following command to run the image to become the desired container.
docker run -it --rm -v "$(pwd)/src:/workspaces/src" --network pros_app_my_bridge_network --device=/dev/usb_front_wheel --device=/dev/usb_rear_wheel --device=/dev/usb_robot_arm --env-file ./.env ghcr.io/otischung/pros_ai_image:latest /bin/bash
-i
: The container will getstdin
from your keyboard.-t
: The container screen will show on your display monitor.--rm
: The container will be shut down automatically when detaching.-v "<host/location:/container/location>"
: Mount the host location into container.--network <network_name>
: Use the network you provided. We use bridge netowrk here. You can see all docker netowrk withdocker network ls
.--env-file
: This will pass the environment variables defined in the specific file to the container.- In the end, tell the container what program should be executed. We use
bash
in this case.
We've written 2 shell scripts to run the image.
car_control_2.sh
car_control_4.sh
mediapipe.sh
VSCode has these extensions, which are docker
and dev containers
.
After that, you can build your image from Dockerfile
by launching dev containers
.
- Press
ctrl+shift+p
, then selectDev Containers: Rebuild and Reopen
.
These environment variables are defined in .env
.
You may change the ID number to divide other ROS environments.
export ROS_DOMAIN_ID=1
You can change the speed of your car via the Linux environment variable WHEEL_SPEED
using the unit rad/s.
export WHEEL_SPEED=3
digitaltwin
Dockerfile
- You may change the ID number to divide other ROS environments.
ENV ROS_DOMAIN_ID=1
Car<A~D>_serial_writer.py
- Send the signals to jetson orin nano, receive the signals from
Car<A~D>_keyboard.py
.
- Send the signals to jetson orin nano, receive the signals from
Car<A~D>_keyboard.py
- Send the signal to
Car<A~D>_serial_writer.py
, intarget_vel
, index 0 is the left wheel, index 1 is the right wheel. - if the car type is four-wheel drive, we have two lists, one contains
self._vel
andself._vel2
and the other containsself._vel3
andself._vel4
.
# two wheels:
target_vel = [self._vel, self._vel]
# four wheels
target_vel = [self._vel, self._vel2]
target_vel = [self._vel3, self._vel4]
# These two target velocities are sent through different topics
-
env.py
- When we set the USB port, if we run
Car<A~D>_serial_writer.py
and the terminal shows that “cannot find the desired USB port”, then you have to edit this script or check out the USB port on the car device. - You can run
ls /dev/ttyUSB*
to check your USB port number. (if there doesn’t appear any USB devices, you must exit docker, and check the USB port on the car,ttyUSB<0~3>
number depends on the inserted order) - We've defined the name of the soft link for
usb_front_wheel
,usb_rear_wheel
, andusb_lidar
in pros_app. You may also use these rules in this container. - Referene
- When we set the USB port, if we run
-
car_models.py
- For all received data-class types, which the behavior is like
struct
inC/C++
.
- For all received data-class types, which the behavior is like
-
Open two terminals to run the car
- We use
tmux
to open two terminals, pressctrl+B
→shift+5
will open two terminals vertically; and pressctrl+B
→shift+"
will open two terminals horizontally, usingctrl+b
+ arrow keys to change between terminals.
sudo apt install tmux
- We use
-
run the car (open two terminals)
- Use
w a s d
or other keys to control the car. - Press
z
to stop the car.- Note: The car will always go forward and then stop slowly in any case. This is a bug in the C++ program controlling the ESP32.
- Press
q
to exit thekeyboard.py
.
ros2 run pros_car_py car<A~D>_serial_writer.py
ros2 run pros_car_py car<A~D>_keyboard.py
- Use
If you want to show GUI in docker, you need to configure your host first.
xhost +
And then run your docker image by the following command:
docker run -it --rm -v "$(pwd)/src:/workspaces/src" --network pros_app_my_bridge_network --env-file ./.env -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY ghcr.io/otischung/pros_ai_image:latest /bin/bash
We've written the code above into mediapipe.sh
.