-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into go-pos-unsafe-return
- Loading branch information
Showing
14 changed files
with
348 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/usr/bin/env python | ||
|
||
|
||
import math | ||
import rospy | ||
import actionlib | ||
from control_msgs.msg import * | ||
|
||
|
||
class DummyJTA(object): | ||
# create messages that are used to publish feedback/result | ||
_feedback = FollowJointTrajectoryFeedback() | ||
_result = FollowJointTrajectoryResult() | ||
|
||
def __init__(self, robot='pr2'): | ||
self._as = actionlib.SimpleActionServer('dummy_controller/follow_joint_trajectory', FollowJointTrajectoryAction, execute_cb=self.execute_cb, auto_start = False) | ||
self._as.start() | ||
rospy.logwarn("Started Dummy Joint Trajectory Action Server") | ||
rospy.logwarn("If joint < 0, set aborted") | ||
rospy.logwarn("If joint >= 100, set preempted") | ||
|
||
# Return result based on real robot jta server. | ||
# https://github.com/jsk-ros-pkg/jsk_pr2eus/pull/460#issuecomment-975418370 | ||
def execute_cb(self, goal): | ||
if len(goal.trajectory.points) > 0 and len(goal.trajectory.points[0].positions) > 0: | ||
position = goal.trajectory.points[0].positions[0] * 180 / math.pi | ||
rospy.loginfo("Received {}".format(position)) | ||
self._as.publish_feedback(self._feedback) | ||
if robot == 'pr2': | ||
if position < 0: | ||
rospy.logwarn("Set aborted") | ||
self._result.error_code = FollowJointTrajectoryResult.GOAL_TOLERANCE_VIOLATED | ||
self._as.set_aborted(result=self._result) | ||
elif position >= 100: | ||
rospy.logwarn("Set preempted") | ||
self._result.error_code = FollowJointTrajectoryResult.SUCCESSFUL | ||
self._as.set_preempted(result=self._result) | ||
else: | ||
self._result.error_code = FollowJointTrajectoryResult.SUCCESSFUL | ||
self._as.set_succeeded(result=self._result) | ||
if robot == 'fetch': | ||
if position < 0: | ||
rospy.logwarn("Set aborted") | ||
self._result.error_code = FollowJointTrajectoryResult.SUCCESSFUL | ||
self._as.set_aborted( | ||
result=self._result, | ||
text='Controller manager forced preemption.') | ||
elif position >= 100: | ||
rospy.logwarn("Set preempted") | ||
self._result.error_code = FollowJointTrajectoryResult.SUCCESSFUL | ||
self._as.set_preempted( | ||
result=self._result, | ||
text='Trajectory preempted') | ||
else: | ||
self._result.error_code = FollowJointTrajectoryResult.SUCCESSFUL | ||
self._as.set_succeeded( | ||
result=self._result, | ||
text='Trajectory succeeded.') | ||
if robot == 'kinova': | ||
if position < 0: | ||
rospy.logwarn("Set aborted") | ||
self._result.error_code = FollowJointTrajectoryResult.PATH_TOLERANCE_VIOLATED | ||
self._result.error_string = 'After validation, trajectory execution failed in the arm with sub error code SUB_ERROR_NONE' | ||
self._as.set_aborted(result=self._result) | ||
elif position >= 100: | ||
rospy.logwarn("Set preempted") | ||
self._result.error_code = FollowJointTrajectoryResult.PATH_TOLERANCE_VIOLATED | ||
self._result.error_string = 'Trajectory execution failed in the arm with sub error code 55\nThe speed while executing\\n\ the trajectory was too damn high and caused the robot to stop.\n' | ||
# NOTE: this line is not typo but kinova driver's behavior | ||
self._as.set_aborted(result=self._result) | ||
else: | ||
self._result.error_code = FollowJointTrajectoryResult.SUCCESSFUL | ||
self._as.set_succeeded(result=self._result) | ||
|
||
if __name__ == '__main__': | ||
rospy.init_node('dummy_jta') | ||
robot = rospy.get_param('~robot', 'pr2') | ||
server = DummyJTA(robot) | ||
rospy.spin() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
<launch> | ||
<arg name="gui" default="false"/> | ||
<env name="DISPLAY" value=":0.0" if="$(arg gui)"/> | ||
<env name="DISPLAY" value="" unless="$(arg gui)"/> | ||
|
||
<include file="$(find pr2eus)/test/pr2-ri-test-bringup.launch" | ||
pass_all_args="true" /> | ||
|
||
<!-- start test --> | ||
<test test-name="pr2_ri_test_base" pkg="roseus" type="roseus" retry="1" | ||
<test test-name="pr2_ri_test_base" pkg="roseus" type="roseus" retry="3" | ||
args="$(find pr2eus)/test/pr2-ri-test-base.l" time-limit="800" /> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
(require :unittest "lib/llib/unittest.l") | ||
(load "package://pr2eus/pr2-interface.l") | ||
|
||
(init-unit-test) | ||
|
||
(pr2-init) | ||
|
||
;; https://github.com/jsk-ros-pkg/jsk_pr2eus/pull/165#discussion_r37421484 | ||
(deftest test-go-pos | ||
(let () | ||
(setq *ri* (instance pr2-interface :init)) | ||
(assert (send *ri* :go-pos 1 0 0) "(send *ri* :go-pos 1 0 0)") ;; go-pos is relative to current position | ||
(assert (send *ri* :go-pos 0 1 90) "(send *ri* :go-pos 0 1 90)") | ||
(assert (send *ri* :go-pos-no-wait -1 1 -90) "(send *ri* :go-pos-no-wait -1 1 -90)") | ||
(ros::sleep 1) ;; wait for 1 sec to activate goal status... | ||
(assert (send *ri* :go-waitp) "(send *ri* :go-waitp)") | ||
(assert (send *ri* :go-wait) "(send *ri* :go-wait)") | ||
(assert (eps-v= (send (send *ri* :worldcoords ) :worldpos) #f(0 0 0))) | ||
(assert (send *ri* :go-pos-unsafe-no-wait -1 1 -90) "(send *ri* :go-pos-unsafe-no-wait -1 1 -90)") | ||
)) | ||
|
||
(deftest test-move-to | ||
(let () | ||
(setq *ri* (instance pr2-interface :init)) | ||
(assert (send *ri* :move-to (make-coords :pos #f(1000 0 0))) "(send *ri* :move-to (make-coords :pos #f(1000 0 0)))") ;; default is world and wait | ||
(send *ri* :move-to (make-coords :pos #f(1000 1000 0) :rpy (float-vector pi/2 0 0))) | ||
(assert (send *ri* :move-to (make-coords) :no-wait t) "(send *ri* :move-to (make-coords) :no-wait t)") ;; no-wait t means not wait so need to call wait | ||
(assert (send *ri* :move-to-wait) "(send *ri* :move-to-wait)") ;; wait move-to | ||
(assert (eps-v= (send (send *ri* :worldcoords ) :worldpos) #f(0 0 0))) | ||
)) | ||
|
||
(run-all-tests) | ||
(exit) |
Oops, something went wrong.