Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion launch/sofia_perception.launch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<launch>
<node pkg="tf" type="static_transform_publisher" name="camera_link_broadcaster" args="0 0 0 0 0 0 0 /end_effector_link /camera 100" />
<!-- <node pkg="tf" type="static_transform_publisher" name="camera_link_broadcaster" args="0 0 0 0 0 0 0 /end_effector_link /camera 100" /> -->
<node pkg="sofia_perception" type="perception_server.py" name="perception_server" output="screen" />
</launch>
Binary file added resources/perception.bag
Binary file not shown.
2 changes: 1 addition & 1 deletion scripts/optimize_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def plot_inputs(self, ax1, col='k'):
optim = Fminsearch()
optim.load_set(poses_path, tfs_path)

# initial guess for the optimization algorithm written as position + quaternion (x, y, z, qx, qy, qz, qw)
# REPLACE initial guess (t1) for the optimization algorithm written as position + quaternion (x, y, z, qx, qy, qz, qw) with your calculated guess
t1 = np.asarray([0, 0, 0, 0, 0, 0, 0])
topt, f = optim.do_optimise_T(t1)

Expand Down
12 changes: 8 additions & 4 deletions scripts/perception_server.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,29 @@ class SofiaPerception(object):
def __init__(self):
self.detect_object_srv = rospy.Service('detect_object', DetectObject, self.detect_object)
print("DetectObject srv is now available")
self.z = 0.05
rospy.spin()

def detect_object(self, req):
self.points = ros_numpy.point_cloud2.pointcloud2_to_array(req.input_pc)
z_values = self.points['z']
mask = ~np.isnan(z_values) * (z_values > self.z) * (z_values < self.z + 0.15) # removing spurious points
self.points = self.points[mask]

#########################
## YOUR CODE GOES HERE ##
#########################

z_values = self.points['z']
mask = ~np.isnan(z_values) * (z_values > self.z) * (z_values < self.z + 0.15) # removing spurious points
self.points = self.points[mask]

object_centroid = Point()
# object_centroid.x = ...
# object_centroid.y = ...
# object_centroid.z = ...

res = DetectObjectResponse()
res.object_centroid = object_centroid
res.object_centroid_yellow = object_centroid
res.object_centroid_green = object_centroid
res.object_centroid_blue = object_centroid

return res

Expand Down
4 changes: 3 additions & 1 deletion srv/DetectObject.srv
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
sensor_msgs/PointCloud2 input_pc
---
geometry_msgs/Point object_centroid
geometry_msgs/Point object_centroid_yellow
geometry_msgs/Point object_centroid_green
geometry_msgs/Point object_centroid_blue