Implementing comm protocols#5
Conversation
…ng ros2sim with hym_solo
Pull Request Test Coverage Report for Build 611747165
💛 - Coveralls |
goobta
left a comment
There was a problem hiding this comment.
This was a big one, great work! Just a handful of comments and questions.
| def get_joint_values(self, ): | ||
| """Return a dictionary containing joint values based on joint ordering | ||
| """ | ||
| pass |
| ## This is important to preserve the exact values of joint values. | ||
| # Converting frop degrees to radians and back to degrees can cause some floating point | ||
| # differences to exist. This essentially gets rid of them. | ||
| values = np.round(values) |
There was a problem hiding this comment.
Wouldn't rounding cause a more significant error (floating point errors might exist, but our sensors are def not reading at that resolution)?
| if len(action_deg) != len(self.env.joint_ordering): | ||
| raise ValueError |
There was a problem hiding this comment.
Do we want to be suppressing this exception? In other words, should we remove the try/except so that the program just exists?
Not sure what the intended behavior is, so your call.
| except: | ||
| raise ValueError('The action needs to have the same number of joint as ' | ||
| 'the robot') |
There was a problem hiding this comment.
Are you just reraising the same exception? Then you would want to do something like the following:
try:
raise ValueError('Error1')
except:
raiseThe raise keyword will essentially reraise the exception that was caught. Re-raising the original exception allows the context of the exception to be maintained.
For example, consider the following:
try:
if err = 'error1':
raise ValueError('value1')
elif err = 'error2':
raise ValueError('value2')
else:
raiseThat way, you know exactly which error is being raised, even if they are the same error.
| for i, rad in enumerate(ground_truth_rad): | ||
| if rad > math.pi: | ||
| ground_truth_rad[i] -= (2 * math.pi) | ||
| #print(self.env_stub.step.call_args[0][0]) |
| import serial | ||
| import threading | ||
| import copy | ||
| import logging |
There was a problem hiding this comment.
Should make this into an issue, but we should make this into a named logger for file handling and whatnot.
Actually the best bet would be to make this into an issue: I think I have a code example somewhere on how to set up the loggers properly.
| # Initial state of the state machine | ||
| self.serial_read_state = SerialReadState.INIT | ||
| # List of all possible states for the state machine | ||
| self.list_of_states = [state for state in SerialReadState] |
There was a problem hiding this comment.
is there no function in the enum that does this? i.e. list(SerialReadState)? genuinely have no idea.
| # while True: | ||
| # request = b'' | ||
| # while not request.endswith(s.EOM.value): | ||
| # request += os.read(self.master, 1) | ||
|
|
||
| # response = self.parser.parse(request) | ||
| # os.write(self.master, response + s.EOM.value) |
| else: | ||
| logging.debug("Updating Joint Angles") | ||
| logging.debug("The received data is: {}".format(self.validated_packed_data)) | ||
| self.sim_executor.action(self.validated_packed_data) |
There was a problem hiding this comment.
No response / heartbeat on the action?
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
No newline at end of file |
This is a working version of ros2sim that implements our communication protocols to interact with the original solo8