Skip to content
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

Open
wants to merge 26 commits into
base: dev
Choose a base branch
from
Open

Icub dev #241

wants to merge 26 commits into from

Conversation

omareldardear
Copy link

@omareldardear omareldardear commented Dec 9, 2024

Dear all,

I create here the main pull request for the major updates of the integration of the iCub robot into pycram.
In the next 2 days, I will replace some prints with exception handling and add some documentation.

I create this pull request to initiate the process to speed up the integration.
Please have a look and let me know if there are any reviews

There are some requirements to have the code running. I will add all the details in README soon.

Thanks

@@ -419,3 +419,9 @@ def close(self) -> Type[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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exit method for Process modules is a nice idea.
But the actual code to exit the connection to a robot should be directly in the Process module.
Please also add an exit method to the ProcessModule parent class and then call the currently loaded ProcessModule.exit method from this method

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this what i did ?
Would you explain more this part

Copy link
Collaborator

Choose a reason for hiding this comment

The 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

from ..datastructures.enums import JointType, ObjectType, Arms, ExecutionType, GripperState
from ..external_interfaces import giskard
from ..external_interfaces.robokudo import *
import yarp
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This add yarp as a hard dependency. Wrap this into a try, catch and add a log function in case the imports fail. Look here for reference

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

for i in hand_values:
target_loc.addFloat32(i)

print("command Ready to send to iCub part tcp")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use pycram.ros.logging instead of print statements, throughout the whole file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return False

HAND_CLOSED = [60.0,60.0,0,85.0,20,85,20,85,85]
HAND_OPENED = [0 ,0 ,0,0 ,0 ,0 ,0 ,0 ,0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess these are joint values for the hand, they are already in the robot_description use these insetad and remove the global variable

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not all the joint are directly actuated 1:1.
In the robot description I have the values for every joint for close and open. However the control joints are different and also different values.
So this list is the actuated control values. which is only used for the real robot
What do you think ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, then you cloud put them in the move_gripper process module of the real robot. This way it should be clear where they are used.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE

from ..external_interfaces.robokudo import *
import yarp

from pycram.yarp_utils.yarp_networking import NO_ACK_VOCAB, ACK_VOCAB, open_rpc_client_port, open_buffered_bottle_port, \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to move the calls to yarp into its own file and put this in external_interfaces instead of yarp_utils. So people know what purpose yarp has.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

ProcessModuleManager.execution_type = ExecutionType.SIMULATED
cls.viz_marker_publisher = VizMarkerPublisher()

def test_move_joint_direct(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no assert here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted the whole file, this was just for me to test the implementation.
I think I will try to make jupyter notebook on virtual labs for this instead of here

def test_move_joints_simulated(self):
with simulated_robot:
MoveJointsMotion(["torso_roll"], [math.radians(-20.0)]).perform()
sleep(3)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these sleeps necessary? Are the calls in yarp asynchronous?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, not necessary, it was just too fast to see it in the simulation. Anyways, the whole file os removed :)

MoveGripperMotion(GripperState.CLOSE, Arms.LEFT).perform()
sleep(10)
MoveGripperMotion(GripperState.OPEN, Arms.RIGHT).perform()
MoveGripperMotion(GripperState.OPEN, Arms.LEFT).perform()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also no asserts here. So you are only executing the motions and checking if nothing crashes

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same



def test_try_world(self):
sleep(100)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What? Why?
I guess this was for testing, in this case please delete it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same



with real_robot:
yarpModule = run_icub_state_updater(['/', '--robot', 'icubSim'])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is unittest.skip for this case, look here for reference

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@omareldardear omareldardear requested a review from Tigul December 11, 2024 09:39
Copy link
Collaborator

@sunava sunava Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please checkout the new default_process_modules and how specific process modules are handled

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't change the default processing modules for the simulated robot.
I used them as it is.

For the real robot, I implemented the specific functionalities to control icub in the right way.
Note: the tcp/looking/ etc poses are expected to be w.r.t. robot frame. At the moment as we don't have a simulated world for the real robot. maybe lateron, we can easily do the transformation.

If there is any other notes, please clarify what you mean.
Thanks

@sunava sunava self-requested a review December 11, 2024 13:14
"""
Initializes the YARP network.

**Returns:**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please stick to the rst standard

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,66 @@
from typing_extensions import Tuple,Optional

import yarp
Copy link
Collaborator

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

loginfo("Received: another reply")
return False

def update_part(state_port,ctp_port, joint_to_change_idx, joints_to_change_pos):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add documentation here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

This point can either be a position or an object.
"""

def __init__(self,lock,cmd_port:yarp.RpcClient):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type annotation yarp.RpcClient will not work if yarp is not there. You can put it in quotation marks to prevent the interpreter evaluating it

@omareldardear
Copy link
Author

I noticed that the CI/CD checks failed because of the imports of yarp.
I did a fix and pushed the changes.

@omareldardear
Copy link
Author

let me check again your last reviews. I just noticed it

@omareldardear
Copy link
Author

omareldardear commented Dec 11, 2024

I went through the code again and all your comments.
You can check again now @Tigul

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants