-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Icub dev #241
base: dev
Are you sure you want to change the base?
Icub dev #241
Changes from 21 commits
5dca4e7
6a15414
c083502
0632c6c
be79bf2
3a0f739
0a788fc
316e7a1
b0a980e
6083ad7
087d86d
05d791c
8b305fb
be8500b
9b62853
7ba39af
13e8c5b
9a3b7e3
8124de0
ec1fdb5
837e4aa
abd246c
2a07761
3da3b33
949efc0
c78f026
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from typing_extensions import Tuple,Optional | ||
|
||
import yarp | ||
|
||
|
||
ACK_VOCAB = yarp.createVocab32('a','c','k') | ||
NO_ACK_VOCAB = yarp.createVocab32('n','a','c','k') | ||
|
||
|
||
def init_yarp_network(): | ||
""" | ||
Initializes the YARP network. | ||
|
||
**Returns:** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please stick to the rst standard There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
- `True` if the YARP network is successfully initialized. | ||
- `False` if no YARP server is found. | ||
""" | ||
if not yarp.Network.checkNetwork(): | ||
print("Unable to find a yarp server exiting ...") | ||
return False | ||
|
||
yarp.Network.init() | ||
return True | ||
|
||
def open_rpc_client_port(port_name:str)->Tuple[bool, Optional[yarp.RpcClient]]: | ||
""" | ||
Opens a YARP RpcClient port with the specified name. | ||
|
||
**Parameters:** | ||
- `port_name` (str): The name of the RPC client port to be opened. | ||
|
||
**Returns:** | ||
- Tuple: (bool, yarp.RpcClient or None) | ||
- `True` and the opened port if successful. | ||
- `False` and `None` if the port fails to open. | ||
""" | ||
handle_port: yarp.RpcClient = yarp.RpcClient() | ||
if not handle_port.open(port_name): | ||
print(f"Can't open the port %s correctly" % port_name) | ||
return False , None | ||
print(f"Port %s opened correctly" % port_name) | ||
return True , handle_port | ||
|
||
def open_buffered_bottle_port(port_name:str)->Tuple[bool, Optional[yarp.BufferedPortBottle]]: | ||
""" | ||
Opens a YARP BufferedPortBottle with the specified port name. | ||
|
||
**Parameters:** | ||
- `port_name` (str): The name of the port to be opened. | ||
|
||
**Returns:** | ||
- Tuple: (bool, yarp.BufferedPortBottle or None) | ||
- `True` and the opened port if successful. | ||
- `False` and `None` if the port fails to open. | ||
""" | ||
opened_port: yarp.BufferedPortBottle = yarp.BufferedPortBottle() | ||
if not opened_port.open(port_name): | ||
print(f"Can't open the port %s correctly" % port_name) | ||
return False , None | ||
print(f"Port %s opened correctly" % port_name) | ||
return True , opened_port | ||
|
||
|
||
def interrupt_and_close(m_module:yarp.RFModule): | ||
m_module.interruptModule() | ||
m_module.close() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -425,3 +425,9 @@ def close(self) -> ProcessModule: | |
""" | ||
raise NotImplementedError( | ||
f"There are no Process Modules for '{inspect.currentframe().f_code.co_name}' for robot '{self.robot_name}'") | ||
|
||
def exit(self)->None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The exit method for Process modules is a nice idea. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't this what i did ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes what you did is correct, I was just confused about the structure of the ProcessModuleManager |
||
""" | ||
Exit process module and disconnect from robot | ||
""" | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs a try, catch block