Last active
August 29, 2015 14:11
-
-
Save Stapelzeiger/94891c57ccfb9c87b775 to your computer and use it in GitHub Desktop.
CAN budget calculations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cid = 28 | |
# cid = 11 | |
framebits = { # including average number of stuff bits | |
11: [47, 55, 63, 71, 79, 87, 95, 103, 111], | |
28: [65, 73, 81, 89, 97, 105, 113, 121, 129] | |
} | |
service = [] # name, update rate, bytes, nb. nodes | |
service.append(("dyn_ctrl", 400, 8, 2+3*2)) # float32 pos, float16 vel, float16 torque, 2 wheels + 3 per arm | |
service.append(("pos_fb (odom)", 400, 2, 2)) # uint16 coder cnt | |
service.append(("pos_fb", 100, 2, 6)) # uint16 coder cnt | |
service.append(("servoctrl", 50, 4, 16)) # float32 pos | |
service.append(("servoctrl", 100, 4, 16)) # float32 pos | |
service.append(("dist_sens", 50, 2, 8)) | |
# service.append(("pid_calib", 5000, 4, 1)) # float16 err, float16 ctr | |
print("using {}bit can id".format(cid)) | |
budget = 0 | |
for s in service: | |
cost = s[1] * framebits[cid][s[2]] * s[3] | |
print("{:15}: {:4}Hz, {}byte, {:2} nodes, {}%".format(*(s+(cost/10000,)))) | |
budget += cost | |
print() | |
print("budget: {} / 1000000 = {}%".format(budget, budget/10000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment