Commit 8b27326c authored by Sven Gestegård Robertz's avatar Sven Gestegård Robertz
Browse files

Merge branch 'master' of git.cs.lth.se:robotlab/GBS-labcomm

parents 960bf80e 5a2559b3
A project for bridging GBS commands using labcomm
A project for bridging GBS commands to ROS using labcomm
For an example with the Java server and python client
go to the src dir and do
For an example of the pure GBS/labcomm part, with the Java server and python
client go to the src dir and do
make runserver
......@@ -14,6 +14,10 @@ and the, in another shell, do
to run the python client
The ROS code for GBS (with and without labcomm) is in the catkin_ws directory.
NB! this project has labcomm_core as a submodule.
To setup that, do
......
/opt/ros/indigo/share/catkin/cmake/toplevel.cmake
\ No newline at end of file
cmake_minimum_required(VERSION 2.8.3)
project(gbs)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
message_generation
)
## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()
################################################
## Declare ROS messages, services and actions ##
################################################
## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependencies might have been
## pulled in transitively but can be declared for certainty nonetheless:
## * add a build_depend tag for "message_generation"
## * add a run_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
## Generate messages in the 'msg' folder
add_message_files(
FILES
GBSCmdArray.msg
GBSEuler.msg
GBSJointPose.msg
GBSPose.msg
GBSPos.msg
GBSSensor.msg
)
## Generate services in the 'srv' folder
add_service_files(
FILES
GBSCircMove.srv
GBSCombMove.srv
GBSLinMove.srv
GBSLockSpindle.srv
GBSLockTool.srv
GBSMeasureMove.srv
GBSNailLinMove.srv
GBSPTPMove.srv
GBSReadCurJointPose.srv
GBSReadSensor.srv
GBSReleasePanel.srv
GBSRunSpindle.srv
GBSShakeVacuum.srv
GBSStopSpindle.srv
GBSSwitchVacuum.srv
GBSTakePanel.srv
GBSUnlockSpindle.srv
GBSUnlockTool.srv
)
## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )
## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
std_msgs
)
###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES gbs
# CATKIN_DEPENDS roscpp rospy std_msgs
CATKIN_DEPENDS message_runtime
# DEPENDS system_lib
)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
${catkin_INCLUDE_DIRS}
)
## Declare a cpp library
# add_library(gbs
# src/${PROJECT_NAME}/gbs.cpp
# )
## Declare a cpp executable
# add_executable(gbs_node src/gbs_node.cpp)
## Add cmake target dependencies of the executable/library
## as an example, message headers may need to be generated before nodes
# add_dependencies(gbs_node gbs_generate_messages_cpp)
## Specify libraries to link a library or executable target against
# target_link_libraries(gbs_node
# ${catkin_LIBRARIES}
# )
#############
## Install ##
#############
# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark executables and/or libraries for installation
# install(TARGETS gbs gbs_node
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )
## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )
#############
## Testing ##
#############
## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_gbs.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()
## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
int32 n
float32[1000] array
float32 c
float32 b
float32 a
float32 j1
float32 j2
float32 j3
float32 j4
float32 j5
float32 j6
float32 x
float32 y
float32 z
float32 x1
float32 x2
float32 y1
<?xml version="1.0"?>
<package>
<name>gbs</name>
<version>0.0.0</version>
<description>The gbs package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
<maintainer email="mathias.haage@cs.lth.se">mathias</maintainer>
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>LGPLv2.1</license>
<!-- Url tags are optional, but mutiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/gbs</url> -->
<!-- Author tags are optional, mutiple are allowed, one per tag -->
<!-- Authors do not have to be maintianers, but could be -->
<!-- Example: -->
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->
<!-- The *_depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use build_depend for packages you need at compile time: -->
<build_depend>message_generation</build_depend>
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use run_depend for packages you need at runtime: -->
<run_depend>message_runtime</run_depend>
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
#!/usr/bin/env python
from gbs.srv import *
import rospy
class Array:
n = 0
array = [0 for i in range(100)]
def near(t, n):
return n-0.01 < t and t < n+0.01
def prettyprint(array):
i = 0
while i < array.n:
c0 = array.array[0+i]
c1 = array.array[1+i]
c2 = array.array[2+i]
if near(c0,10) and near(c1,1) and near(c2,1):
x = array.array[3+i]
y = array.array[4+i]
z = array.array[5+i]
c = array.array[6+i]
b = array.array[7+i]
a = array.array[8+i]
s = array.array[9+i]
ac = array.array[10+i]
i = i + 11
print "linmove x=%f y=%f z=%f c=%f b=%f a=%f s=%f ac=%f"%(x,y,z,c,b,a,s,ac)
elif near(c0,10) and near(c1,1) and near(c2,2):
j1 = array.array[3+i]
j2 = array.array[4+i]
j3 = array.array[5+i]
j4 = array.array[6+i]
j5 = array.array[7+i]
j6 = array.array[8+i]
s = array.array[9+i]
ac = array.array[10+i]
i = i + 11
print "ptpmove j1=%f j2=%f j3=%f j4=%f j5=%f j6=%f s=%f ac=%f"%(j1,j2,j3,j4,j5,j6,s,ac)
elif near(c0,2) and near(c1,1) and near(c2,4):
i = i + 3
print "readlibrary"
elif near(c0,2) and near(c1,1) and near(c2,5):
i = i + 3
print "readcurrentrobotpos"
elif near(c0,2) and near(c1,1) and near(c2,6):
i = i + 3
print "locktool"
elif near(c0,2) and near(c1,1) and near(c2,7):
i = i + 3
print "unlocktool"
elif near(c0,18) and near(c1,1) and near(c2,8):
id = array.array[3+i]
bstop = array.array[4+i]
s = array.array[5+i]
ac = array.array[6+i]
x1 = array.array[7+i]
y1 = array.array[8+i]
z1 = array.array[9+i]
c1 = array.array[10+i]
b1 = array.array[11+i]
a1 = array.array[12+i]
x2 = array.array[13+i]
y2 = array.array[14+i]
z2 = array.array[15+i]
c2 = array.array[16+i]
b2 = array.array[17+i]
a2 = array.array[18+i]
i = i + 19
print "naillinmove id=%f bstop=%f s=%f ac=%f x1=%f y1=%f z1=%f c1=%f b1=%f a1=%f x2=%f y2=%f z2=%f c2=%f b2=%f a2=%f"%(id,bstop,s,ac,x1,y1,z1,c1,b1,a1,x2,y2,z2,c2,b2,a2)
elif near(c0,11) and near(c1,1) and near(c2,8):
id = array.array[3+i]
x = array.array[4+i]
y = array.array[5+i]
z = array.array[6+i]
c = array.array[7+i]
b = array.array[8+i]
a = array.array[9+i]
s = array.array[10+i]
ac = array.array[11+i]
i = i + 12
print "measuremove id=%f x=%f y=%f z=%f c=%f b=%f a=%f s=%f ac=%f"%(id,x,y,z,c,b,a,s,ac)
elif near(c0,16) and near(c1,1) and near(c2,10):
xi = array.array[3+i]
yi = array.array[4+i]
zi = array.array[5+i]
ci = array.array[6+i]
bi = array.array[7+i]
ai = array.array[8+i]
xf = array.array[9+i]
yf = array.array[10+i]
zf = array.array[11+i]
cf = array.array[12+i]
bf = array.array[13+i]
af = array.array[14+i]
s = array.array[15+i]
ac = array.array[16+i]
i = i + 17
print "circmove xi=%f yi=%f zi=%f ci=%f bi=%f ai=%f xf=%f yf=%f zf=%f cf=%f bf=%f af=%f s=%f ac=%f"%(xi,yi,zi,ci,bi,ai,xf,yf,zf,cf,bf,af,s,ac)
elif near(c0,35) and near(c1,1) and near(c2,11):
i = i + 3
print "combmove"
while True:
cc0 = array.array[i]
if near(cc0, 1):
x = array.array[1+i]
y = array.array[2+i]
z = array.array[3+i]
c = array.array[4+i]
b = array.array[5+i]
a = array.array[6+i]
s = array.array[7+i]
ac = array.array[8+i]
i = i + 9
print " linmove x=%f y=%f z=%f c=%f b=%f a=%f s=%f ac=%f"%(x,y,z,c,b,a,s,ac)
elif near(cc0, 10):
xi = array.array[1+i]
yi = array.array[2+i]
zi = array.array[3+i]
ci = array.array[4+i]
bi = array.array[5+i]
ai = array.array[6+i]
xf = array.array[7+i]
yf = array.array[8+i]
zf = array.array[9+i]
cf = array.array[10+i]
bf = array.array[11+i]
af = array.array[12+i]
s = array.array[13+i]
ac = array.array[14+i]
i = i + 15
print " circmove xi=%f yi=%f zi=%f ci=%f bi=%f ai=%f xf=%f yf=%f zf=%f cf=%f bf=%f af=%f s=%f ac=%f"%(xi,yi,zi,ci,bi,ai,xf,yf,zf,cf,bf,af,s,ac)
elif near(cc0, 2):
j1 = array.array[1+i]
j2 = array.array[2+i]
j3 = array.array[3+i]
j4 = array.array[4+i]
j5 = array.array[5+i]
j6 = array.array[6+i]
s = array.array[7+i]
ac = array.array[8+i]
i = i + 9
print " ptpmove j1=%f j2=%f j3=%f j4=%f j5=%f j6=%f s=%f ac=%f"%(j1,j2,j3,j4,j5,j6,s,ac)
else:
break
elif near(c0,3) and near(c1,1) and near(c2,12):
rpm = array.array[3+i]
i = i + 4
print "runspindle rpm=%f"%(rpm)
elif near(c0,2) and near(c1,1) and near(c2,13):
i = i + 3
print "stopspindle"
elif near(c0,2) and near(c1,1) and near(c2,14):
i = i + 3
print "lockspindle"
elif near(c0,2) and near(c1,1) and near(c2,15):
i = i + 3
print "unlockspindle"
elif near(c0,2) and near(c1,1) and near(c2,16):
i = i + 3
print "getsensorvalues"
elif near(c0,2) and near(c1,1) and near(c2,17):
i = i + 3
print "takepanel"
elif near(c0,2) and near(c1,1) and near(c2,18):
i = i + 3
print "releasepanel"
elif near(c0,2) and near(c1,1) and near(c2,19):
i = i + 3
print "switchvacuum"
elif near(c0,2) and near(c1,1) and near(c2,20):
i = i + 3
print "shakevacuum"
else:
print "Unknown GBS command %f %f %f"%(c0,c1,c2)
return
def handle_gbs_circmove(req):
array = Array()
array.n = 17
array.array = [16,1,10, req.pi.pos.x,req.pi.pos.y,req.pi.pos.z, req.pi.ori.c,req.pi.ori.b,req.pi.ori.a, req.pf.pos.x,req.pf.pos.y,req.pf.pos.z, req.pf.ori.c,req.pf.ori.b,req.pf.ori.a, req.s, req.ac]
prettyprint(array)
ans = GBSCircMoveResponse()
ans.err1 = 0
ans.err2 = 0
return ans
def handle_gbs_combmove(req):
array = Array()
array.n = 3 + req.n
array.array = [35,1,11] + [-1 for i in range(req.n + 1)]
for i in range(req.n):
array.array[3 + i] = req.array[i]
prettyprint(array)
ans = GBSCombMoveResponse()
ans.err1 = 0
ans.err2 = 0
return ans
def handle_gbs_linmove(req):
array = Array()
array.n = 11
array.array = [10,1,1, req.p.pos.x,req.p.pos.y,req.p.pos.z, req.p.ori.c,req.p.ori.b,req.p.ori.a, req.s, req.ac]
prettyprint(array)
ans = GBSLinMoveResponse()
ans.err1 = 0
ans.err2 = 0
return ans
def handle_gbs_lockspindle(req):
array = Array()
array.n = 3
array.array = [2,1,14]
prettyprint(array)
ans = GBSLockSpindleResponse()
ans.err = 0
return ans
def handle_gbs_locktool(req):
array = Array()
array.n = 3
array.array = [2,1,6]
prettyprint(array)
ans = GBSLockToolResponse()
ans.err = 0
return ans
def handle_gbs_measuremove(req):
array = Array()
array.n = 12
array.array = [11,1,8, req.id, req.p.pos.x,req.p.pos.y,req.p.pos.z, req.p.ori.c,req.p.ori.b,req.p.ori.a, req.s, req.ac]
prettyprint(array)
ans = GBSMeasureMoveResponse()
ans.err1 = 0
ans.err2 = 0
return ans
def handle_gbs_naillinmove(req):
array = Array()
array.n = 19
array.array = [18,1,8, req.id, req.bstop, req.s, req.ac, req.p1.pos.x,req.p1.pos.y,req.p1.pos.z, req.p1.ori.c,req.p1.ori.b,req.p1.ori.a, req.p2.pos.x,req.p2.pos.y,req.p2.pos.z, req.p2.ori.c,req.p2.ori.b,req.p2.ori.a]
prettyprint(array)
ans = GBSNailLinMoveResponse()
ans.err1 = 0
ans.err2 = 0
return ans
def handle_gbs_ptpmove(req):
array = Array()
array.n = 11
array.array = [10,1,2, req.p.j1, req.p.j2, req.p.j3, req.p.j4, req.p.j5, req.p.j6, req.s, req.ac]
prettyprint(array)
ans = GBSPTPMoveResponse()
ans.err1 = 0
ans.err2 = 0
return ans
def handle_gbs_readcurjointpose(req):
array = Array()
array.n = 3
array.array = [2,1,5]
prettyprint(array)
ans = GBSReadCurJointPoseResponse()
ans.err = 0
ans.p.j1 = 0
# ...
return ans
def handle_gbs_releasepanel(req):
array = Array()
array.n = 3
array.array = [2,1,18]
prettyprint(array)
ans = GBSReleasePanelResponse()
ans.err = 0
return ans
def handle_gbs_runspindle(req):
array = Array()
array.n = 4
array.array = [3,1,12, req.rpm]
prettyprint(array)
ans = GBSRunSpindleResponse()
return ans
def handle_gbs_readsensor(req):
array = Array()
array.n = 3
array.array = [2,1,16]
prettyprint(array)
ans = GBSReadSensorResponse()
ans.err = 0
ans.data.x1 = 0