Home Community Blog Buy Now

Misty Community Forum

ToFs aren't working

I was going through the ToF tutorials and sample code posted on GitHub and the robot would only run the code for a few seconds then freeze. Even if I stopped running the skill, deleted the skill and re loaded it; the robot would sit there in the same state. If I went to the command center and drove the robot manually around it seemed to “reset” it, then when I loaded the skill back in, it would run it for a few seconds then freeze.
I’m hesitant to say much more here, because Ben is just going to edit it anyways.
Do you guys just want your robot back?

Unfair characterization! :slight_smile: I only edit for formatting and then moving to different categories.

I’m not sure what you are asking (the title doesn’t indicate it). But if you are saying you are having continued issues with your time of flight sensors and the robot moving around - there are still things to try.

Have you turned off the hazard system yet?

I don’t know what I’m asking either because I don’t know what to look for anymore. All I know is the robot was running the skill for ToF tutorial fine the first part of the day. Then it would only run the skill for maybe 1 second and stop. If I deleted the skill, reloaded it and started the skill again the robot would just sit there with the LED light in red. If I went to the command center and manually drove the robot around it would drive fine. I’d go back to running the skill, LED light would turn green, it’d move forward for about a second, then stop, LED light red and would be froze there again.
I tried the sample code for ToF and the light stayed orange the whole time but not playing any sound. I opened the console and it was scrolling super fast and kept saying it was playing the sound amazement but no sound was being played by the robot until I stopped the skill. Then it would play the sound once.

And no, I didn’t turn the hazard systems off because I was planning to work on the obstacle course mission. It seems like the obstacle course mission kind of needs the hazard system on to detect obstacles.

Hit @ScottC! Can you share a link to which tutorial you were going through?

Was it this one?

Yes. That was the first one I was using. When the robot started freezing I switched the the sample skill for ToF, mostly to use the console to see what was going on.

Thanks @ScottC! Can you send me a link to the second sample skill you tried out? The one I linked to doesn’t have any code that plays a sound, so it seems like there is something else running on your robot.

So one thing to note: the HelloWorld_TimeOfFlight code we show in the Time-Of-Flight tutorial will only run through once, that is MIsty will execute only a single drive command, and will not move if an obstacle is in it’s way

This piece of code tells misty to only trigger the ToF event when there is an obstacle <0.2 meters away

misty.AddPropertyTest("FrontTOF", "DistanceInMeters", "<=", 0.2, "double");

So if your robot is red when you start this skill, it means it sees an obstacle. Otherwise it will drive forward for 10 seconds then stop if it’s path is clear.

Let me know what the other skill you were running that plays sounds and I can help figure out what might be going on there!

1 Like

Yes, at first that skill ran through as described and perfectly. I could restart the skill and it would run through once again. I was trying different things to get it to continue to run the skill more than once and was unsuccessful. I tried putting the code back to it’s original and that didn’t work. So I deleted the entire folder and re downloaded it from GitHub and loaded that original code back into the robot. The light stayed red and it didn’t move. I went to the command center and the robot moved fine. I then went back to the skill, reinstalled it and ran it. The light turned green, it moved forward about 6 inches, stopped and the light turned red. Delete the skill, reinstall the skill, light stays red, no movement. I went back to the command center and the robot ran fine again. Back to the skill and it starts fine with the light green, moves forward a split second stops and the light is red.
Then I tried this skill

and opened the console. With my old robot that had the ToF issues this skill would just keep playing the sound over and over. This time it played no sound but the console was saying it was playing sound over and over very quickly.

Also. Every time I change the code in any skill I delete all the other skills on the robot. There is only one skill on the robot at a time. I know the hello world tutorial said you didn’t need to do this. But I couldn’t find a way to add to or change the code and update it on the robot without deleting the original and installing the new skill.

Ok - let’s know these down one at a time. I am starting with the easier ones. First, using Skill Runner, you can just drag and drop new skills (js and json files) and they will replace older code. No need to delete other skills.

Here are the developer docs that explain the use of Skill Runner

Here’s a video showing it’s use

That’s pretty much how I did it when I went through the Hello World tutorial step by step. But when I added the next step on to the code and updated it to Misty it would show 2 Hello World skills and there was no way to tell which one was which. When I clicked play on one of them it gave me a yellow box with some warning (I don’t remember what it said). So I tried to delete it and it wouldn’t let me do that either. I shut Misty down and restarted it. Then it showed only 1 Hello World skill, but I didn’t know which one it was. So I deleted it and loaded the new updated skill. That was way too much of a pain, and it was just easier to delete the old code and upload the new (edited, added on to, etc.) code without getting confused and having to shut down and restart the robot after every change.
In other words, it didn’t replace the older code.

Try refreshing your browser after upload.

My process: I have about 10 skills loaded. When I update a skill, I use Choose Files, navigate to the js and json files I want to update, select both, click Open. Yellow box says “Uploading to Misty…” then “Skill successfully updated.” In the sdk Skill Runner browser window all the skills duplicate. I then hit refresh on browser and duplicates disappear. Then I run skill using Start.

This is using Chrome and Windows.


Ah, apologies @ScottC, this is actually a known issue which is currently being fixed. Today, all you have to do is refresh your browser and it will resolve (Command+R on Mac, Ctrl + R on windows)

You shouldn’t need to delete old skills off your robot, but out of curiousity, what editor are you using to modify you javascript? I personally have encountered problems where I thought my code was being automatically saved in Visual Studio Code, but I in fact had to manually click ‘Save’, then drop the file in skill runner before my changes would be recognized.

Keep us posted if the refresh works!

1 Like

Thank you both. I’ll start refreshing the browser to fix the duplicate issue. I’m also using Visual Studio Code, but I always hit save after any changes out of habit.

That’s a good habit that I have needed to redevelop :slight_smile:

To @ScottC, @MorningR, and anyone else using Visual Studio Code – be sure to also check out the Misty JavaScript extension for VSC. This extension has commands for uploading skills, starting skills at time of upload, and stopping all running skills, so you can manage all these processes without leaving your text editor. With the most recent update, you can also stream SkillData (that’s all the debug messages Misty sends to the web console in the Skill Runner tool) directly to your terminal in VSC. You can download the extension from the VSC marketplace, and be sure to check out the docs for more information!


Here is a pretty boring and poor quality video of me trying to show what I’m doing on the computer, what the robot is doing and what the console is saying while switching between two skills, and using the command center to move the robot. Both of these skills are the ones posted previously in this thread and both are directly dowloaded from Github. I didn’t edit or change anything in these.
The video shows switching back and forth between both skills and neither of the skills work correctly. It shows the robot able to move in all directions via command center with the hazard systems working appropriately. It shows what the console is saying and the robot plays 1 sound at a random time.

Thanks for the video Scott! It appears the first skill is working as expected in that it’s stoping when it encounters a perceived ToF obstacle.

The second piece of sample code actually needs an update. Currently, the debounce is set extremely low and the ToF’s are triggering CONSTANTLY and trying to send a message to Misty to play a sound which is being overwritten by the following calls, so it seems like the sound is constantly being played, but never completed. If you want to hear that sound be played constantly, you should just change this line misty.RegisterEvent("TOF", "TimeOfFlight", 0, true);
to this
misty.RegisterEvent("TOF", "TimeOfFlight", 2000, true);

This will give you a 2 second delay between events.

HOWEVER, I want to test something else. Could you go to this section in the command center and subscribe to the ToF’s? It looks like this

Can you let me know if you see quite a few ‘SignalFail’ Statuses?

1 Like

I check those often. They alternate between signal fail and out of bounds constantly until I drive misty close to something. Then they seem to stabilize until I put misty back in the middle of the room.

This is right now. Out in the middle of the room.