kercre123 / wire-pod

Free, fully-featured server software for the Anki Vector robot.
MIT License
486 stars 164 forks source link

Vector Battery Status #382

Closed AshMartian closed 2 months ago

AshMartian commented 2 months ago

First off, thank you so much for this repository and keeping Vector alive 💚

I saw a closed PR on battery status #310, and thought it would be a nice way to learn how Wire Pod works. So I obsessively tackled creating a nice UX for displaying battery stats. This could resolve #309

goroutine 601 [running]: github.com/kercre123/wire-pod/chipper/pkg/wirepod/sdkapp.connTimer(0x1) /home/ash/wire-pod/chipper/pkg/wirepod/sdkapp/robot.go:149 +0x21c created by github.com/kercre123/wire-pod/chipper/pkg/wirepod/sdkapp.newRobot in goroutine 28 /home/ash/wire-pod/chipper/pkg/wirepod/sdkapp/robot.go:107 +0x4ec


- New `common.js` file for loading sdkInfo and getting battery status, since these are needed on home and settings

https://github.com/user-attachments/assets/f41bfcd4-1cff-491e-aeda-da81e6fcc94f

Full Charged
![image](https://github.com/user-attachments/assets/16b33437-9fb8-407a-a71d-e80ffe950456)
Roaming
![image](https://github.com/user-attachments/assets/96d9e4bb-cdbb-4de4-bf67-dc58aa7be707)
Needs Charging
![image](https://github.com/user-attachments/assets/620df08b-27bb-49ce-8797-f99fabc8a54c)
Charging with ETA
![image](https://github.com/user-attachments/assets/e25381c5-b9fb-40c5-8b79-f05a0381cd6a)
Charging with Tooltip
![image](https://github.com/user-attachments/assets/93da01b1-d83f-43e6-b96a-ead185b5b9e1)
Loading
![image](https://github.com/user-attachments/assets/d5887db1-1cae-4e6d-9ef9-c38870bfff39)
Network error
![image](https://github.com/user-attachments/assets/3de052a4-b213-466a-96ce-9f377e642465)

## Issues
- Thinking the % approximation should be done and returned from the api endpoint, to serve 3rd party usages as well.
- Vector only sends new voltages while charging or just leaving the charger. 
  - Unsure if this is an sdk limitation or firmware, can't find any documentation but seems out of scope for this PR
Zomboy4313 commented 2 months ago

One small thing I would change is instead of using a question mark, maybe use a ~ symbol since it means approximately

AshMartian commented 2 months ago

Good idea @Zomboy4313, implemented

kercre123 commented 2 months ago

This implementation is so cute! A battery indicator has been requested before, but I've been hesitant because of the same issues you ran into. Specifically: new voltages being sent not very often. I believe this to be a firmware limitation. It is also hard to be precise with the battery since there isn't a "fuel gauge" like a smartphone would have. Your curve idea seems accurate enough, though.

Just one nitpick: when no bots are authenticated, there is a bit of empty space between the header and content in the main page. If that is fixed, I will merge this.

I like this idea a lot. I wonder if we could replicate the "Vector is doing ..." indicator that was in the Vector mobile app. Vector has an event stream which provides things like that. In my testing though, I couldn't figure out how to correspond a "RobotState.Status" with one of the proto-defined statuses.

AshMartian commented 2 months ago

Awesome ideas @kercre123! Thanks for removing the botStats element on no bots!

I also pondered more animations and expanding on the robot status, included is a blank face which we could make more gif animations for various status states! (the home charging png I made in photoshop) To be clear, Vector's firmware was not open sourced, correct? We can't push firmware updates or on board logic with the vector-cloud server?

I was also thinking that this makes the "Bot Settings" page obsolete, since it's much faster to click into the bots from the homepage, but felt removing that was outside scope and didn't want to interrupt any workflows utilizing that functionality.

kercre123 commented 2 months ago

Right, we can't change the robot firmware. Some parts were open-sourced, but we don't have enough of the code to fully build our own firmware. Even if we could build it, we'd have no way to sign it and run it on a production bot.

The animations were fully open-sourced. The more complex ones have sprite sequences which could be turned into GIFs. For regular animation files, a dev robot could be used to capture it.

The Bot Settings page is probably unneeded now.. I think I'll leave it in for now since all of the YouTube wire-pod setup tutorials still refer to it and such.

AshMartian commented 2 months ago

Oooo awesome tip on those sprite sequences! I'll keep them in mind and maybe raise a PR for an animated home/charging GIF