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, Popen, PIPE, STDOUT
21 from subprocess
import check_output
as _check_output
22 def check_output(*args, **kwargs):
return _check_output(*args, **kwargs).decode(
'ascii')
30 openhrp3_path =
check_output([
'rospack',
'find',
'openhrp3']).rstrip()
31 if os.path.exists(os.path.join(openhrp3_path,
"bin")) :
32 self.
PKG_CONFIG_PATH=
'PKG_CONFIG_PATH=%s/lib/pkgconfig:$PKG_CONFIG_PATH'%(openhrp3_path)
40 pkg_path = os.path.join(pkg_dname, fname)
41 pkg_ret = os.path.exists(pkg_path)
42 self.assertTrue(pkg_ret,
"pkg-config openhrp3.1 --variable=%s`/%s (%s) returns %r"%(pkg_var, fname, pkg_path, pkg_ret))
50 pkg_dname =
check_output([
'rospack',
'find',
'openhrp3']).rstrip()
51 pkg_path = os.path.join(pkg_dname, fname)
52 pkg_ret = os.path.exists(pkg_path)
53 self.assertTrue(pkg_ret,
"`rospack find openhrp3`(%s) returns %r"%(pkg_path, pkg_ret))
85 print(
"`"+cmd+
"` =",
check_output(cmd, shell=
True, stderr=STDOUT))
86 ret = call(
"g++ -o openhrp3-sample-pkg-config /tmp/%d-openhrp3-sample.cpp `%s`"%(PID,cmd), shell=
True)
87 self.assertTrue(ret==0)
90 cmd1 =
"pkg-config openhrp3.1 --cflags --libs" 91 cmd2 =
"pkg-config openhrp3.1 --variable=idl_dir" 92 print(
"`"+cmd1+
"` =",
check_output(cmd1, shell=
True, stderr=STDOUT))
93 print(
"`"+cmd2+
"` =",
check_output(cmd2, shell=
True, stderr=STDOUT))
94 ret = call(
"g++ -o move_ankle `%s`/../sample/example/move_ankle/move_ankle.cpp `%s`"%(cmd2,cmd1), shell=
True)
95 self.assertTrue(ret==0)
98 cmd =
"%s pkg-config openhrp3.1 --variable=idl_dir"%(self.
PKG_CONFIG_PATH)
99 fname =
"OpenHRP/OpenHRPCommon.idl" 101 print(
"`"+cmd+
"`"+fname+
" = "+os.path.join(
check_output(cmd, shell=
True).rstrip(), fname))
102 self.assertTrue(os.path.exists(os.path.join(
check_output(cmd, shell=
True).rstrip(), fname)))
105 cmd =
"%s pkg-config openhrp3.1 --variable=idl_dir"%(self.
PKG_CONFIG_PATH)
106 fname =
"../sample/model/PA10/pa10.main.wrl" 108 print(
"`"+cmd+
"`"+fname+
" = "+os.path.join(
check_output(cmd, shell=
True).rstrip(), fname))
109 self.assertTrue(os.path.exists(os.path.join(
check_output(cmd, shell=
True).rstrip(), fname)))
111 cmd =
"%s pkg-config openhrp3.1 --variable=prefix"%(self.
PKG_CONFIG_PATH)
112 fname =
"share/OpenHRP-3.1/sample/model/PA10/pa10.main.wrl" 114 print(
"`"+cmd+
"`"+fname+
" = "+os.path.join(
check_output(cmd, shell=
True).rstrip(), fname))
115 self.assertTrue(os.path.exists(os.path.join(
check_output(cmd, shell=
True).rstrip(), fname)))
118 cmd =
"%s pkg-config openhrp3.1 --variable=idl_dir"%(self.
PKG_CONFIG_PATH)
119 fname =
"../sample/model/sample1.wrl" 121 print(
"`"+cmd+
"`"+fname+
" = "+os.path.join(
check_output(cmd, shell=
True).rstrip(), fname))
122 self.assertTrue(os.path.exists(os.path.join(
check_output(cmd, shell=
True).rstrip(), fname)),
"cmd = %r, fname = %r"%(cmd, fname))
125 fname =
"../sample/controller/SampleController/etc/Sample.pos" 126 print(
"`"+cmd+
"`"+fname+
" = "+os.path.join(
check_output(cmd, shell=
True).rstrip(), fname))
127 self.assertTrue(os.path.exists(os.path.join(
check_output(cmd, shell=
True).rstrip(), fname)),
"cmd = %r, fname = %r"%(cmd, fname))
129 cmd =
"%s pkg-config openhrp3.1 --variable=prefix"%(self.
PKG_CONFIG_PATH)
130 fname =
"share/OpenHRP-3.1/sample/model/sample1.wrl" 132 print(
"`"+cmd+
"`"+fname+
" = "+os.path.join(
check_output(cmd, shell=
True).rstrip(), fname))
133 self.assertTrue(os.path.exists(os.path.join(
check_output(cmd, shell=
True).rstrip(), fname)),
"cmd = %r, fname = %r"%(cmd, fname))
136 fname =
"share/OpenHRP-3.1/sample/controller/SampleController/etc/Sample.pos" 137 print(
"`"+cmd+
"`"+fname+
" = "+os.path.join(
check_output(cmd, shell=
True).rstrip(), fname))
138 self.assertTrue(os.path.exists(os.path.join(
check_output(cmd, shell=
True).rstrip(), fname)),
"cmd = %r, fname = %r"%(cmd, fname))
141 if __name__ ==
'__main__':
145 f = open(
"/tmp/%d-openhrp3-sample.cpp"%(PID),
'w')
148 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)
def check_output(args, kwargs)