Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to run a jetbot right after bootup? #55

Closed
HannahZhangVW opened this issue Apr 30, 2019 · 13 comments
Closed

how to run a jetbot right after bootup? #55

HannahZhangVW opened this issue Apr 30, 2019 · 13 comments

Comments

@HannahZhangVW
Copy link

I would like to have the jetbot car run collision avoidance algorithm automatically after boot up.
Here is what I did:

  1. converted "live_demo.ipynb" to a python file "live_demo.py".
  2. Put "python /home/jetbot/Notebooks/collision_avoidance/live_demo.py in /etc/rc.local.
    However, the live_demo.py can't run because no pytorch, pytorchvision, jetbot could be import.
    I installed AMR version pytorch and pytorchvision sucessfully.
    how to intall jetbot?
    Why "live_demo.ipynb" don't have import problems when it runs on jupytor?
@jaybdub
Copy link
Contributor

jaybdub commented Apr 30, 2019

Hi HannahZhangVW,

Thanks for reaching out! Do you know which python interpreter you’re calling?

We install dependencies for Python 3 only. My best guess is your new script is being executed with python 2.

Best,
John

@HannahZhangVW
Copy link
Author

HannahZhangVW commented Apr 30, 2019 via email

@jaybdub
Copy link
Contributor

jaybdub commented Apr 30, 2019

Awesome! Nice to talk to you again, glad to hear you're enjoying it!

Python3 is actually already installed, all you have to do is call python3 instead of python.

Hopefully that works, if you run into any issues let me know.

Best,
John

@HannahZhangVW
Copy link
Author

HannahZhangVW commented Apr 30, 2019 via email

@jaybdub
Copy link
Contributor

jaybdub commented Apr 30, 2019

Hi Hannah,

One way is to create a system service that calls your script and enable it to run at boot. We do this for the stats display on JetBot. We actually generate the system service using this script:

https://github.com/NVIDIA-AI-IOT/jetbot/blob/master/jetbot/utils/create_stats_service.py

That script automatically generates the system service file (just filling in a few parameters like the current user). You can easily create a file like this manually. Say you want to create a service called run_my_python_script which executes the python script /home/jetbot/my_python_script.py. You would:

  1. Create a file /etc/systemd/system/run_my_python_script.service

  2. Edit the following with text like the following

    Description=Runs my python script
    [Service]
    Type=simple
    User=jetbot
    ExecStart=/bin/sh -c "python3 /home/jetbot/my_python_script.py"
    WorkingDirectory=/home/jetbot
    Restart=always
    [Install]
    WantedBy=multi-user.target
  3. Start the service manually by calling this in a terminal

    sudo systemctl start run_my_python_script
  4. Enable the service at boot by calling this in a terminal

    sudo systemctl enable run_my_python_script

Please let me know if you run into any issues. Hope this helps!

John

@HannahZhangVW
Copy link
Author

HannahZhangVW commented May 4, 2019 via email

@hachpai
Copy link

hachpai commented May 4, 2019

Hi all!

I'm into the same goal, thanks for those instructions.
Someone could give a trained model for obstacle avoidance? I'm lacking of time to produce the dataset and train it by myself... I've two jetbots and i just need them to avoid each others and evident walls in good light conditions.

@RyanC1681
Copy link

RyanC1681 commented May 7, 2019

Hi,
How to run live demo live_demo.py with downloaded pre-trained model?
I tried python3 live_demo.py, but it didn't spin the wheel or no outputs.
Can I put ipynb in in /etc/rc.local or let it continuous run?
Thanks,

@jaybdub
Copy link
Contributor

jaybdub commented May 8, 2019

@HannahZhangVW

Thanks for sharing! Very impressive!

The road following code will be released soon, but we don’t have an exact date. If you’re eager to get started you can check out the notebooks in the road_following_ai branch.

It’s under development, we still need clean the samples and add documentation.

Please let me know if you have any questions or feedback.

Best,
John

@HannahZhangVW
Copy link
Author

HannahZhangVW commented May 24, 2019 via email

@jaybdub
Copy link
Contributor

jaybdub commented May 26, 2019

Hi Hannah,

Rather than rebooting, the following should be an easier method to recover from this state.

  1. Restart notebook

  2. Restart camera daemon (from terminal)

    sudo systemctl restart nvargus-daemon

Could you try the following and see if this issue persists:

  1. Convert model to half precision (and update preprocessing function)

    model = model.half()
    ...
    def preprocess(camera_value):
        ...
        return x.half()
  2. Configure Jetson Nano to 5W mode (from terminal)

    sudo nvpmodel -m1

Please let me know if this works for you.

Thanks!
John

@HannahZhangVW
Copy link
Author

HannahZhangVW commented Jul 17, 2019 via email

@dvillevald
Copy link

Hi Hannah,

I tried a similar approach (a classifier with 4 classes - left, right, free, blocked) to teach JetBot to navigate through the maze of traffic cones and it worked pretty well. I also added FPV videos with superimposed classification and robot actions - it helped me a lot to debug. In case you are interested, the links are below (the code is on Github):

Youtube: https://youtu.be/YwxSwXEjd4c
Github: https://github.com/dvillevald/Finding-path-in-maze-of-traffic-cones
Hackster: https://www.hackster.io/dvillevald/transfer-learning-with-nvidia-jetbot-fun-with-cones-adf531

Hope it helps.
Good luck!
Dmitri

@jaybdub jaybdub closed this as completed Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants