4 import roslib; roslib.load_manifest(PKG)
11 #include <hrpModel/Body.h> 13 int main (int argc, char** argv) 15 hrp::BodyPtr body(new hrp::Body()); 19 from subprocess
import call, check_output, Popen, PIPE, STDOUT
27 openhrp3_path = check_output([
'rospack',
'find',
'openhrp3']).rstrip()
28 if os.path.exists(os.path.join(openhrp3_path,
"bin")) :
29 self.
PKG_CONFIG_PATH=
'PKG_CONFIG_PATH=%s/lib/pkgconfig:$PKG_CONFIG_PATH'%(openhrp3_path)
32 return check_output(
"%s pkg-config openhrp3.1 --variable=%s"%(self.
PKG_CONFIG_PATH, var), shell=
True).rstrip()
37 pkg_path = os.path.join(pkg_dname, fname)
38 pkg_ret = os.path.exists(pkg_path)
39 self.assertTrue(pkg_ret,
"pkg-config openhrp3.1 --variable=%s`/%s (%s) returns %r"%(pkg_var, fname, pkg_path, pkg_ret))
47 pkg_dname = check_output([
'rospack',
'find',
'openhrp3']).rstrip()
48 pkg_path = os.path.join(pkg_dname, fname)
49 pkg_ret = os.path.exists(pkg_path)
50 self.assertTrue(pkg_ret,
"`rospack find openhrp3`(%s) returns %r"%(pkg_path, pkg_ret))
82 print "`"+cmd+
"` =",check_output(cmd, shell=
True, stderr=STDOUT)
83 ret = call(
"g++ -o openhrp3-sample-pkg-config /tmp/%d-openhrp3-sample.cpp `%s`"%(PID,cmd), shell=
True)
84 self.assertTrue(ret==0)
87 cmd1 =
"pkg-config openhrp3.1 --cflags --libs" 88 cmd2 =
"pkg-config openhrp3.1 --variable=idl_dir" 89 print "`"+cmd1+
"` =",check_output(cmd1, shell=
True, stderr=STDOUT)
90 print "`"+cmd2+
"` =",check_output(cmd2, shell=
True, stderr=STDOUT)
91 ret = call(
"g++ -o move_ankle `%s`/../sample/example/move_ankle/move_ankle.cpp `%s`"%(cmd2,cmd1), shell=
True)
92 self.assertTrue(ret==0)
95 cmd =
"%s pkg-config openhrp3.1 --variable=idl_dir"%(self.
PKG_CONFIG_PATH)
96 fname =
"OpenHRP/OpenHRPCommon.idl" 98 print "`"+cmd+
"`"+fname+
" = "+os.path.join(check_output(cmd, shell=
True).rstrip(), fname)
99 self.assertTrue(os.path.exists(os.path.join(check_output(cmd, shell=
True).rstrip(), fname)))
102 cmd =
"%s pkg-config openhrp3.1 --variable=idl_dir"%(self.
PKG_CONFIG_PATH)
103 fname =
"../sample/model/PA10/pa10.main.wrl" 105 print "`"+cmd+
"`"+fname+
" = "+os.path.join(check_output(cmd, shell=
True).rstrip(), fname)
106 self.assertTrue(os.path.exists(os.path.join(check_output(cmd, shell=
True).rstrip(), fname)))
108 cmd =
"%s pkg-config openhrp3.1 --variable=prefix"%(self.
PKG_CONFIG_PATH)
109 fname =
"share/OpenHRP-3.1/sample/model/PA10/pa10.main.wrl" 111 print "`"+cmd+
"`"+fname+
" = "+os.path.join(check_output(cmd, shell=
True).rstrip(), fname)
112 self.assertTrue(os.path.exists(os.path.join(check_output(cmd, shell=
True).rstrip(), fname)))
115 cmd =
"%s pkg-config openhrp3.1 --variable=idl_dir"%(self.
PKG_CONFIG_PATH)
116 fname =
"../sample/model/sample1.wrl" 118 print "`"+cmd+
"`"+fname+
" = "+os.path.join(check_output(cmd, shell=
True).rstrip(), fname)
119 self.assertTrue(os.path.exists(os.path.join(check_output(cmd, shell=
True).rstrip(), fname)),
"cmd = %r, fname = %r"%(cmd, fname))
122 fname =
"../sample/controller/SampleController/etc/Sample.pos" 123 print "`"+cmd+
"`"+fname+
" = "+os.path.join(check_output(cmd, shell=
True).rstrip(), fname)
124 self.assertTrue(os.path.exists(os.path.join(check_output(cmd, shell=
True).rstrip(), fname)),
"cmd = %r, fname = %r"%(cmd, fname))
126 cmd =
"%s pkg-config openhrp3.1 --variable=prefix"%(self.
PKG_CONFIG_PATH)
127 fname =
"share/OpenHRP-3.1/sample/model/sample1.wrl" 129 print "`"+cmd+
"`"+fname+
" = "+os.path.join(check_output(cmd, shell=
True).rstrip(), fname)
130 self.assertTrue(os.path.exists(os.path.join(check_output(cmd, shell=
True).rstrip(), fname)),
"cmd = %r, fname = %r"%(cmd, fname))
133 fname =
"share/OpenHRP-3.1/sample/controller/SampleController/etc/Sample.pos" 134 print "`"+cmd+
"`"+fname+
" = "+os.path.join(check_output(cmd, shell=
True).rstrip(), fname)
135 self.assertTrue(os.path.exists(os.path.join(check_output(cmd, shell=
True).rstrip(), fname)),
"cmd = %r, fname = %r"%(cmd, fname))
138 if __name__ ==
'__main__':
142 f = open(
"/tmp/%d-openhrp3-sample.cpp"%(PID),
'w')
145 rostest.rosrun(PKG,
'test_openhrp3', TestCompile)
def check_if_file_exists_from_prefix(self, fname)
def test_config_variables(self)
A sample python unit test.
def test_sample_pa10(self)
def test_files_for_hrpsys(self)
def test_compile_pkg_config(self)
test 1 == 1
def test_files_for_hrpsys_ros_bridge(self)
def check_if_file_exists(self, var, fname)
def _test_compile_move_ankle(self)
def test_sample_samplerobot(self)
def check_if_file_exists_from_rospack(self, fname)
def pkg_config_variable(self, var)