Run the ROB1001 Arduino code - LCAS/ROB1001 GitHub Wiki

Download the Code

This may not be necessary if you already have the code downloaded before.

  1. Fork the module GitHub repository to your account.

  2. Open the terminal and clone your fork of the module repository.

git clone https://github.com/<username>/ROB1001.git

Running the Python scripts (No ROS)

For running the examples serial_example_1 or serial_example_2 in a Lab PC, it is necessary to complete the following instructions:

  1. In a terminal, go to the folder rob1001_arduino_code and choose any of the Arduino programs (e.g. serial_example_1 or serial_example_2):
cd ~/ROB1001/rob1001_arduino_code/<arduino_program_name>
  1. Run the Python script within the chosen folder:
python3 <python_file_name.py>

Running the Python scripts (with ROS)

For running serial_example_3 in the robot PC, it is necessary to complete the following instructions:

  1. Using VScode on the lab PC, establish a remote connection with the robot (using SSH or VNC) by following the instructions here (see Section 4).
  2. Once you are remotely connected to the robot, open the container that is currently running by using:
docker exec -it agilex-limo_drivers-1 bash
  1. Once you are within the container running in the robot, clone your fork of the module repository:
cd /home/ros/
git clone https://github.com/<username>/ROB1001.git

Note: the password for the user within the container is ros.

  1. To be able to use Arduino code within the container, it is necessary to install pyserial:
pip install pyserial
  1. To be able to connect to the Arduino board connected to the robot, it is necessary to permit to use of the specific serial port (e.g. /dev/ttyACM0).
sudo chmod 666 <port_name> 
  1. Finally, go to the folder rob1001_arduino_code/serial_example_3 and run the python script within it:
python3 serial_example_3.py
  1. You should be able to see the counter and alert values being printed in the terminal. You can also check the topics that are being published by using any of the following commands on another terminal:
ros2 topic echo /counter
ros2 topic echo /alert
  1. To change the message published in the topic /alert (red, yellow, or green) you can use any of the following commands on another terminal.
ros2 topic pub -r 10 /alert std_msgs/String 'data: yellow' 
ros2 topic pub --once /alert std_msgs/String 'data: red'

Uploading the Arduino programs

  1. Open the Arduino program (with the same name as the Python script) using Arduino IDE.
  2. Connect the Arduino Board to the PC and make sure the communication port (e.g. COM3) matches the port set in the Arduino program.
  3. Upload the program and make sure no errors appear on the output panel.
⚠️ **GitHub.com Fallback** ⚠️