print UInt8MultiArray values in python
Hi! I would like to save into 3 arrays the fields of a custum message:
std_msgs/UInt8MultiArray pixel
std_msgs/Float64MultiArray nord
std_msgs/Float64MultiArray est
this is my callback to listen to the message. When I try to print pixel I get letters. How could I transform them to integers from 0 to 255? thanks
def callback(data):
#rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.pixel.data)
#rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.est.data)
#rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.nord.data)
pixel= np.array(data.pixel.data)
print(pixel)
est = np.array(data.est.data)
nord= np.array(data.nord.data)
Hi @v.leto can you please post what you get? Is it hexadecimal values?
Hi @osilva!
outputs
they are numbers from 0 to 255 but they are stored like strings
I have read that it is a base64 because uint8[] are converted by rosbridge to base64,...
Ok then use this tutorial to decode: https://stackabuse.com/encoding-and-d...
Should
Python is fun
Your code works. I tried to modify mine in order to look like yours but I get errors. I used an online decorder and I think my sting is not base64 as it doesn't end with ==. my string·
eehggehhdeagefhfddbcadbecbcdcdaciffabbfchaaddbdcecafabbedecccececdbfdehhfibcaabfddcgegaabacddfcbcbfeedfdccd
dccfbag
dfceceddadcefhggbfjde
bicfggffddfcgcefhehcddfchdgcfacdbfegfifgdahceidiehjjghhddafhgdaggegaefkihngihhejifehjikjdkgjgighechgehde
dcbdadddaddccfcdebdcacbcacafddecdadbacedbbadbcbc
abbccgdbfgdebekifidghdegbehfhfdfgihigifbcighidc
dcbefcccgceaddcfhdhfbdbbcdehddcccfddbceaecacbbbbfegidfbfddbd
cfdegfchfeaeeidcbccgfbh`efcfgdhkhhhjimkkhffiljjnlhmgicbfeffgeefdbeggfdbaegfdeidcbfdhdjiihdhhhcc
dihfhifahehgdehhigjihhllemmlimgfjwrfmlnliflldbcfiijfhhhaehhhlmllqoqojlmnkfllorrqstgnirqmejppnkhqmjiijildghgehdihjnnnlkfklkkhiiaffgmkgejijhdihhhkefgddjklihjoqfnnqiimqmomnlnlikhedcgfhgjkihgighfhjfkikkhghmohhhacghehfeeghlkihdgfiehcfddbachchcabadeeegedffdejkhkmrmpqslnkolrrsklqpxtsqpxsuyxxrqpprurrmqrslnifklckpk
Hi @v.leto, take a look at this discussion as there is more to the conversion that I thought: https://github.com/gramaziokohler/ros...