Documentation for UltraSonicSensor in Python


#1

Using this code with GoPiGo:

my_ultrasonic = easygopigo.UltraSonicSensor()
reading=my_ultrasonic.read()
print(reading)
print (“Here are the results:”)
print("String representation: ", repr(reading), "Length: ", len(str(reading)))

I get these results:

I couldn’t figure out where the first three lines were coming from, so I commented out all of the “print” statements. They were still present, which means that they are coming from the statement:

my_ultrasonic = easygopigo.UltraSonicSensor()

I would like to turn off the output of the first three lines, but I can find no documentation of the function.


#2

Hello @michael_bush

Thank you for trying out easygopigo! Indeed we had debug statements in the library for a while. They have already been removed from the code but it seems your SD card isn’t up to date.
If you do a DI Update Software, it will download the newest version of easygopigo.py and gopigo.py and re-install them for you. Sorry for the hassle.
Cleo


#3

Cleo,

I could not do what you requested with the SD card that has the Beta system I received. It only responded to my connection via its own Wifi.

I then swapped it out for my previous SD card with the older system and updated it. Now when I do VNC, the icons on the desktop are bouncing around. I had to shut down the system via a terminal window.

I wondered if that was because I had the motors disconnected as per the instructions on the Web site. I reconnected those and then rebooted the system. I got the same results. I was able to capture the two states in the graphics below.

Cheers,

Mike


#4

Hi @Michael_Bush1,


I’m not sure I’m getting this phrase:

… that has the Beta system I received. It only responded to my connection via its own Wifi.


Also, when you say:

the icons on the desktop are bouncing around

Are you implying that the Desktop icons are moving around “lively” - like are they switching their place on the fly? Or do they switch their position upon rebooting the system?


And most importantly, is your OS functional?
Can you “talk” with your GoPiGo from within a Python script?
Did your initial Python script stop printing debug messages?


Thank you!


#5
  1. The problem I reported (extra numbers being output) was occurring with the Beta system.
  2. As explained by the Beta documentation, connection with that system is only possible directly using its WiFi assignment of IP address. In other words the connection is NOT established through my router as is normally the case.
  3. Due to #2 above, I removed the Beta SD and inserted the SD that came with the GoPiGo.
  4. I then did the DI Update as directed by Cleo.
  5. When the system came up, the icons on the desktop were switching positions, from one state then to the other, then back again.
  6. I was able to connect using a terminal to the IP address listed on my router. I did not try anything with Python, but I was able to shutdown the system normally (sudo shutdown now).
  7. To get past the problem, I downloaded the latest image from Dexter and installed that on the Beta SD card.
  8. Things worked well for a while with the new image, but then the Grove Ultrasonic Ranger stopped working. (It now reports back the same value over and over. I have rebooted the system several times and even changed the battery pack, but to no avail.

Would it be helpful for me to send you the SD card that has the “dancing desk icon” problem?

Cheers,

Mike


#6
  1. The problem I reported (extra numbers being output) was occurring with the Beta system.
  2. As explained by the Beta documentation, connection with that system is only possible directly using its WiFi assignment of IP address. In other words the connection is NOT established through my router as is normally the case.
  3. Due to #2 above, I removed the Beta SD and inserted the SD that came with the GoPiGo.
  4. I then did the DI Update as directed by Cleo.
  5. When the system came up, the icons on the desktop were switching positions, from one state then to the other, then back again.
  6. I was able to connect using a terminal to the IP address listed on my router. I did not try anything with Python, but I was able to shutdown the system normally (sudo shutdown now).
  7. To get past the problem, I downloaded the latest image from Dexter and installed that on the Beta SD card.
  8. Things worked well for a while with the new image, but then the Grove Ultrasonic Ranger stopped working. (It now reports back the same value over and over. I have rebooted the system several times and even changed the battery pack, but to no avail.

I am wondering if Dexter would find it useful for me to send the SD card that has the “dancing desk icon” problem…

Cheers,

Mike


#7

Hello @michael_bush,
Which one do you call the Beta system? DexterOS? Cinch?

DexterOS is new and I have to get into the habit of asking if that’s what’s running. If it’s DexterOS, you’re right, you can’t update it in the same way as Raspbian for Robots or Cinch. I apologize for not having thought about that option. We are currently working on getting an update. The mechanism is already in place, we just need to get the actual update file ready.

As for the icons bouncing around, I would very much appreciate a video to try to see what’s causing it.

thank you,
Cleo


#8

Cleo,

Attached is a screen recording of the problem. It also illustrates the problem I am having with the Grove Ultrasonic Sensor, which only returns the value of “1”.

As a reminder, I arrived at this point by updating my previous version of the OS by double-clicking on the icon on the desktop as per a previous message you sent:
Hello @michael_bush</u/michael_bush>
Thank you for trying out easygopigo! Indeed we had debug statements in the library for a while. They have already been removed from the code but it seems your SD card isn’t up to date.
If you do a DI Update Software, it will download the newest version of easygopigo.py and gopigo.py and re-install them for you. Sorry for the hassle.
Cleo
Many thanks for your help!

Cheers,

Mike


#9

The MP4 I sent of the screen recording was not accepted by the system, so I renamed the file with “MPG” instead of “MP4.” Hopefully it will be viewable.

GoPiGo System Update Problem (Small).mpg (1.8 MB)


#10

Thanks for the video Michael and happy Independence Day to you! :sparkler::fireworks:

Part of me wants to say the icons are happy to celebrate 4th of July but unfortunately that is probably not the reason. But you do get to be the first to report this problem! I’m going to have to review this whole thread because at the moment I’ll admit I haven’t got a clue.
Cleo


#11

Happy Independence Day to you too!

Do you want me to mail you the SD card? Actually, it occurs to me that I can create an IMG file of the card and put that on OneDrive and send you a link…


#12

I’m Canadian, hence me working today :maple_leaf::maple_leaf::canada:

I would indeed appreciate getting an image of your SD card, if you can. A link is enough. I also have the feeling that doing the DI update again would fix it but that’s just intuition.

Cleo


#13

Cleo,

Here is the linkhttps://1drv.ms/u/s!ArbxA1RlknTQgcRpK8hIzhaF6KZEbw to the ZIP file! I am including a file with the MD5 Hash. If I get a chance, I will try the DI update again. The problem will be clicking on the icon as it moves around.

I already downloaded what I think is the most recent image from the Dexter site and put that on the SD that I had received with the Beta software. It is working fine. Sadly, as you can see in the video I sent, the Grove Ultrasonic Ranger has quit working. I am hoping that I can get that replaced…

Cheers,

Mike

MD5 Hash.txt (32 Bytes)


#14

Thanks for the image. I am currently downloading it.

If you don’t want to play whack-a-mole with the icon you can use a terminal window and type in the following:
sudo bash /home/pi/di_update/Raspbian_For_Robots/upd_script/update_all.sh

This is what gets run when you click on the icon, so exactly the same thing will happen.

As for the ultrasonic sensor, did you talk with @RobertLucian about it?

Cleo


#15

Good morning @michael_bush1,

Good news and bad news. I do believe I found the cause of the dancing icons. One of the steps that DI Update Software does is currently not compatible with Wheezy, and your card is a Wheezy card. I do not know your background so in case you don’t know what Wheezy is, it’s like a version number for Raspbian. Just like Windows has Windows 7, 8 and 10 (but no 9), Raspbian uses names. Wheezy is the “old” one, current one is Jessie, and newly out but not on the Pi yet is Stretch. While Wheezy does the job, it’s not able to offer all the same things as Jessie.

I found the command that creates the problem, however I have not found (yet) how to get Wheezy back on its feet. I would suggest burning a new card with Jessie on it. You can find instructions here if you need them.

I hope you will consider moving to Jessie. In the meantime, I’ll keep looking for how to fix your Wheezy card but so far I’ve only succeeded in making it worse.

Cleo