GPS sensor gopigo from command line


#1

I did the code here
https://www.dexterindustries.com/GoPiGo/projects/python-examples-for-the-raspberry-pi/example-project-a-raspberry-pi-gps-guided-robot-with-the-gopigo/
but with a changed path (Desktop/GoPiGo/Software/Python/Examples/GPS_Bot/) and it works!

well its says that it recognizes this directory

when I try to make it do something (sudo python gps.py) but it just talks about the directory

I’ve never programmed with the command line, is there a way to adapt this to python? What am I doing wrong? Can you just find directories in the command line?


#2

Hi @ikhouider,

Can you paste the screenshot of the error that you get and also you have said that you have changed the path to Desktop/GoPiGo/Software/Python/Examples/GPS_Bot/ so after changing to this location, can you type ls on the command line and paste the output with your reply.

-Shoban


#3

You technically could do everything you do in the terminal in python, but it is highly unconventional. It would kinda be like using a Volkswagen INA NASCAR race. If you really want to you can look into the is library for Python. Though it would be harder.

If you typed CD to go into the directory and it gives an error about GPS.py, it most likely means there is no GPS.py. You can also type pwd into the terminal to see what directory your in. Like @Shoban said post in the output of GPS.py would be helpful.


#4

This is what I got when I did what you asked.

I’m kind of confused right now but is there a way i could do this in python


#5

You need to type cd before the file path. So you would type it like this:
cd Desktop/GoPiGo/Software/Python/Examples/GPS_Bot/

The cd command switches you to the directory you specify in front of it. Just typing the directory will just produce output on whether it exists or not. I would suggest that you may want to find a quick tutorial on the command line, it’ll make your life much easier! :slight_smile:


#6

I’m so sorry to bother you about something this stupid…
At least now I know that the GPS sensor is working!

Is there a way to program it on python? I can’t find anything…

Thanks again for all the help


#7

Its unable to read sudo python gps.py


#8

Could you expand on program in python? And it’s not a stupid question, It’s fine, that’s what the forums are for. I checked and there is indeed a gps.py in Desktop/GoPiGo/Software/Python/Examples/GPS_Bot/ on raspbian for robots. Are you sure youre in that directory when you run sudo python gps.py? You can also type this command to run it from the home directory: sudo python Desktop/GoPiGo/Software/Python/Examples/GPS_Bot/gps.py


#9

It says thats its unable to access that library…
I don’t know
Thanks so much @graykevinb for all the help you’ve been giving me.
I’m just trying to get the GPS sensor to print its coordinates in python whenever its asked. At first I thought I could link the command line to python or something. That was stupid

I’m now just looking for a way to program this on python. I really don’t understand what commands I can use for this sensor. The only sensor I’ve programmed before is the sound sensor which is totally different then this and I can’t find anything online. I was wondering if you could point me towards a tutorial for this for this grove sensor or any tips or how to acess this library on python

Thanks again @graykevinb and @Shoban for all the help so far :grinning:


#10

You can run terminal commands with os.system("your command") Check out the official wiki by the gps’s manufacturor. Scroll down till you see it talk about using g the raspberry pi and the you go! Have fun! :slight_smile: Is that everything then? Feel free to ask more questions if you need to.


#11

Hi @ikhouider,

Adding on to what @graykevinb has said, we also have a brief explanation on using this sensor here and also a small project on GPS Bot here. You can refer to more of our projects there and let us know your comments.

-Shoban


#12

thanks @Shoban but the code you linked was the same I used before and wasn’t in python.

And thanks @graykevinb I understand the command module now!

I now know how to change the output for google maps Ect. but I just need to make it do what it does in the command module in python.

Is there a way to change that command module to make it in python?
That way I can both get the coordinates and get it on google maps at the same time!

Thanks so much again and sorry for all my questions


#13

No need to apologize. That’s what the forum is for. :slight_smile:


#14

Thanks :slight_smile:

Do you know of any way I can adapt this to python?

Thanks again :smile:


#15

Could you clarify on what you mean by use python?


#16

Be able to access the same library I could access in the command line but in python and print GPS coordinates in python
so i could say

print (GPS_coordinates)

and that would print


#17

like I would make GPS_coordanate a variable that connects to that library… If that makes any sense?
Like in the sound sensor you would

print (something_value)

I may have forgot what that value is called but you get the idea


#18

Gotcha. Look at the code of the GPS example and that’s how you use the GPS in python. U fortunately there is no easier way. :frowning:


#19

Could you expand?
Do I put the exact same thing from the command module in python? Is there a certain way? Or do you just not know?
I’m absolutely hopless on the command module, sorry


#20

It is identical to terminal. So are you just wanting to run the GPS.py python script from another python script?