Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Introduction To Robotics
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GUT Teaching
introduction-to-robotics
Introduction To Robotics
Commits
09c615ba
Commit
09c615ba
authored
1 month ago
by
Brolin Antony
Browse files
Options
Downloads
Patches
Plain Diff
updating example code documentation
parent
20141098
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Exercises/catkin_ws/src/pick_and_place/scripts/pick_place_example.py
+21
-26
21 additions, 26 deletions
...atkin_ws/src/pick_and_place/scripts/pick_place_example.py
with
21 additions
and
26 deletions
Exercises/catkin_ws/src/pick_and_place/scripts/pick_place_example.py
+
21
−
26
View file @
09c615ba
...
@@ -78,20 +78,20 @@ def add_items(scene, frame):
...
@@ -78,20 +78,20 @@ def add_items(scene, frame):
Returns the items that can be picked as an array.
Returns the items that can be picked as an array.
'''
'''
rospy
.
loginfo
(
"
-- Adding Objects --
"
)
rospy
.
loginfo
(
"
-- Adding Objects --
"
)
height_from_ground
=
0.0
height_from_ground
=
0.0
#change this to move the table up or down
#Define the objects
#Define the objects
table1
=
create_object
(
obj_id
=
"
table1
"
,
ref_frame
=
frame
,
table1
=
create_object
(
obj_id
=
"
table1
"
,
ref_frame
=
frame
,
dimensions
=
[
0.
2
,
0.5
,
0.01
],
dimensions
=
[
0.
1
,
0.5
,
0.01
],
pose
=
[
0.
3
,
0.0
,
height_from_ground
,
0.0
,
0.0
,
0.0
],)
pose
=
[
0.
2
,
0.0
,
height_from_ground
,
0.0
,
0.0
,
0.0
],)
table2
=
create_object
(
obj_id
=
"
table2
"
,
ref_frame
=
frame
,
table2
=
create_object
(
obj_id
=
"
table2
"
,
ref_frame
=
frame
,
dimensions
=
[
0.
2
,
0.5
,
0.01
],
dimensions
=
[
0.
1
,
0.5
,
0.01
],
pose
=
[
-
0.
3
,
0.0
,
height_from_ground
,
0.0
,
0.0
,
0.0
])
pose
=
[
-
0.
2
,
0.0
,
height_from_ground
,
0.0
,
0.0
,
0.0
])
box1
=
create_object
(
obj_id
=
"
box1
"
,
ref_frame
=
frame
,
box1
=
create_object
(
obj_id
=
"
box1
"
,
ref_frame
=
frame
,
dimensions
=
[
0.
1
,
0.025
,
0.025
],
dimensions
=
[
0.
05
,
0.025
,
0.025
],
pose
=
[
0.
3
,
0
,
height_from_ground
+
(
0.05
/
2.0
),
0.0
,
0.0
,
0.0
])
pose
=
[
0.
2
,
0
,
height_from_ground
+
(
0.05
/
2.0
),
0.0
,
0.0
,
0.0
])
#Add Objects to the scene
#Add Objects to the scene
scene
.
add_object
(
table1
)
scene
.
add_object
(
table1
)
...
@@ -139,7 +139,6 @@ def gripper_action(gripper_end, action="open"):
...
@@ -139,7 +139,6 @@ def gripper_action(gripper_end, action="open"):
set_gripper_position
(
gripper_end
,
"
gripper_open
"
)
set_gripper_position
(
gripper_end
,
"
gripper_open
"
)
elif
(
action
==
"
close
"
):
elif
(
action
==
"
close
"
):
set_gripper_position
(
gripper_end
,
"
gripper_close
"
)
set_gripper_position
(
gripper_end
,
"
gripper_close
"
)
else
:
else
:
print
(
"
Action undefined
"
)
print
(
"
Action undefined
"
)
...
@@ -156,17 +155,13 @@ def move_to_pose(arm, goal_pose, goal_angle):
...
@@ -156,17 +155,13 @@ def move_to_pose(arm, goal_pose, goal_angle):
None
None
'''
'''
#NOTE:
#NOTE:
#The planner will create a plan for the panda_link8 to reach
#The planner will create a plan for the gripper_center to reach
#the goal pose. But since we have an end-endeffector attached to it
#the goal pose.
#it will cause collision.
#distance between wrist(panda_link8) and gripper_end(panda_hand_tcp)
wrist_to_tcp
=
0.103
# rospy.logwarn("planning and moving to location")
# rospy.logwarn("planning and moving to location")
gripper_angle
=
geometry_msgs
.
msg
.
Quaternion
()
gripper_angle
=
geometry_msgs
.
msg
.
Quaternion
()
#Orientation of the tcp(
world
) w.r.t base frame(
gripper_center
)
#Orientation of the tcp(
gripper_center
) w.r.t base frame(
world
)
rpy
=
[
math
.
radians
(
goal_angle
[
0
]),
math
.
radians
(
goal_angle
[
1
]),
math
.
radians
(
goal_angle
[
2
])]
rpy
=
[
math
.
radians
(
goal_angle
[
0
]),
math
.
radians
(
goal_angle
[
1
]),
math
.
radians
(
goal_angle
[
2
])]
quaternion
=
tf
.
transformations
.
quaternion_from_euler
(
rpy
[
0
],
rpy
[
1
],
rpy
[
2
])
quaternion
=
tf
.
transformations
.
quaternion_from_euler
(
rpy
[
0
],
rpy
[
1
],
rpy
[
2
])
...
@@ -186,7 +181,7 @@ def move_to_pose(arm, goal_pose, goal_angle):
...
@@ -186,7 +181,7 @@ def move_to_pose(arm, goal_pose, goal_angle):
.
format
(
grasp_pose
.
position
.
x
,
grasp_pose
.
position
.
y
,
grasp_pose
.
position
.
z
,
.
format
(
grasp_pose
.
position
.
x
,
grasp_pose
.
position
.
y
,
grasp_pose
.
position
.
z
,
goal_angle
[
0
],
goal_angle
[
1
],
goal_angle
[
2
]))
goal_angle
[
0
],
goal_angle
[
1
],
goal_angle
[
2
]))
arm
.
set_goal_position_tolerance
(
0.1
)
#setting tolerence for pose
arm
.
set_goal_position_tolerance
(
0.
0
1
)
#setting tolerence for pose
arm
.
set_pose_target
(
grasp_pose
)
#setting the pose of the end-effector
arm
.
set_pose_target
(
grasp_pose
)
#setting the pose of the end-effector
plan
=
arm
.
go
(
wait
=
True
)
#move the arm to the grasp_pose.
plan
=
arm
.
go
(
wait
=
True
)
#move the arm to the grasp_pose.
...
@@ -262,27 +257,27 @@ def main():
...
@@ -262,27 +257,27 @@ def main():
#Adding objects to the scene
#Adding objects to the scene
add_items
(
scene
,
planning_frame
)
add_items
(
scene
,
planning_frame
)
#Simulating Gripper actions
#Simulating Gripper actions
#
rospy.loginfo("------------------")
rospy
.
loginfo
(
"
------------------
"
)
#
rospy.loginfo("Closing Gripper")
rospy
.
loginfo
(
"
Closing Gripper
"
)
#
gripper_action(gripper, action="close")
gripper_action
(
gripper
,
action
=
"
close
"
)
#
rospy.loginfo("Openning Gripper")
rospy
.
loginfo
(
"
Openning Gripper
"
)
#
gripper_action(gripper, action="open")
gripper_action
(
gripper
,
action
=
"
open
"
)
#
rospy.loginfo("------------------")
rospy
.
loginfo
(
"
------------------
"
)
rospy
.
loginfo
(
"
Moving to pose1
"
)
rospy
.
loginfo
(
"
Moving to pose1
"
)
position1
=
[
0.
3
21
,
-
0.0
34
,
0.1
18
]
position1
=
[
0.2
3
1
,
-
0.0
22
,
0.1
03
]
orientation1
=
[
-
90.
038
,
27.682
,
-
5.
997
]
orientation1
=
[
-
90.
174
,
41.199
,
-
5.
554
]
move_to_pose
(
arm
,
position1
,
orientation1
)
#sending goal pose
move_to_pose
(
arm
,
position1
,
orientation1
)
#sending goal pose
rospy
.
loginfo
(
"
Moving to pose2
"
)
rospy
.
loginfo
(
"
Moving to pose2
"
)
position2
=
position1
#copying the position from pose1
position2
=
position1
#copying the position from pose1
orientation2
=
[
-
89.
934
,
27.686
,
174.061
]
#copying the orientation from pose1
orientation2
=
[
-
89.
870
,
41.196
,
173.669
]
#copying the orientation from pose1
position2
[
0
]
=
-
1
*
position2
[
0
]
#creating a different x value
position2
[
0
]
=
-
1
*
position2
[
0
]
#creating a different x value
position2
[
1
]
=
-
1
*
position2
[
1
]
#creating a different
x
value
position2
[
1
]
=
-
1
*
position2
[
1
]
#creating a different
y
value
move_to_pose
(
arm
,
position2
,
orientation2
)
#sending the goal pose
move_to_pose
(
arm
,
position2
,
orientation2
)
#sending the goal pose
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment