So I write the exact same thing but in python?
Is there like a tutorial on how to do this @graykevinb? or is it the same? How can I adapt the code?
also the command module doesn’t work anymore?
You mean the python is module? The error you are seeing must be a problem with GPS.py not the is module.
As far as adapting the code. You essentially copy it. You may want to put it into a function. If you look at line 84 and the next few lines you’ll see the code that prints the data out. That help?
I can give you a few pointers, but I’m not the one righting the robot
@ikhouider,
I think you are on the right path, can you try running gps_hardware_test.py which is in the same folder as gps.py and post the output here. Also, do let us know if the error goes away.
The GPS sensor is a bit different than other sensors. It uses serial, so basically it keeps on sending messages which give the data from the GPS. For the GPS to work properly, it has to get a signal from the GPS satellites, this is called getting a fix. Sometimes when you are indoors where it might be harder to get a signal from the GPS satellites, the GPS has no proper data to send back, also the module usually takes less than a minute to actually start getting the signal from the GPS satellites, so one of the things that might be happening is that the GPS does not have any data which can be read which might be causing the error that you got. Running the gps_hardware_test.py would show the raw data from the GPS and help in debugging the problem.
@graykevinb is right and it would be harder to run this program from the interpreter. We have a class here which basically parses through the datastream as it comes from the GPS to pick out the parameters that are important and returns them to wherever you call it from, like here and then you can use those values independently.
Up there is I think I found a way to program that from command module to python
GPS hardware test as you have suggested it prints out coordinates in the command line
Why does the test work and not the other program?
I will now check out the program in python that you sent me and will tell you what happened.
It seemed to work and I understood most of the code as well, thanks @karan for the great explanation but then I got this mistake
My permission was denied for the GPS data, why?
Is this the same reason the GPS sensor was unable to read the gps.py in the command module?
If so why did the folder gps_hardware_test work?
you can always run python with sudo.
However USE WITH CAUTION!!
@graykevinb ??? ??? I dont understand what you mean? are you explaining the reason the sudo doesnt work?
Permission is being denied because the data is owned by root. Meaning you the “all powerful” admin can’t access it normally. To access it you must run python with sudo. sudo python
Sudo allows you to do stuff only root can do as the admin. I say use with caution because it’s risky to run programs with high level priviledges. Especially if you don’t know what your doing.
A better solution would be to find where gps_data.csv
is located and go into that directory and type chown pi gps_data.csv
That will make you the owner of that data.
Ok so how would I do that second option because the first one sounds scary
Could you explain in detail or link a tutorial
I’m so sorry to be bothering you
I think the file is in the folder where the gps stuff is located. So what you’ll need to do is run run the chown command I showed you and also run chmod +w gps_data.csv
and chmod +r gps_data.csv
That should give you access to the files.
Dexter Ind really loves to lock stuff down!
Also if you have time
Could you explain or link to a tutorial about why and what is root and why it has the data. If you don’t have time its fine I searched it up online but its confusing and I’m not sure if its exactly the same for the robot but again if you don’t have time its fine I’ll make do, just please explain how to find where
The important questions I have really quick are I do both those commands right? and one after the other? and that’s it? and that’s how they are written?
Sorry again, just clarifying and thanks SO SO SO much for all the help so far THANK YOU
its not permitted
Oh yah forgot. You have to run sudo to do that.
It’s fine and safe.
Kinda like its ok to unlock your door but leaving it unlocked all the time(running a program with root priviledges “can” be dangerous.
Ok how can I run sudo? Or do I run sudo first? Or do i run sudo in python? ??? wait what do i do with sudo?
just put sudo in front of the commands you said didn’t work above, chmod and chown.
After that if all goes well you shouldn’t have to type sudo againt to access those files.
So I did that as you can see the chown didnt work and the chmod didnt do anything which i took it to be working but when I tried my python program i got the same error
can you type ls
in the terminal? That will show the files in the directory. Then post it here?
bash: 1s: command not found