Closed RaulFdzbis closed 7 years ago
Better use the IEncoders
interface: see example.
PS: Parsing [is] encs (30.0 0.0 0.0 0.0 0.0 0.0) [tsta] 70 1508927958.17612 [ok]
would be a bit more like (note that syntax may be slightly different, do not have ipython
right now):
b = self.res.get(2).asList()
and then doing similar to yours:
for i in range(b.size()):
state_now.append(b.get(i).asDouble())
print("The state now is: ",state_now)
Thank you @jgvictores!
I used IEncoders
as you suggested in the code.
Regarding these lines that are currently:
state_now=[]
state_now.append(float(str(v[0])))
state_now.append(float(str(v[1])))
state_now.append(float(str(v[3])))
Since str
is just for printing, maybe they could be more efficiently implemented as:
state_now=[]
state_now.append(v[0])
state_now.append(v[1])
state_now.append(v[3])
PS: Also careful with more get encs
along the same code.
BTW:
Confirmed this works:
b = self.res.get(2).asList()
for i in range(b.size()): state_now.append(b.get(i).asDouble()) print("The state now is: ",state_now)
Thank you @jgvictores i think we can close this issue.
When trying to get the state of the encoders from TEO, the output format is something like this.
When trying to parse that string in python to get the state of each encoders things are not so straightforward as i think should be. With the following code:
I get the following output:
I think there is a problem with the formatting of the ouput signal. To solve this I did the following:
With the output:
So I think that a possible improvement for the future could be to change the format of the output of "get encs" to have a more proper format.