Open skruglewicz opened 1 month ago
Hi Steve,
I wanted to clarify the structure of the install_rosai_file_input.sh script and the README. Some steps in the script are commented out to match the sections in the README for user convenience. If you compare the script with section 6, you’ll find that the steps missing from the README are executed within the script.
Regarding the error "bash: install/local_setup.sh: No such file or directory," this file is typically generated during the build process with colcon build. If it is missing, it suggests that the build process did not complete successfully or the install directory was not created. Here are steps to troubleshoot and resolve this issue:
Verify Directory Structure and Permissions: Ensure the directory /home/root/ros2_ws_fileio exists and is accessible.
Re-run the Build Process: Re-run the build process to ensure that all necessary files are generated:
cd /home/root/ros2_ws_fileio
source /opt/ros/humble/setup.bash
colcon build
Check for Errors During Build: Watch for any errors during the build process. If there are errors, they will prevent the install directory and local_setup.sh file from being created. If you encounter any errors, please let us know.
Verify the Build Output: After the build process completes, verify the contents of the install directory. You should see the local_setup.sh file among other setup files. If the file is not present, the build process did not complete correctly.
Full Script to Ensure All Steps are Correct Below is a full script that encompasses all necessary steps to ensure the build process completes correctly:
#!/bin/bash
# Become super user and set the pynq_venv environment
sudo su
source /etc/profile.d/pynq_venv.sh
# Create test images
python3 /home/ubuntu/KR260-Robotics-AI-Challenge/files/ROSAI/save_images_from_MNIST_dataset.py
# Create workspace folder and copy files
cd /home/root
mkdir -p ros2_ws_fileio
mkdir -p ros2_ws_fileio/src
cp -rf /home/ubuntu/KR260-Robotics-AI-Challenge/files/ROSAI/file_input/rosai_file ros2_ws_fileio/src/
cd ros2_ws_fileio
# Initialize ROS2 environment variables
source /opt/ros/humble/setup.bash
# Build the workspace
colcon build
# Verify the presence of local_setup.sh
if [ -f install/local_setup.sh ]; then
echo "local_setup.sh found, proceeding..."
source install/local_setup.sh
ros2 launch rosai_file rosai_file_demo_launch.py
else
echo "local_setup.sh not found, build may have failed."
fi
By following these steps, you should be able to identify and resolve the issue preventing the creation of install/local_setup.sh.
We hope this helps, and please feel free to reach out if you have any further questions or need additional assistance.
Somayeh
Thank you I will retry your suggestions. Stay tuned. But I'm still wondering why I had to manually install colcon as stated? Steve K
hello @somayeh-rahimipour I ran the "install_rosai_file_input.sh" script again and there are errors generated in the "save_images_from_MNIST_dataset.py" and creating the Workspace folder with cd /home/root. The directory ros2_ws_fileio was created but under the scripts directory. SO the question now is why is the the image script failing and the the cd cmd failing?
# Create test images **python3 /home/ubuntu/KR260-Robotics-AI-Challenge/files/ROSAI/save_images_from_MNIST_dataset.py** # Create workspace folder and copy files **cd /home/root**
This is the terminal output--- (pynq-venv) root@kria:/home/ubuntu# cd /home/ubuntu/KR260-Robotics-AI-Challenge/files/scripts
(pynq-venv) root@kria:/home/ubuntu/KR260-Robotics-AI-Challenge/files/scripts# ls install_rosai_camera_input.sh install_update_kr260_to_vitisai35.sh install_rosai_file_input.sh ros2_ws install_ros.sh ros2_ws_fileio
(pynq-venv) root@kria:/home/ubuntu/KR260-Robotics-AI-Challenge/files/scripts# source ./install_rosai_file_input.sh
Traceback (most recent call last):
File "/home/ubuntu/KR260-Robotics-AI-Challenge/files/ROSAI/save_images_from_MNIST_dataset.py", line 54, in
Summary: 1 package finished [11.0s] (pynq-venv) root@kria:/home/ubuntu/KR260-Robotics-AI-Challenge/files/scripts/ros2_ws_fileio# ls build install log src
Hi Steve,
Based on the terminal output, the script save_images_from_MNIST_dataset.py is trying to download the MNIST dataset but fails with a 403 HTTP Error. This means the request to download the dataset is forbidden. There could be a few possibilities:
1. Check Internet Connection It's possible that the internet connection might block access to the URL used by the mnist library to download the dataset. To resolve it, please check the internet connection:
Ensure that the board has an active internet connection.
Try accessing other websites or downloading other files to confirm the internet connection is working.
2. Manually Verify URL Access Locate the URL used by the mnist library to download the dataset. You can find this in the mnist library code. Try to manually access this URL from a browser or using a command-line tool like wget or curl on the board:
wget http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
If the URL access is blocked or results in a 403 error, this confirms the issue is with URL restrictions, or changes in how the dataset is hosted. You can use an alternative library like tensorflow or keras to download the MNIST dataset. Here’s how you can modify the script to use tensorflow to download the MNIST dataset:
import tensorflow as tf
import numpy as np
import os
import cv2
def save_image():
(train_images, train_labels), (test_images, test_labels) = tf.keras.datasets.mnist.load_data()
normalized_data = np.asarray(test_images / 255, dtype=np.float32)
test_data = np.expand_dims(normalized_data, axis=3)
num_pics = 100
output_folder = "/home/ubuntu/images/rosai_file_demo_test_images"
if not os.path.exists(output_folder):
os.makedirs(output_folder)
for i in range(num_pics):
image_to_save = (255 * test_data[i]).astype(np.uint8)
filename = f"{output_folder}/mnist_image_{i}.jpg"
success = cv2.imwrite(filename, image_to_save)
def main(args=None):
save_image()
if __name__ == '__main__':
main()
Alternative Approach: Use a Local Copy of the MNIST Dataset If internet access is restricted, another approach is to use a local copy of the MNIST dataset. Here’s how you can modify the script to load the dataset from a local file:
Download the Dataset Locally
Download the MNIST dataset manually on a system with internet access.
Transfer the downloaded files to the board (e.g., using scp).
Modify the Script to Load Locally Save the MNIST dataset as .npy files or use the original .gz files. Here's an example of how to modify the script to load the dataset from local files:
import numpy as np
import os
import cv2
def load_mnist_local(file_path):
with open(file_path, 'rb') as f:
return np.load(f)
def save_image():
raw_data = load_mnist_local('/home/ubuntu/mnist_data/t10k-images-idx3-ubyte.npy')
normalized_data = np.asarray(raw_data / 255, dtype=np.float32)
test_data = np.expand_dims(normalized_data, axis=3)
num_pics = 100
output_folder = "/home/ubuntu/images/rosai_file_demo_test_images"
if not os.path.exists(output_folder):
os.makedirs(output_folder)
for i in range(num_pics):
image_to_save = (255 * test_data[i]).astype(np.uint8)
filename = f"{output_folder}/mnist_image_{i}.jpg"
success = cv2.imwrite(filename, image_to_save)
def main(args=None):
save_image()
if __name__ == '__main__':
main()
This script assumes you have manually downloaded and converted the MNIST dataset to .npy format and placed it in /home/ubuntu/mnist_data/.
I also strongly recommend you follow all the steps (from section 1) one by one, especially when you need to be a super user and set the environment before running some commands.
Please let me know if any of these approaches solve your issue.
Best, Somayeh
Hi @somayeh-rahimipour I'm a bit confused on why I'm getting the Forbidden error as you suggest in option2. it is a restriction and if I try to access the sit from a browser on my PC on the same network as the Kit I get the forbidden error. Off the web site selecting the Highlighted file as described below:
I'm not sure why I don't have access? how do the others following THIS tutorial? I'm using the same Kit, the KR260? There must be a way to login to the site ? but I'm not familiar? can you access the site? Thanks for the information. STEVE K
In section 6.1 Launch the install_rosai_file_input.sh script to install and build the application. In step 3 this is what I'm experiencing. setp3. cd /home/ubuntu/KR260-Robotics-AI-Challenge/files/scripts source ./install_rosai_file_input.sh
ERROR GENERATED: File "/usr/lib/python3.10/urllib/request.py", line 643, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden bash: cd: /home/root: No such file or directory colcon: command not found
The code is open source, and available on GitHub. I Installed COLCON with the following command $ sudo apt install python3-colcon-common-extensions
I assume that COLCON did not get installed with ./install_rosai_file_input.sh script?
Now I’m able to run these commands with no COLCON error cd /home/ubuntu/KR260-Robotics-AI-Challenge/files/scripts source ./install_rosai_file_input.sh
HOWEVER NOW I’m getting the following error on step 6 (where is steps 4,5?) by running
source install/local_setup.sh bash: install/local_setup.sh: No such file or directory
Why is the directory or file not found? Where should it be? I am able to run the demo and the The TurtleSim window will pop up but nothing happens as described? I might add that I did not execute the code in both Sections 4.2 and 4.3. I'm not sure if this has anything to do with it Thanks in advance for your help Steve