Repository: ahq1993/MPNet Branch: master Commit: f38623bff346 Files: 80 Total size: 393.2 KB Directory structure: gitextract_cfl6eb6l/ ├── LICENSE ├── MPNet/ │ ├── AE/ │ │ ├── CAE.py │ │ └── data_loader.py │ ├── data_loader.py │ ├── model.py │ ├── neuralplanner.py │ └── train.py ├── README.md ├── data_generation/ │ ├── Makefile │ ├── README │ ├── lcmtypes/ │ │ ├── CMakeLists.txt │ │ ├── Makefile │ │ ├── cmake/ │ │ │ ├── lcmtypes.cmake │ │ │ └── pods.cmake │ │ ├── lcmtypes/ │ │ │ ├── c/ │ │ │ │ └── lcmtypes/ │ │ │ │ ├── lcmtypes.h │ │ │ │ ├── lcmtypes_edge_t.c │ │ │ │ ├── lcmtypes_edge_t.h │ │ │ │ ├── lcmtypes_environment_t.c │ │ │ │ ├── lcmtypes_environment_t.h │ │ │ │ ├── lcmtypes_graph_t.c │ │ │ │ ├── lcmtypes_graph_t.h │ │ │ │ ├── lcmtypes_region_3d_t.c │ │ │ │ ├── lcmtypes_region_3d_t.h │ │ │ │ ├── lcmtypes_state_t.c │ │ │ │ ├── lcmtypes_state_t.h │ │ │ │ ├── lcmtypes_trajectory_t.c │ │ │ │ ├── lcmtypes_trajectory_t.h │ │ │ │ ├── lcmtypes_vertex_t.c │ │ │ │ └── lcmtypes_vertex_t.h │ │ │ ├── java/ │ │ │ │ └── lcmtypes/ │ │ │ │ ├── edge_t.java │ │ │ │ ├── environment_t.java │ │ │ │ ├── graph_t.java │ │ │ │ ├── region_3d_t.java │ │ │ │ ├── state_t.java │ │ │ │ ├── trajectory_t.java │ │ │ │ └── vertex_t.java │ │ │ ├── lcmtypes_edge_t.lcm │ │ │ ├── lcmtypes_environment_t.lcm │ │ │ ├── lcmtypes_graph_t.lcm │ │ │ ├── lcmtypes_region_3d_t.lcm │ │ │ ├── lcmtypes_state_t.lcm │ │ │ ├── lcmtypes_trajectory_t.lcm │ │ │ ├── lcmtypes_vertex_t.lcm │ │ │ └── python/ │ │ │ └── lcmtypes/ │ │ │ ├── __init__.py │ │ │ ├── edge_t.py │ │ │ ├── environment_t.py │ │ │ ├── graph_t.py │ │ │ ├── region_3d_t.py │ │ │ ├── state_t.py │ │ │ ├── trajectory_t.py │ │ │ └── vertex_t.py │ │ └── pod.xml │ ├── permute.cpp │ ├── rrtstar/ │ │ ├── CMakeLists.txt │ │ ├── Makefile │ │ ├── cmake/ │ │ │ └── pods.cmake │ │ ├── doxy/ │ │ │ └── doxy.conf │ │ └── src/ │ │ ├── CMakeLists.txt │ │ ├── CMakeLists.txt~ │ │ ├── kdtree.c │ │ ├── kdtree.h │ │ ├── rrts.h │ │ ├── rrts.hpp │ │ ├── rrts_main.cpp │ │ ├── system.h │ │ ├── system_single_integrator.cpp │ │ └── system_single_integrator.h │ ├── tobuild.txt │ └── viewer/ │ ├── CMakeLists.txt │ ├── Makefile │ ├── README │ ├── cmake/ │ │ └── pods.cmake │ └── src/ │ ├── CMakeLists.txt │ ├── main_viewer.cpp │ └── renderers/ │ ├── CMakeLists.txt │ ├── graph_renderer.cpp │ ├── graph_renderer.h │ └── graph_renderer.h~ ├── readme └── visualizer.py ================================================ FILE CONTENTS ================================================ ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2018 Ahmed Qureshi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: MPNet/AE/CAE.py ================================================ import argparse import os import torch import torchvision from torch import nn from torch.autograd import Variable from data_loader import load_dataset class Encoder(nn.Module): def __init__(self): super(Encoder, self).__init__() self.encoder = nn.Sequential(nn.Linear(2800, 512),nn.PReLU(),nn.Linear(512, 256),nn.PReLU(),nn.Linear(256, 128),nn.PReLU(),nn.Linear(128, 28)) def forward(self, x): x = self.encoder(x) return x class Decoder(nn.Module): def __init__(self): super(Decoder, self).__init__() self.decoder = nn.Sequential(nn.Linear(28, 128),nn.PReLU(),nn.Linear(128, 256),nn.PReLU(),nn.Linear(256, 512),nn.PReLU(),nn.Linear(512, 2800)) def forward(self, x): x = self.decoder(x) return x mse_loss = nn.MSELoss() lam=1e-3 def loss_function(W, x, recons_x, h): mse = mse_loss(recons_x, x) """ W is shape of N_hidden x N. So, we do not need to transpose it as opposed to http://wiseodd.github.io/techblog/2016/12/05/contractive-autoencoder/ """ dh = h*(1-h) # N_batch x N_hidden contractive_loss = torch.sum(Variable(W)**2, dim=1).sum().mul_(lam) return mse + contractive_loss def main(args): if not os.path.exists(args.model_path): os.makedirs(args.model_path) obs = load_dataset() encoder = Encoder() decoder = Decoder() if torch.cuda.is_available(): encoder.cuda() decoder.cuda() params = list(encoder.parameters())+list(decoder.parameters()) optimizer = torch.optim.Adagrad(params) total_loss=[] for epoch in range(args.num_epochs): print "epoch" + str(epoch) avg_loss=0 for i in range(0, len(obs), args.batch_size): decoder.zero_grad() encoder.zero_grad() if i+args.batch_size max_length: max_length=len(path) paths=np.zeros((N,NP,max_length,2), dtype=np.float32) ## padded paths for i in range(0,N): for j in range(0,NP): fname='../../dataset/e'+str(i)+'/path'+str(j)+'.dat' if os.path.isfile(fname): path=np.fromfile(fname) path=path.reshape(len(path)/2,2) for k in range(0,len(path)): paths[i][j][k]=path[k] dataset=[] targets=[] for i in range(0,N): for j in range(0,NP): if path_lengths[i][j]>0: for m in range(0, path_lengths[i][j]-1): data=np.zeros(32,dtype=np.float32) for k in range(0,28): data[k]=obs_rep[i][k] data[28]=paths[i][j][m][0] data[29]=paths[i][j][m][1] data[30]=paths[i][j][path_lengths[i][j]-1][0] data[31]=paths[i][j][path_lengths[i][j]-1][1] targets.append(paths[i][j][m+1]) dataset.append(data) data=zip(dataset,targets) random.shuffle(data) dataset,targets=zip(*data) return np.asarray(dataset),np.asarray(targets) #N=number of environments; NP=Number of Paths; s=starting environment no.; sp=starting_path_no #Unseen_environments==> N=10, NP=2000,s=100, sp=0 #seen_environments==> N=100, NP=200,s=0, sp=4000 def load_test_dataset(N=100,NP=200, s=0,sp=4000): obc=np.zeros((N,7,2),dtype=np.float32) temp=np.fromfile('../../dataset/obs.dat') obs=temp.reshape(len(temp)/2,2) temp=np.fromfile('../../dataset/obs_perm2.dat',np.int32) perm=temp.reshape(77520,7) ## loading obstacles for i in range(0,N): for j in range(0,7): for k in range(0,2): obc[i][j][k]=obs[perm[i+s][j]][k] Q = Encoder() Q.load_state_dict(torch.load('../models/cae_encoder.pkl')) if torch.cuda.is_available(): Q.cuda() obs_rep=np.zeros((N,28),dtype=np.float32) k=0 for i in range(s,s+N): temp=np.fromfile('../../dataset/obs_cloud/obc'+str(i)+'.dat') temp=temp.reshape(len(temp)/2,2) obstacles=np.zeros((1,2800),dtype=np.float32) obstacles[0]=temp.flatten() inp=torch.from_numpy(obstacles) inp=Variable(inp).cuda() output=Q(inp) output=output.data.cpu() obs_rep[k]=output.numpy() k=k+1 ## calculating length of the longest trajectory max_length=0 path_lengths=np.zeros((N,NP),dtype=np.int8) for i in range(0,N): for j in range(0,NP): fname='../../dataset/e'+str(i+s)+'/path'+str(j+sp)+'.dat' if os.path.isfile(fname): path=np.fromfile(fname) path=path.reshape(len(path)/2,2) path_lengths[i][j]=len(path) if len(path)> max_length: max_length=len(path) paths=np.zeros((N,NP,max_length,2), dtype=np.float32) ## padded paths for i in range(0,N): for j in range(0,NP): fname='../../dataset/e'+str(i+s)+'/path'+str(j+sp)+'.dat' if os.path.isfile(fname): path=np.fromfile(fname) path=path.reshape(len(path)/2,2) for k in range(0,len(path)): paths[i][j][k]=path[k] return obc,obs_rep,paths,path_lengths ================================================ FILE: MPNet/model.py ================================================ import torch import torch.nn as nn import torchvision.models as models from torch.nn.utils.rnn import pack_padded_sequence from torch.autograd import Variable # DMLP Model-Path Generator class MLP(nn.Module): def __init__(self, input_size, output_size): super(MLP, self).__init__() self.fc = nn.Sequential( nn.Linear(input_size, 1280),nn.PReLU(),nn.Dropout(), nn.Linear(1280, 1024),nn.PReLU(),nn.Dropout(), nn.Linear(1024, 896),nn.PReLU(),nn.Dropout(), nn.Linear(896, 768),nn.PReLU(),nn.Dropout(), nn.Linear(768, 512),nn.PReLU(),nn.Dropout(), nn.Linear(512, 384),nn.PReLU(),nn.Dropout(), nn.Linear(384, 256),nn.PReLU(), nn.Dropout(), nn.Linear(256, 256),nn.PReLU(), nn.Dropout(), nn.Linear(256, 128),nn.PReLU(), nn.Dropout(), nn.Linear(128, 64),nn.PReLU(), nn.Dropout(), nn.Linear(64, 32),nn.PReLU(), nn.Linear(32, output_size)) def forward(self, x): out = self.fc(x) return out ================================================ FILE: MPNet/neuralplanner.py ================================================ import argparse import torch import torch.nn as nn import numpy as np import os import pickle from data_loader import load_test_dataset from model import MLP from torch.autograd import Variable import math import time size=5.0 # Load trained model for path generation mlp = MLP(32, 2) # simple @D mlp.load_state_dict(torch.load('models/mlp_100_4000_PReLU_ae_dd150.pkl')) if torch.cuda.is_available(): mlp.cuda() #load test dataset obc,obstacles, paths, path_lengths= load_test_dataset() def IsInCollision(x,idx): s=np.zeros(2,dtype=np.float32) s[0]=x[0] s[1]=x[1] for i in range(0,7): cf=True for j in range(0,2): if abs(obc[idx][i][j] - s[j]) > size/2.0: cf=False break if cf==True: return True return False def steerTo (start, end, idx): DISCRETIZATION_STEP=0.01 dists=np.zeros(2,dtype=np.float32) for i in range(0,2): dists[i] = end[i] - start[i] distTotal = 0.0 for i in range(0,2): distTotal =distTotal+ dists[i]*dists[i] distTotal = math.sqrt(distTotal) if distTotal>0: incrementTotal = distTotal/DISCRETIZATION_STEP for i in range(0,2): dists[i] =dists[i]/incrementTotal numSegments = int(math.floor(incrementTotal)) stateCurr = np.zeros(2,dtype=np.float32) for i in range(0,2): stateCurr[i] = start[i] for i in range(0,numSegments): if IsInCollision(stateCurr,idx): return 0 for j in range(0,2): stateCurr[j] = stateCurr[j]+dists[j] if IsInCollision(end,idx): return 0 return 1 # checks the feasibility of entire path including the path edges def feasibility_check(path,idx): for i in range(0,len(path)-1): ind=steerTo(path[i],path[i+1],idx) if ind==0: return 0 return 1 # checks the feasibility of path nodes only def collision_check(path,idx): for i in range(0,len(path)): if IsInCollision(path[i],idx): return 0 return 1 def to_var(x, volatile=False): if torch.cuda.is_available(): x = x.cuda() return Variable(x, volatile=volatile) def get_input(i,dataset,targets,seq,bs): bi=np.zeros((bs,18),dtype=np.float32) bt=np.zeros((bs,2),dtype=np.float32) k=0 for b in range(i,i+bs): bi[k]=dataset[seq[i]].flatten() bt[k]=targets[seq[i]].flatten() k=k+1 return torch.from_numpy(bi),torch.from_numpy(bt) def is_reaching_target(start1,start2): s1=np.zeros(2,dtype=np.float32) s1[0]=start1[0] s1[1]=start1[1] s2=np.zeros(2,dtype=np.float32) s2[0]=start2[0] s2[1]=start2[1] for i in range(0,2): if abs(s1[i]-s2[i]) > 1.0: return False return True #lazy vertex contraction def lvc(path,idx): for i in range(0,len(path)-1): for j in range(len(path)-1,i+1,-1): ind=0 ind=steerTo(path[i],path[j],idx) if ind==1: pc=[] for k in range(0,i+1): pc.append(path[k]) for k in range(j,len(path)): pc.append(path[k]) return lvc(pc,idx) return path def re_iterate_path2(p,g,idx,obs): step=0 path=[] path.append(p[0]) for i in range(1,len(p)-1): if not IsInCollision(p[i],idx): path.append(p[i]) path.append(g) new_path=[] for i in range(0,len(path)-1): target_reached=False st=path[i] gl=path[i+1] steer=steerTo(st, gl, idx) if steer==1: new_path.append(st) new_path.append(gl) else: itr=0 target_reached=False while (not target_reached) and itr<50 : new_path.append(st) itr=itr+1 ip=torch.cat((obs,st,gl)) ip=to_var(ip) st=mlp(ip) st=st.data.cpu() target_reached=is_reaching_target(st,gl) if target_reached==False: return 0 #new_path.append(g) return new_path def replan_path(p,g,idx,obs): step=0 path=[] path.append(p[0]) for i in range(1,len(p)-1): if not IsInCollision(p[i],idx): path.append(p[i]) path.append(g) new_path=[] for i in range(0,len(path)-1): target_reached=False st=path[i] gl=path[i+1] steer=steerTo(st, gl, idx) if steer==1: new_path.append(st) new_path.append(gl) else: itr=0 pA=[] pA.append(st) pB=[] pB.append(gl) target_reached=0 tree=0 while target_reached==0 and itr<50 : itr=itr+1 if tree==0: ip1=torch.cat((obs,st,gl)) ip1=to_var(ip1) st=mlp(ip1) st=st.data.cpu() pA.append(st) tree=1 else: ip2=torch.cat((obs,gl,st)) ip2=to_var(ip2) gl=mlp(ip2) gl=gl.data.cpu() pB.append(gl) tree=0 target_reached=steerTo(st, gl, idx) if target_reached==0: return 0 else: for p1 in range(0,len(pA)): new_path.append(pA[p1]) for p2 in range(len(pB)-1,-1,-1): new_path.append(pB[p2]) return new_path def main(args): # Create model directory if not os.path.exists(args.model_path): os.makedirs(args.model_path) tp=0 fp=0 tot=[] for i in range(0,1): et=[] for j in range(0,2): print ("step: i="+str(i)+" j="+str(j)) p1_ind=0 p2_ind=0 p_ind=0 if path_lengths[i][j]>0: start=np.zeros(2,dtype=np.float32) goal=np.zeros(2,dtype=np.float32) for l in range(0,2): start[l]=paths[i][j][0][l] for l in range(0,2): goal[l]=paths[i][j][path_lengths[i][j]-1][l] #start and goal for bidirectional generation ## starting point start1=torch.from_numpy(start) goal2=torch.from_numpy(start) ##goal point goal1=torch.from_numpy(goal) start2=torch.from_numpy(goal) ##obstacles obs=obstacles[i] obs=torch.from_numpy(obs) ##generated paths path1=[] path1.append(start1) path2=[] path2.append(start2) path=[] target_reached=0 step=0 path=[] # stores end2end path by concatenating path1 and path2 tree=0 tic = time.clock() while target_reached==0 and step<80 : step=step+1 if tree==0: inp1=torch.cat((obs,start1,start2)) inp1=to_var(inp1) start1=mlp(inp1) start1=start1.data.cpu() path1.append(start1) tree=1 else: inp2=torch.cat((obs,start2,start1)) inp2=to_var(inp2) start2=mlp(inp2) start2=start2.data.cpu() path2.append(start2) tree=0 target_reached=steerTo(start1,start2,i); tp=tp+1 if target_reached==1: for p1 in range(0,len(path1)): path.append(path1[p1]) for p2 in range(len(path2)-1,-1,-1): path.append(path2[p2]) path=lvc(path,i) indicator=feasibility_check(path,i) if indicator==1: toc = time.clock() t=toc-tic et.append(t) fp=fp+1 print ("path[0]:") for p in range(0,len(path)): print (path[p][0]) print ("path[1]:") for p in range(0,len(path)): print (path[p][1]) print ("Actual path[0]:") for p in range(0,path_lengths[i][j]): print (paths[i][j][p][0]) print ("Actual path[1]:") for p in range(0,path_lengths[i][j]): print (paths[i][j][p][1]) else: sp=0 indicator=0 while indicator==0 and sp<10 and path !=0: sp=sp+1 g=np.zeros(2,dtype=np.float32) g=torch.from_numpy(paths[i][j][path_lengths[i][j]-1]) path=replan_path(path,g,i,obs) #replanning at coarse level if path !=0: path=lvc(path,i) indicator=feasibility_check(path,i) if indicator==1: toc = time.clock() t=toc-tic et.append(t) fp=fp+1 if len(path)<20: print ("new_path[0]:") for p in range(0,len(path)): print (path[p][0]) print ("new_path[1]:") for p in range(0,len(path)): print (path[p][1]) print ("Actual path[0]:") for p in range(0,path_lengths[i][j]): print (paths[i][j][p][0]) print ("Actual path[1]:") for p in range(0,path_lengths[i][j]): print (paths[i][j][p][1]) else: print "path found, dont worry" tot.append(et) pickle.dump(tot, open("time_s2D_unseen_mlp.p", "wb" )) print ("total paths") print (tp) print ("feasible paths") print (fp) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--model_path', type=str, default='./models/',help='path for saving trained models') parser.add_argument('--no_env', type=int, default=50,help='directory for obstacle images') parser.add_argument('--no_motion_paths', type=int,default=2000,help='number of optimal paths in each environment') parser.add_argument('--log_step', type=int , default=10,help='step size for prining log info') parser.add_argument('--save_step', type=int , default=1000,help='step size for saving trained models') # Model parameters parser.add_argument('--input_size', type=int , default=68, help='dimension of the input vector') parser.add_argument('--output_size', type=int , default=2, help='dimension of the input vector') parser.add_argument('--hidden_size', type=int , default=256, help='dimension of lstm hidden states') parser.add_argument('--num_layers', type=int , default=4, help='number of layers in lstm') parser.add_argument('--num_epochs', type=int, default=100) parser.add_argument('--batch_size', type=int, default=28) parser.add_argument('--learning_rate', type=float, default=0.001) args = parser.parse_args() print(args) main(args) ================================================ FILE: MPNet/train.py ================================================ import argparse import torch import torch.nn as nn import numpy as np import os import pickle from data_loader import load_dataset from model import MLP from torch.autograd import Variable import math def to_var(x, volatile=False): if torch.cuda.is_available(): x = x.cuda() return Variable(x, volatile=volatile) def get_input(i,data,targets,bs): if i+bs .pyc foreach(py_file ${_lcmtypes_python_files}) set(full_py_fname ${_lcmtypes_python_dir}/${py_file}) add_custom_command(OUTPUT "${full_py_fname}c" COMMAND ${PYTHON_EXECUTABLE} -m py_compile ${full_py_fname} DEPENDS ${full_py_fname} VERBATIM) list(APPEND pyc_files "${full_py_fname}c") endforeach() add_custom_target(pyc_files ALL DEPENDS ${pyc_files}) # install python files execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(sys.version[:3])" OUTPUT_VARIABLE pyversion) install(DIRECTORY ${_lcmtypes_python_dir}/ DESTINATION lib/python${pyversion}/site-packages) lcmtypes_add_clean_dir(${_lcmtypes_python_dir}) endfunction() function(lcmtypes_install_types) lcmtypes_get_types(_lcmtypes) list(LENGTH _lcmtypes _num_lcmtypes) if(_num_lcmtypes EQUAL 0) return() endif() install(FILES ${_lcmtypes} DESTINATION share/lcmtypes) endfunction() macro(lcmtypes_build) find_package(PkgConfig REQUIRED) pkg_check_modules(LCM REQUIRED lcm) lcmtypes_build_c(${ARGV}) include_directories(${LCMTYPES_INCLUDE_DIRS}) lcmtypes_build_java(${ARGV}) lcmtypes_build_python(${ARGV}) lcmtypes_install_types() endmacro() ================================================ FILE: data_generation/lcmtypes/cmake/pods.cmake ================================================ # Macros to simplify compliance with the pods build policies. # # To enable the macros, add the following lines to CMakeLists.txt: # set(POD_NAME ) # include(cmake/pods.cmake) # # If POD_NAME is not set, then the CMake source directory is used as POD_NAME # # Next, any of the following macros can be used. See the individual macro # definitions in this file for individual documentation. # # C/C++ # pods_install_headers(...) # pods_install_libraries(...) # pods_install_executables(...) # pods_install_pkg_config_file(...) # # pods_use_pkg_config_packages(...) # # Python # pods_install_python_packages(...) # pods_install_python_script(...) # # Java # None yet # # ---- # File: pods.cmake # Distributed with pods version: 11.02.09 # pods_install_headers( ... DESTINATION ) # # Install a (list) of header files. # # Header files will all be installed to include/ # # example: # add_library(perception detector.h sensor.h) # pods_install_headers(detector.h sensor.h DESTINATION perception) # function(pods_install_headers) list(GET ARGV -2 checkword) if(NOT checkword STREQUAL DESTINATION) message(FATAL_ERROR "pods_install_headers missing DESTINATION parameter") endif() list(GET ARGV -1 dest_dir) list(REMOVE_AT ARGV -1) list(REMOVE_AT ARGV -1) #copy the headers to the INCLUDE_OUTPUT_PATH (${CMAKE_BINARY_DIR}/include) foreach(header ${ARGV}) get_filename_component(_header_name ${header} NAME) configure_file(${header} ${INCLUDE_OUTPUT_PATH}/${dest_dir}/${_header_name} COPYONLY) endforeach(header) #mark them to be installed install(FILES ${ARGV} DESTINATION include/${dest_dir}) endfunction(pods_install_headers) # pods_install_executables( ...) # # Install a (list) of executables to bin/ function(pods_install_executables) install(TARGETS ${ARGV} RUNTIME DESTINATION bin) endfunction(pods_install_executables) # pods_install_libraries( ...) # # Install a (list) of libraries to lib/ function(pods_install_libraries) install(TARGETS ${ARGV} LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) endfunction(pods_install_libraries) # pods_install_pkg_config_file( # [VERSION ] # [DESCRIPTION ] # [CFLAGS ...] # [LIBS ...] # [REQUIRES ...]) # # Create and install a pkg-config .pc file. # # example: # add_library(mylib mylib.c) # pods_install_pkg_config_file(mylib LIBS -lmylib REQUIRES glib-2.0) function(pods_install_pkg_config_file) list(GET ARGV 0 pc_name) # TODO error check set(pc_version 0.0.1) set(pc_description ${pc_name}) set(pc_requires "") set(pc_libs "") set(pc_cflags "") set(pc_fname "${PKG_CONFIG_OUTPUT_PATH}/${pc_name}.pc") set(modewords LIBS CFLAGS REQUIRES VERSION DESCRIPTION) set(curmode "") # parse function arguments and populate pkg-config parameters list(REMOVE_AT ARGV 0) foreach(word ${ARGV}) list(FIND modewords ${word} mode_index) if(${mode_index} GREATER -1) set(curmode ${word}) elseif(curmode STREQUAL LIBS) set(pc_libs "${pc_libs} ${word}") elseif(curmode STREQUAL CFLAGS) set(pc_cflags "${pc_cflags} ${word}") elseif(curmode STREQUAL REQUIRES) set(pc_requires "${pc_requires} ${word}") elseif(curmode STREQUAL VERSION) set(pc_version ${word}) set(curmode "") elseif(curmode STREQUAL DESCRIPTION) set(pc_description "${word}") set(curmode "") else(${mode_index} GREATER -1) message("WARNING incorrect use of pods_add_pkg_config (${word})") break() endif(${mode_index} GREATER -1) endforeach(word) # write the .pc file out file(WRITE ${pc_fname} "prefix=${CMAKE_INSTALL_PREFIX}\n" "exec_prefix=\${prefix}\n" "libdir=\${exec_prefix}/lib\n" "includedir=\${prefix}/include\n" "\n" "Name: ${pc_name}\n" "Description: ${pc_description}\n" "Requires: ${pc_requires}\n" "Version: ${pc_version}\n" "Libs: -L\${exec_prefix}/lib ${pc_libs}\n" "Cflags: ${pc_cflags}\n") # mark the .pc file for installation to the lib/pkgconfig directory install(FILES ${pc_fname} DESTINATION lib/pkgconfig) # find targets that this pkg-config file depends on string(REPLACE " " ";" split_lib ${pc_libs}) foreach(lib ${split_lib}) string(REGEX REPLACE "^-l" "" libname ${lib}) get_target_property(IS_TARGET ${libname} LOCATION) if (NOT IS_TARGET STREQUAL "IS_TARGET-NOTFOUND") set_property(GLOBAL APPEND PROPERTY "PODS_PKG_CONFIG_TARGETS-${pc_name}" ${libname}) endif() endforeach() endfunction(pods_install_pkg_config_file) # pods_install_python_script( ) # # Create and install a script that invokes the python interpreter with a # specified module. # # A script will be installed to bin/. The script simply # adds /lib/pythonX.Y/site-packages to the python path, and # then invokes `python -m `. # # example: # pods_install_python_script(run-pdb pdb) function(pods_install_python_script script_name py_module) find_package(PythonInterp REQUIRED) # which python version? execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(sys.version[:3])" OUTPUT_VARIABLE pyversion) # where do we install .py files to? set(python_install_dir ${CMAKE_INSTALL_PREFIX}/lib/python${pyversion}/site-packages) # write the script file file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${script_name} "#!/bin/sh\n" "export PYTHONPATH=${python_install_dir}:\${PYTHONPATH}\n" "exec ${PYTHON_EXECUTABLE} -m ${py_module} $*\n") # install it... install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${script_name} DESTINATION bin) endfunction() # pods_install_python_packages() # # Install python packages to lib/pythonX.Y/site-packages, where X.Y refers to # the current python version (e.g., 2.6) # # Recursively searches for .py files, byte-compiles them, and # installs them function(pods_install_python_packages py_src_dir) find_package(PythonInterp REQUIRED) # which python version? execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(sys.version[:3])" OUTPUT_VARIABLE pyversion) # where do we install .py files to? set(python_install_dir ${CMAKE_INSTALL_PREFIX}/lib/python${pyversion}/site-packages) if(ARGC GREATER 1) message(FATAL_ERROR "NYI") else() # get a list of all .py files file(GLOB_RECURSE py_files RELATIVE ${py_src_dir} ${py_src_dir}/*.py) # add rules for byte-compiling .py --> .pyc foreach(py_file ${py_files}) get_filename_component(py_dirname ${py_file} PATH) add_custom_command(OUTPUT "${py_src_dir}/${py_file}c" COMMAND ${PYTHON_EXECUTABLE} -m py_compile ${py_src_dir}/${py_file} DEPENDS ${py_src_dir}/${py_file}) list(APPEND pyc_files "${py_src_dir}/${py_file}c") # install python file and byte-compiled file install(FILES ${py_src_dir}/${py_file} ${py_src_dir}/${py_file}c DESTINATION "${python_install_dir}/${py_dirname}") # message("${py_src_dir}/${py_file} -> ${python_install_dir}/${py_dirname}") endforeach() string(REGEX REPLACE "[^a-zA-Z0-9]" "_" san_src_dir "${py_src_dir}") add_custom_target("pyc_${san_src_dir}" ALL DEPENDS ${pyc_files}) endif() endfunction() # pods_use_pkg_config_packages( ...) # # Convenience macro to get compiler and linker flags from pkg-config and apply them # to the specified target. # # Invokes `pkg-config --cflags-only-I ...` and adds the result to the # include directories. # # Additionally, invokes `pkg-config --libs ...` and adds the result to # the target's link flags (via target_link_libraries) # # example: # add_executable(myprogram main.c) # pods_use_pkg_config_packages(myprogram glib-2.0 opencv) macro(pods_use_pkg_config_packages target) if(${ARGC} LESS 2) message(WARNING "Useless invocation of pods_use_pkg_config_packages") return() endif() find_package(PkgConfig REQUIRED) execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --cflags-only-I ${ARGN} OUTPUT_VARIABLE _pods_pkg_include_flags) string(STRIP ${_pods_pkg_include_flags} _pods_pkg_include_flags) string(REPLACE "-I" "" _pods_pkg_include_flags "${_pods_pkg_include_flags}") separate_arguments(_pods_pkg_include_flags) # message("include: ${_pods_pkg_include_flags}") execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --libs ${ARGN} OUTPUT_VARIABLE _pods_pkg_ldflags) string(STRIP ${_pods_pkg_ldflags} _pods_pkg_ldflags) # message("ldflags: ${_pods_pkg_ldflags}") include_directories(${_pods_pkg_include_flags}) target_link_libraries(${target} ${_pods_pkg_ldflags}) # make the target depend on libraries being installed by this source build foreach(_pkg ${ARGN}) get_property(_has_dependencies GLOBAL PROPERTY "PODS_PKG_CONFIG_TARGETS-${_pkg}" SET) if(_has_dependencies) get_property(_dependencies GLOBAL PROPERTY "PODS_PKG_CONFIG_TARGETS-${_pkg}") add_dependencies(${target} ${_dependencies}) # message("Found dependencies for ${_pkg}: ${dependencies}") endif() unset(_has_dependencies) unset(_dependencies) endforeach() unset(_pods_pkg_include_flags) unset(_pods_pkg_ldflags) endmacro() # pods_config_search_paths() # # Setup include, linker, and pkg-config paths according to the pods core # policy. This macro is automatically invoked, there is no need to do so # manually. macro(pods_config_search_paths) if(NOT DEFINED __pods_setup) #set where files should be output locally set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) set(INCLUDE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/include) set(PKG_CONFIG_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/pkgconfig) #set where files should be installed to set(LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib) set(EXECUTABLE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/bin) set(INCLUDE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/include) set(PKG_CONFIG_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) # add build/lib/pkgconfig to the pkg-config search path set(ENV{PKG_CONFIG_PATH} ${PKG_CONFIG_INSTALL_PATH}:$ENV{PKG_CONFIG_PATH}) set(ENV{PKG_CONFIG_PATH} ${PKG_CONFIG_OUTPUT_PATH}:$ENV{PKG_CONFIG_PATH}) # add build/include to the compiler include path include_directories(BEFORE ${INCLUDE_OUTPUT_PATH}) include_directories(${INCLUDE_INSTALL_PATH}) # add build/lib to the link path link_directories(${LIBRARY_INSTALL_PATH}) link_directories(${LIBRARY_OUTPUT_PATH}) # abuse RPATH if(${CMAKE_INSTALL_RPATH}) set(CMAKE_INSTALL_RPATH ${LIBRARY_INSTALL_PATH}:${CMAKE_INSTALL_RPATH}) else(${CMAKE_INSTALL_RPATH}) set(CMAKE_INSTALL_RPATH ${LIBRARY_INSTALL_PATH}) endif(${CMAKE_INSTALL_RPATH}) # for osx, which uses "install name" path rather than rpath #set(CMAKE_INSTALL_NAME_DIR ${LIBRARY_OUTPUT_PATH}) set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_RPATH}) # hack to force cmake always create install and clean targets install(FILES DESTINATION) add_custom_target(tmp) set(__pods_setup true) endif(NOT DEFINED __pods_setup) endmacro(pods_config_search_paths) macro(enforce_out_of_source) if(CMAKE_BINARY_DIR STREQUAL PROJECT_SOURCE_DIR) message(FATAL_ERROR "\n Do not run cmake directly in the pod directory. use the supplied Makefile instead! You now need to remove CMakeCache.txt and the CMakeFiles directory. Then to build, simply type: $ make ") endif() endmacro(enforce_out_of_source) #set the variable POD_NAME to the directory path, and set the cmake PROJECT_NAME if(NOT POD_NAME) get_filename_component(POD_NAME ${CMAKE_SOURCE_DIR} NAME) message(STATUS "POD_NAME is not set... Defaulting to directory name: ${POD_NAME}") endif(NOT POD_NAME) project(${POD_NAME}) #make sure we're running an out-of-source build enforce_out_of_source() #call the function to setup paths pods_config_search_paths() ================================================ FILE: data_generation/lcmtypes/lcmtypes/c/lcmtypes/lcmtypes.h ================================================ #ifndef __lcmtypes_lcmtypes_h__ #define __lcmtypes_lcmtypes_h__ #include "lcmtypes_trajectory_t.h" #include "lcmtypes_state_t.h" #include "lcmtypes_environment_t.h" #include "lcmtypes_vertex_t.h" #include "lcmtypes_graph_t.h" #include "lcmtypes_edge_t.h" #include "lcmtypes_region_3d_t.h" #endif ================================================ FILE: data_generation/lcmtypes/lcmtypes/c/lcmtypes/lcmtypes_edge_t.c ================================================ // THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY // BY HAND!! // // Generated by lcm-gen #include #include "lcmtypes/lcmtypes_edge_t.h" static int __lcmtypes_edge_t_hash_computed; static uint64_t __lcmtypes_edge_t_hash; uint64_t __lcmtypes_edge_t_hash_recursive(const __lcm_hash_ptr *p) { const __lcm_hash_ptr *fp; for (fp = p; fp != NULL; fp = fp->parent) if (fp->v == __lcmtypes_edge_t_get_hash) return 0; __lcm_hash_ptr cp; cp.parent = p; cp.v = (void*)__lcmtypes_edge_t_get_hash; (void) cp; uint64_t hash = (uint64_t)0x1fae492d71eedf94LL + __lcmtypes_vertex_t_hash_recursive(&cp) + __lcmtypes_vertex_t_hash_recursive(&cp) + __lcmtypes_trajectory_t_hash_recursive(&cp) ; return (hash<<1) + ((hash>>63)&1); } int64_t __lcmtypes_edge_t_get_hash(void) { if (!__lcmtypes_edge_t_hash_computed) { __lcmtypes_edge_t_hash = (int64_t)__lcmtypes_edge_t_hash_recursive(NULL); __lcmtypes_edge_t_hash_computed = 1; } return __lcmtypes_edge_t_hash; } int __lcmtypes_edge_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_edge_t *p, int elements) { int pos = 0, element; int thislen; for (element = 0; element < elements; element++) { thislen = __lcmtypes_vertex_t_encode_array(buf, offset + pos, maxlen - pos, &(p[element].vertex_src), 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_vertex_t_encode_array(buf, offset + pos, maxlen - pos, &(p[element].vertex_dst), 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_trajectory_t_encode_array(buf, offset + pos, maxlen - pos, &(p[element].trajectory), 1); if (thislen < 0) return thislen; else pos += thislen; } return pos; } int lcmtypes_edge_t_encode(void *buf, int offset, int maxlen, const lcmtypes_edge_t *p) { int pos = 0, thislen; int64_t hash = __lcmtypes_edge_t_get_hash(); thislen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, &hash, 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_edge_t_encode_array(buf, offset + pos, maxlen - pos, p, 1); if (thislen < 0) return thislen; else pos += thislen; return pos; } int __lcmtypes_edge_t_encoded_array_size(const lcmtypes_edge_t *p, int elements) { int size = 0, element; for (element = 0; element < elements; element++) { size += __lcmtypes_vertex_t_encoded_array_size(&(p[element].vertex_src), 1); size += __lcmtypes_vertex_t_encoded_array_size(&(p[element].vertex_dst), 1); size += __lcmtypes_trajectory_t_encoded_array_size(&(p[element].trajectory), 1); } return size; } int lcmtypes_edge_t_encoded_size(const lcmtypes_edge_t *p) { return 8 + __lcmtypes_edge_t_encoded_array_size(p, 1); } int __lcmtypes_edge_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_edge_t *p, int elements) { int pos = 0, thislen, element; for (element = 0; element < elements; element++) { thislen = __lcmtypes_vertex_t_decode_array(buf, offset + pos, maxlen - pos, &(p[element].vertex_src), 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_vertex_t_decode_array(buf, offset + pos, maxlen - pos, &(p[element].vertex_dst), 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_trajectory_t_decode_array(buf, offset + pos, maxlen - pos, &(p[element].trajectory), 1); if (thislen < 0) return thislen; else pos += thislen; } return pos; } int __lcmtypes_edge_t_decode_array_cleanup(lcmtypes_edge_t *p, int elements) { int element; for (element = 0; element < elements; element++) { __lcmtypes_vertex_t_decode_array_cleanup(&(p[element].vertex_src), 1); __lcmtypes_vertex_t_decode_array_cleanup(&(p[element].vertex_dst), 1); __lcmtypes_trajectory_t_decode_array_cleanup(&(p[element].trajectory), 1); } return 0; } int lcmtypes_edge_t_decode(const void *buf, int offset, int maxlen, lcmtypes_edge_t *p) { int pos = 0, thislen; int64_t hash = __lcmtypes_edge_t_get_hash(); int64_t this_hash; thislen = __int64_t_decode_array(buf, offset + pos, maxlen - pos, &this_hash, 1); if (thislen < 0) return thislen; else pos += thislen; if (this_hash != hash) return -1; thislen = __lcmtypes_edge_t_decode_array(buf, offset + pos, maxlen - pos, p, 1); if (thislen < 0) return thislen; else pos += thislen; return pos; } int lcmtypes_edge_t_decode_cleanup(lcmtypes_edge_t *p) { return __lcmtypes_edge_t_decode_array_cleanup(p, 1); } int __lcmtypes_edge_t_clone_array(const lcmtypes_edge_t *p, lcmtypes_edge_t *q, int elements) { int element; for (element = 0; element < elements; element++) { __lcmtypes_vertex_t_clone_array(&(p[element].vertex_src), &(q[element].vertex_src), 1); __lcmtypes_vertex_t_clone_array(&(p[element].vertex_dst), &(q[element].vertex_dst), 1); __lcmtypes_trajectory_t_clone_array(&(p[element].trajectory), &(q[element].trajectory), 1); } return 0; } lcmtypes_edge_t *lcmtypes_edge_t_copy(const lcmtypes_edge_t *p) { lcmtypes_edge_t *q = (lcmtypes_edge_t*) malloc(sizeof(lcmtypes_edge_t)); __lcmtypes_edge_t_clone_array(p, q, 1); return q; } void lcmtypes_edge_t_destroy(lcmtypes_edge_t *p) { __lcmtypes_edge_t_decode_array_cleanup(p, 1); free(p); } int lcmtypes_edge_t_publish(lcm_t *lc, const char *channel, const lcmtypes_edge_t *p) { int max_data_size = lcmtypes_edge_t_encoded_size (p); uint8_t *buf = (uint8_t*) malloc (max_data_size); if (!buf) return -1; int data_size = lcmtypes_edge_t_encode (buf, 0, max_data_size, p); if (data_size < 0) { free (buf); return data_size; } int status = lcm_publish (lc, channel, buf, data_size); free (buf); return status; } struct _lcmtypes_edge_t_subscription_t { lcmtypes_edge_t_handler_t user_handler; void *userdata; lcm_subscription_t *lc_h; }; static void lcmtypes_edge_t_handler_stub (const lcm_recv_buf_t *rbuf, const char *channel, void *userdata) { int status; lcmtypes_edge_t p; memset(&p, 0, sizeof(lcmtypes_edge_t)); status = lcmtypes_edge_t_decode (rbuf->data, 0, rbuf->data_size, &p); if (status < 0) { fprintf (stderr, "error %d decoding lcmtypes_edge_t!!!\n", status); return; } lcmtypes_edge_t_subscription_t *h = (lcmtypes_edge_t_subscription_t*) userdata; h->user_handler (rbuf, channel, &p, h->userdata); lcmtypes_edge_t_decode_cleanup (&p); } lcmtypes_edge_t_subscription_t* lcmtypes_edge_t_subscribe (lcm_t *lcm, const char *channel, lcmtypes_edge_t_handler_t f, void *userdata) { lcmtypes_edge_t_subscription_t *n = (lcmtypes_edge_t_subscription_t*) malloc(sizeof(lcmtypes_edge_t_subscription_t)); n->user_handler = f; n->userdata = userdata; n->lc_h = lcm_subscribe (lcm, channel, lcmtypes_edge_t_handler_stub, n); if (n->lc_h == NULL) { fprintf (stderr,"couldn't reg lcmtypes_edge_t LCM handler!\n"); free (n); return NULL; } return n; } int lcmtypes_edge_t_subscription_set_queue_capacity (lcmtypes_edge_t_subscription_t* subs, int num_messages) { return lcm_subscription_set_queue_capacity (subs->lc_h, num_messages); } int lcmtypes_edge_t_unsubscribe(lcm_t *lcm, lcmtypes_edge_t_subscription_t* hid) { int status = lcm_unsubscribe (lcm, hid->lc_h); if (0 != status) { fprintf(stderr, "couldn't unsubscribe lcmtypes_edge_t_handler %p!\n", hid); return -1; } free (hid); return 0; } ================================================ FILE: data_generation/lcmtypes/lcmtypes/c/lcmtypes/lcmtypes_edge_t.h ================================================ // THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY // BY HAND!! // // Generated by lcm-gen #include #include #include #include #ifndef _lcmtypes_edge_t_h #define _lcmtypes_edge_t_h #ifdef __cplusplus extern "C" { #endif #include "lcmtypes/lcmtypes_vertex_t.h" #include "lcmtypes/lcmtypes_vertex_t.h" #include "lcmtypes/lcmtypes_trajectory_t.h" typedef struct _lcmtypes_edge_t lcmtypes_edge_t; struct _lcmtypes_edge_t { lcmtypes_vertex_t vertex_src; lcmtypes_vertex_t vertex_dst; lcmtypes_trajectory_t trajectory; }; /** * Create a deep copy of a lcmtypes_edge_t. * When no longer needed, destroy it with lcmtypes_edge_t_destroy() */ lcmtypes_edge_t* lcmtypes_edge_t_copy(const lcmtypes_edge_t* to_copy); /** * Destroy an instance of lcmtypes_edge_t created by lcmtypes_edge_t_copy() */ void lcmtypes_edge_t_destroy(lcmtypes_edge_t* to_destroy); /** * Identifies a single subscription. This is an opaque data type. */ typedef struct _lcmtypes_edge_t_subscription_t lcmtypes_edge_t_subscription_t; /** * Prototype for a callback function invoked when a message of type * lcmtypes_edge_t is received. */ typedef void(*lcmtypes_edge_t_handler_t)(const lcm_recv_buf_t *rbuf, const char *channel, const lcmtypes_edge_t *msg, void *userdata); /** * Publish a message of type lcmtypes_edge_t using LCM. * * @param lcm The LCM instance to publish with. * @param channel The channel to publish on. * @param msg The message to publish. * @return 0 on success, <0 on error. Success means LCM has transferred * responsibility of the message data to the OS. */ int lcmtypes_edge_t_publish(lcm_t *lcm, const char *channel, const lcmtypes_edge_t *msg); /** * Subscribe to messages of type lcmtypes_edge_t using LCM. * * @param lcm The LCM instance to subscribe with. * @param channel The channel to subscribe to. * @param handler The callback function invoked by LCM when a message is received. * This function is invoked by LCM during calls to lcm_handle() and * lcm_handle_timeout(). * @param userdata An opaque pointer passed to @p handler when it is invoked. * @return 0 on success, <0 if an error occured */ lcmtypes_edge_t_subscription_t* lcmtypes_edge_t_subscribe(lcm_t *lcm, const char *channel, lcmtypes_edge_t_handler_t handler, void *userdata); /** * Removes and destroys a subscription created by lcmtypes_edge_t_subscribe() */ int lcmtypes_edge_t_unsubscribe(lcm_t *lcm, lcmtypes_edge_t_subscription_t* hid); /** * Sets the queue capacity for a subscription. * Some LCM providers (e.g., the default multicast provider) are implemented * using a background receive thread that constantly revceives messages from * the network. As these messages are received, they are buffered on * per-subscription queues until dispatched by lcm_handle(). This function * how many messages are queued before dropping messages. * * @param subs the subscription to modify. * @param num_messages The maximum number of messages to queue * on the subscription. * @return 0 on success, <0 if an error occured */ int lcmtypes_edge_t_subscription_set_queue_capacity(lcmtypes_edge_t_subscription_t* subs, int num_messages); /** * Encode a message of type lcmtypes_edge_t into binary form. * * @param buf The output buffer. * @param offset Encoding starts at this byte offset into @p buf. * @param maxlen Maximum number of bytes to write. This should generally * be equal to lcmtypes_edge_t_encoded_size(). * @param msg The message to encode. * @return The number of bytes encoded, or <0 if an error occured. */ int lcmtypes_edge_t_encode(void *buf, int offset, int maxlen, const lcmtypes_edge_t *p); /** * Decode a message of type lcmtypes_edge_t from binary form. * When decoding messages containing strings or variable-length arrays, this * function may allocate memory. When finished with the decoded message, * release allocated resources with lcmtypes_edge_t_decode_cleanup(). * * @param buf The buffer containing the encoded message * @param offset The byte offset into @p buf where the encoded message starts. * @param maxlen The maximum number of bytes to read while decoding. * @param msg Output parameter where the decoded message is stored * @return The number of bytes decoded, or <0 if an error occured. */ int lcmtypes_edge_t_decode(const void *buf, int offset, int maxlen, lcmtypes_edge_t *msg); /** * Release resources allocated by lcmtypes_edge_t_decode() * @return 0 */ int lcmtypes_edge_t_decode_cleanup(lcmtypes_edge_t *p); /** * Check how many bytes are required to encode a message of type lcmtypes_edge_t */ int lcmtypes_edge_t_encoded_size(const lcmtypes_edge_t *p); // LCM support functions. Users should not call these int64_t __lcmtypes_edge_t_get_hash(void); uint64_t __lcmtypes_edge_t_hash_recursive(const __lcm_hash_ptr *p); int __lcmtypes_edge_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_edge_t *p, int elements); int __lcmtypes_edge_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_edge_t *p, int elements); int __lcmtypes_edge_t_decode_array_cleanup(lcmtypes_edge_t *p, int elements); int __lcmtypes_edge_t_encoded_array_size(const lcmtypes_edge_t *p, int elements); int __lcmtypes_edge_t_clone_array(const lcmtypes_edge_t *p, lcmtypes_edge_t *q, int elements); #ifdef __cplusplus } #endif #endif ================================================ FILE: data_generation/lcmtypes/lcmtypes/c/lcmtypes/lcmtypes_environment_t.c ================================================ // THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY // BY HAND!! // // Generated by lcm-gen #include #include "lcmtypes/lcmtypes_environment_t.h" static int __lcmtypes_environment_t_hash_computed; static uint64_t __lcmtypes_environment_t_hash; uint64_t __lcmtypes_environment_t_hash_recursive(const __lcm_hash_ptr *p) { const __lcm_hash_ptr *fp; for (fp = p; fp != NULL; fp = fp->parent) if (fp->v == __lcmtypes_environment_t_get_hash) return 0; __lcm_hash_ptr cp; cp.parent = p; cp.v = (void*)__lcmtypes_environment_t_get_hash; (void) cp; uint64_t hash = (uint64_t)0x8caabc2a2ba0f9c7LL + __lcmtypes_region_3d_t_hash_recursive(&cp) + __lcmtypes_region_3d_t_hash_recursive(&cp) + __int32_t_hash_recursive(&cp) + __lcmtypes_region_3d_t_hash_recursive(&cp) ; return (hash<<1) + ((hash>>63)&1); } int64_t __lcmtypes_environment_t_get_hash(void) { if (!__lcmtypes_environment_t_hash_computed) { __lcmtypes_environment_t_hash = (int64_t)__lcmtypes_environment_t_hash_recursive(NULL); __lcmtypes_environment_t_hash_computed = 1; } return __lcmtypes_environment_t_hash; } int __lcmtypes_environment_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_environment_t *p, int elements) { int pos = 0, element; int thislen; for (element = 0; element < elements; element++) { thislen = __lcmtypes_region_3d_t_encode_array(buf, offset + pos, maxlen - pos, &(p[element].operating), 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_region_3d_t_encode_array(buf, offset + pos, maxlen - pos, &(p[element].goal), 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __int32_t_encode_array(buf, offset + pos, maxlen - pos, &(p[element].num_obstacles), 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_region_3d_t_encode_array(buf, offset + pos, maxlen - pos, p[element].obstacles, p[element].num_obstacles); if (thislen < 0) return thislen; else pos += thislen; } return pos; } int lcmtypes_environment_t_encode(void *buf, int offset, int maxlen, const lcmtypes_environment_t *p) { int pos = 0, thislen; int64_t hash = __lcmtypes_environment_t_get_hash(); thislen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, &hash, 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_environment_t_encode_array(buf, offset + pos, maxlen - pos, p, 1); if (thislen < 0) return thislen; else pos += thislen; return pos; } int __lcmtypes_environment_t_encoded_array_size(const lcmtypes_environment_t *p, int elements) { int size = 0, element; for (element = 0; element < elements; element++) { size += __lcmtypes_region_3d_t_encoded_array_size(&(p[element].operating), 1); size += __lcmtypes_region_3d_t_encoded_array_size(&(p[element].goal), 1); size += __int32_t_encoded_array_size(&(p[element].num_obstacles), 1); size += __lcmtypes_region_3d_t_encoded_array_size(p[element].obstacles, p[element].num_obstacles); } return size; } int lcmtypes_environment_t_encoded_size(const lcmtypes_environment_t *p) { return 8 + __lcmtypes_environment_t_encoded_array_size(p, 1); } int __lcmtypes_environment_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_environment_t *p, int elements) { int pos = 0, thislen, element; for (element = 0; element < elements; element++) { thislen = __lcmtypes_region_3d_t_decode_array(buf, offset + pos, maxlen - pos, &(p[element].operating), 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_region_3d_t_decode_array(buf, offset + pos, maxlen - pos, &(p[element].goal), 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __int32_t_decode_array(buf, offset + pos, maxlen - pos, &(p[element].num_obstacles), 1); if (thislen < 0) return thislen; else pos += thislen; p[element].obstacles = (lcmtypes_region_3d_t*) lcm_malloc(sizeof(lcmtypes_region_3d_t) * p[element].num_obstacles); thislen = __lcmtypes_region_3d_t_decode_array(buf, offset + pos, maxlen - pos, p[element].obstacles, p[element].num_obstacles); if (thislen < 0) return thislen; else pos += thislen; } return pos; } int __lcmtypes_environment_t_decode_array_cleanup(lcmtypes_environment_t *p, int elements) { int element; for (element = 0; element < elements; element++) { __lcmtypes_region_3d_t_decode_array_cleanup(&(p[element].operating), 1); __lcmtypes_region_3d_t_decode_array_cleanup(&(p[element].goal), 1); __int32_t_decode_array_cleanup(&(p[element].num_obstacles), 1); __lcmtypes_region_3d_t_decode_array_cleanup(p[element].obstacles, p[element].num_obstacles); if (p[element].obstacles) free(p[element].obstacles); } return 0; } int lcmtypes_environment_t_decode(const void *buf, int offset, int maxlen, lcmtypes_environment_t *p) { int pos = 0, thislen; int64_t hash = __lcmtypes_environment_t_get_hash(); int64_t this_hash; thislen = __int64_t_decode_array(buf, offset + pos, maxlen - pos, &this_hash, 1); if (thislen < 0) return thislen; else pos += thislen; if (this_hash != hash) return -1; thislen = __lcmtypes_environment_t_decode_array(buf, offset + pos, maxlen - pos, p, 1); if (thislen < 0) return thislen; else pos += thislen; return pos; } int lcmtypes_environment_t_decode_cleanup(lcmtypes_environment_t *p) { return __lcmtypes_environment_t_decode_array_cleanup(p, 1); } int __lcmtypes_environment_t_clone_array(const lcmtypes_environment_t *p, lcmtypes_environment_t *q, int elements) { int element; for (element = 0; element < elements; element++) { __lcmtypes_region_3d_t_clone_array(&(p[element].operating), &(q[element].operating), 1); __lcmtypes_region_3d_t_clone_array(&(p[element].goal), &(q[element].goal), 1); __int32_t_clone_array(&(p[element].num_obstacles), &(q[element].num_obstacles), 1); q[element].obstacles = (lcmtypes_region_3d_t*) lcm_malloc(sizeof(lcmtypes_region_3d_t) * q[element].num_obstacles); __lcmtypes_region_3d_t_clone_array(p[element].obstacles, q[element].obstacles, p[element].num_obstacles); } return 0; } lcmtypes_environment_t *lcmtypes_environment_t_copy(const lcmtypes_environment_t *p) { lcmtypes_environment_t *q = (lcmtypes_environment_t*) malloc(sizeof(lcmtypes_environment_t)); __lcmtypes_environment_t_clone_array(p, q, 1); return q; } void lcmtypes_environment_t_destroy(lcmtypes_environment_t *p) { __lcmtypes_environment_t_decode_array_cleanup(p, 1); free(p); } int lcmtypes_environment_t_publish(lcm_t *lc, const char *channel, const lcmtypes_environment_t *p) { int max_data_size = lcmtypes_environment_t_encoded_size (p); uint8_t *buf = (uint8_t*) malloc (max_data_size); if (!buf) return -1; int data_size = lcmtypes_environment_t_encode (buf, 0, max_data_size, p); if (data_size < 0) { free (buf); return data_size; } int status = lcm_publish (lc, channel, buf, data_size); free (buf); return status; } struct _lcmtypes_environment_t_subscription_t { lcmtypes_environment_t_handler_t user_handler; void *userdata; lcm_subscription_t *lc_h; }; static void lcmtypes_environment_t_handler_stub (const lcm_recv_buf_t *rbuf, const char *channel, void *userdata) { int status; lcmtypes_environment_t p; memset(&p, 0, sizeof(lcmtypes_environment_t)); status = lcmtypes_environment_t_decode (rbuf->data, 0, rbuf->data_size, &p); if (status < 0) { fprintf (stderr, "error %d decoding lcmtypes_environment_t!!!\n", status); return; } lcmtypes_environment_t_subscription_t *h = (lcmtypes_environment_t_subscription_t*) userdata; h->user_handler (rbuf, channel, &p, h->userdata); lcmtypes_environment_t_decode_cleanup (&p); } lcmtypes_environment_t_subscription_t* lcmtypes_environment_t_subscribe (lcm_t *lcm, const char *channel, lcmtypes_environment_t_handler_t f, void *userdata) { lcmtypes_environment_t_subscription_t *n = (lcmtypes_environment_t_subscription_t*) malloc(sizeof(lcmtypes_environment_t_subscription_t)); n->user_handler = f; n->userdata = userdata; n->lc_h = lcm_subscribe (lcm, channel, lcmtypes_environment_t_handler_stub, n); if (n->lc_h == NULL) { fprintf (stderr,"couldn't reg lcmtypes_environment_t LCM handler!\n"); free (n); return NULL; } return n; } int lcmtypes_environment_t_subscription_set_queue_capacity (lcmtypes_environment_t_subscription_t* subs, int num_messages) { return lcm_subscription_set_queue_capacity (subs->lc_h, num_messages); } int lcmtypes_environment_t_unsubscribe(lcm_t *lcm, lcmtypes_environment_t_subscription_t* hid) { int status = lcm_unsubscribe (lcm, hid->lc_h); if (0 != status) { fprintf(stderr, "couldn't unsubscribe lcmtypes_environment_t_handler %p!\n", hid); return -1; } free (hid); return 0; } ================================================ FILE: data_generation/lcmtypes/lcmtypes/c/lcmtypes/lcmtypes_environment_t.h ================================================ // THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY // BY HAND!! // // Generated by lcm-gen #include #include #include #include #ifndef _lcmtypes_environment_t_h #define _lcmtypes_environment_t_h #ifdef __cplusplus extern "C" { #endif #include "lcmtypes/lcmtypes_region_3d_t.h" #include "lcmtypes/lcmtypes_region_3d_t.h" #include "lcmtypes/lcmtypes_region_3d_t.h" typedef struct _lcmtypes_environment_t lcmtypes_environment_t; struct _lcmtypes_environment_t { lcmtypes_region_3d_t operating; lcmtypes_region_3d_t goal; int32_t num_obstacles; lcmtypes_region_3d_t *obstacles; }; /** * Create a deep copy of a lcmtypes_environment_t. * When no longer needed, destroy it with lcmtypes_environment_t_destroy() */ lcmtypes_environment_t* lcmtypes_environment_t_copy(const lcmtypes_environment_t* to_copy); /** * Destroy an instance of lcmtypes_environment_t created by lcmtypes_environment_t_copy() */ void lcmtypes_environment_t_destroy(lcmtypes_environment_t* to_destroy); /** * Identifies a single subscription. This is an opaque data type. */ typedef struct _lcmtypes_environment_t_subscription_t lcmtypes_environment_t_subscription_t; /** * Prototype for a callback function invoked when a message of type * lcmtypes_environment_t is received. */ typedef void(*lcmtypes_environment_t_handler_t)(const lcm_recv_buf_t *rbuf, const char *channel, const lcmtypes_environment_t *msg, void *userdata); /** * Publish a message of type lcmtypes_environment_t using LCM. * * @param lcm The LCM instance to publish with. * @param channel The channel to publish on. * @param msg The message to publish. * @return 0 on success, <0 on error. Success means LCM has transferred * responsibility of the message data to the OS. */ int lcmtypes_environment_t_publish(lcm_t *lcm, const char *channel, const lcmtypes_environment_t *msg); /** * Subscribe to messages of type lcmtypes_environment_t using LCM. * * @param lcm The LCM instance to subscribe with. * @param channel The channel to subscribe to. * @param handler The callback function invoked by LCM when a message is received. * This function is invoked by LCM during calls to lcm_handle() and * lcm_handle_timeout(). * @param userdata An opaque pointer passed to @p handler when it is invoked. * @return 0 on success, <0 if an error occured */ lcmtypes_environment_t_subscription_t* lcmtypes_environment_t_subscribe(lcm_t *lcm, const char *channel, lcmtypes_environment_t_handler_t handler, void *userdata); /** * Removes and destroys a subscription created by lcmtypes_environment_t_subscribe() */ int lcmtypes_environment_t_unsubscribe(lcm_t *lcm, lcmtypes_environment_t_subscription_t* hid); /** * Sets the queue capacity for a subscription. * Some LCM providers (e.g., the default multicast provider) are implemented * using a background receive thread that constantly revceives messages from * the network. As these messages are received, they are buffered on * per-subscription queues until dispatched by lcm_handle(). This function * how many messages are queued before dropping messages. * * @param subs the subscription to modify. * @param num_messages The maximum number of messages to queue * on the subscription. * @return 0 on success, <0 if an error occured */ int lcmtypes_environment_t_subscription_set_queue_capacity(lcmtypes_environment_t_subscription_t* subs, int num_messages); /** * Encode a message of type lcmtypes_environment_t into binary form. * * @param buf The output buffer. * @param offset Encoding starts at this byte offset into @p buf. * @param maxlen Maximum number of bytes to write. This should generally * be equal to lcmtypes_environment_t_encoded_size(). * @param msg The message to encode. * @return The number of bytes encoded, or <0 if an error occured. */ int lcmtypes_environment_t_encode(void *buf, int offset, int maxlen, const lcmtypes_environment_t *p); /** * Decode a message of type lcmtypes_environment_t from binary form. * When decoding messages containing strings or variable-length arrays, this * function may allocate memory. When finished with the decoded message, * release allocated resources with lcmtypes_environment_t_decode_cleanup(). * * @param buf The buffer containing the encoded message * @param offset The byte offset into @p buf where the encoded message starts. * @param maxlen The maximum number of bytes to read while decoding. * @param msg Output parameter where the decoded message is stored * @return The number of bytes decoded, or <0 if an error occured. */ int lcmtypes_environment_t_decode(const void *buf, int offset, int maxlen, lcmtypes_environment_t *msg); /** * Release resources allocated by lcmtypes_environment_t_decode() * @return 0 */ int lcmtypes_environment_t_decode_cleanup(lcmtypes_environment_t *p); /** * Check how many bytes are required to encode a message of type lcmtypes_environment_t */ int lcmtypes_environment_t_encoded_size(const lcmtypes_environment_t *p); // LCM support functions. Users should not call these int64_t __lcmtypes_environment_t_get_hash(void); uint64_t __lcmtypes_environment_t_hash_recursive(const __lcm_hash_ptr *p); int __lcmtypes_environment_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_environment_t *p, int elements); int __lcmtypes_environment_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_environment_t *p, int elements); int __lcmtypes_environment_t_decode_array_cleanup(lcmtypes_environment_t *p, int elements); int __lcmtypes_environment_t_encoded_array_size(const lcmtypes_environment_t *p, int elements); int __lcmtypes_environment_t_clone_array(const lcmtypes_environment_t *p, lcmtypes_environment_t *q, int elements); #ifdef __cplusplus } #endif #endif ================================================ FILE: data_generation/lcmtypes/lcmtypes/c/lcmtypes/lcmtypes_graph_t.c ================================================ // THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY // BY HAND!! // // Generated by lcm-gen #include #include "lcmtypes/lcmtypes_graph_t.h" static int __lcmtypes_graph_t_hash_computed; static uint64_t __lcmtypes_graph_t_hash; uint64_t __lcmtypes_graph_t_hash_recursive(const __lcm_hash_ptr *p) { const __lcm_hash_ptr *fp; for (fp = p; fp != NULL; fp = fp->parent) if (fp->v == __lcmtypes_graph_t_get_hash) return 0; __lcm_hash_ptr cp; cp.parent = p; cp.v = (void*)__lcmtypes_graph_t_get_hash; (void) cp; uint64_t hash = (uint64_t)0x49189ad7b639b453LL + __int32_t_hash_recursive(&cp) + __lcmtypes_vertex_t_hash_recursive(&cp) + __int32_t_hash_recursive(&cp) + __lcmtypes_edge_t_hash_recursive(&cp) ; return (hash<<1) + ((hash>>63)&1); } int64_t __lcmtypes_graph_t_get_hash(void) { if (!__lcmtypes_graph_t_hash_computed) { __lcmtypes_graph_t_hash = (int64_t)__lcmtypes_graph_t_hash_recursive(NULL); __lcmtypes_graph_t_hash_computed = 1; } return __lcmtypes_graph_t_hash; } int __lcmtypes_graph_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_graph_t *p, int elements) { int pos = 0, element; int thislen; for (element = 0; element < elements; element++) { thislen = __int32_t_encode_array(buf, offset + pos, maxlen - pos, &(p[element].num_vertices), 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_vertex_t_encode_array(buf, offset + pos, maxlen - pos, p[element].vertices, p[element].num_vertices); if (thislen < 0) return thislen; else pos += thislen; thislen = __int32_t_encode_array(buf, offset + pos, maxlen - pos, &(p[element].num_edges), 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_edge_t_encode_array(buf, offset + pos, maxlen - pos, p[element].edges, p[element].num_edges); if (thislen < 0) return thislen; else pos += thislen; } return pos; } int lcmtypes_graph_t_encode(void *buf, int offset, int maxlen, const lcmtypes_graph_t *p) { int pos = 0, thislen; int64_t hash = __lcmtypes_graph_t_get_hash(); thislen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, &hash, 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_graph_t_encode_array(buf, offset + pos, maxlen - pos, p, 1); if (thislen < 0) return thislen; else pos += thislen; return pos; } int __lcmtypes_graph_t_encoded_array_size(const lcmtypes_graph_t *p, int elements) { int size = 0, element; for (element = 0; element < elements; element++) { size += __int32_t_encoded_array_size(&(p[element].num_vertices), 1); size += __lcmtypes_vertex_t_encoded_array_size(p[element].vertices, p[element].num_vertices); size += __int32_t_encoded_array_size(&(p[element].num_edges), 1); size += __lcmtypes_edge_t_encoded_array_size(p[element].edges, p[element].num_edges); } return size; } int lcmtypes_graph_t_encoded_size(const lcmtypes_graph_t *p) { return 8 + __lcmtypes_graph_t_encoded_array_size(p, 1); } int __lcmtypes_graph_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_graph_t *p, int elements) { int pos = 0, thislen, element; for (element = 0; element < elements; element++) { thislen = __int32_t_decode_array(buf, offset + pos, maxlen - pos, &(p[element].num_vertices), 1); if (thislen < 0) return thislen; else pos += thislen; p[element].vertices = (lcmtypes_vertex_t*) lcm_malloc(sizeof(lcmtypes_vertex_t) * p[element].num_vertices); thislen = __lcmtypes_vertex_t_decode_array(buf, offset + pos, maxlen - pos, p[element].vertices, p[element].num_vertices); if (thislen < 0) return thislen; else pos += thislen; thislen = __int32_t_decode_array(buf, offset + pos, maxlen - pos, &(p[element].num_edges), 1); if (thislen < 0) return thislen; else pos += thislen; p[element].edges = (lcmtypes_edge_t*) lcm_malloc(sizeof(lcmtypes_edge_t) * p[element].num_edges); thislen = __lcmtypes_edge_t_decode_array(buf, offset + pos, maxlen - pos, p[element].edges, p[element].num_edges); if (thislen < 0) return thislen; else pos += thislen; } return pos; } int __lcmtypes_graph_t_decode_array_cleanup(lcmtypes_graph_t *p, int elements) { int element; for (element = 0; element < elements; element++) { __int32_t_decode_array_cleanup(&(p[element].num_vertices), 1); __lcmtypes_vertex_t_decode_array_cleanup(p[element].vertices, p[element].num_vertices); if (p[element].vertices) free(p[element].vertices); __int32_t_decode_array_cleanup(&(p[element].num_edges), 1); __lcmtypes_edge_t_decode_array_cleanup(p[element].edges, p[element].num_edges); if (p[element].edges) free(p[element].edges); } return 0; } int lcmtypes_graph_t_decode(const void *buf, int offset, int maxlen, lcmtypes_graph_t *p) { int pos = 0, thislen; int64_t hash = __lcmtypes_graph_t_get_hash(); int64_t this_hash; thislen = __int64_t_decode_array(buf, offset + pos, maxlen - pos, &this_hash, 1); if (thislen < 0) return thislen; else pos += thislen; if (this_hash != hash) return -1; thislen = __lcmtypes_graph_t_decode_array(buf, offset + pos, maxlen - pos, p, 1); if (thislen < 0) return thislen; else pos += thislen; return pos; } int lcmtypes_graph_t_decode_cleanup(lcmtypes_graph_t *p) { return __lcmtypes_graph_t_decode_array_cleanup(p, 1); } int __lcmtypes_graph_t_clone_array(const lcmtypes_graph_t *p, lcmtypes_graph_t *q, int elements) { int element; for (element = 0; element < elements; element++) { __int32_t_clone_array(&(p[element].num_vertices), &(q[element].num_vertices), 1); q[element].vertices = (lcmtypes_vertex_t*) lcm_malloc(sizeof(lcmtypes_vertex_t) * q[element].num_vertices); __lcmtypes_vertex_t_clone_array(p[element].vertices, q[element].vertices, p[element].num_vertices); __int32_t_clone_array(&(p[element].num_edges), &(q[element].num_edges), 1); q[element].edges = (lcmtypes_edge_t*) lcm_malloc(sizeof(lcmtypes_edge_t) * q[element].num_edges); __lcmtypes_edge_t_clone_array(p[element].edges, q[element].edges, p[element].num_edges); } return 0; } lcmtypes_graph_t *lcmtypes_graph_t_copy(const lcmtypes_graph_t *p) { lcmtypes_graph_t *q = (lcmtypes_graph_t*) malloc(sizeof(lcmtypes_graph_t)); __lcmtypes_graph_t_clone_array(p, q, 1); return q; } void lcmtypes_graph_t_destroy(lcmtypes_graph_t *p) { __lcmtypes_graph_t_decode_array_cleanup(p, 1); free(p); } int lcmtypes_graph_t_publish(lcm_t *lc, const char *channel, const lcmtypes_graph_t *p) { int max_data_size = lcmtypes_graph_t_encoded_size (p); uint8_t *buf = (uint8_t*) malloc (max_data_size); if (!buf) return -1; int data_size = lcmtypes_graph_t_encode (buf, 0, max_data_size, p); if (data_size < 0) { free (buf); return data_size; } int status = lcm_publish (lc, channel, buf, data_size); free (buf); return status; } struct _lcmtypes_graph_t_subscription_t { lcmtypes_graph_t_handler_t user_handler; void *userdata; lcm_subscription_t *lc_h; }; static void lcmtypes_graph_t_handler_stub (const lcm_recv_buf_t *rbuf, const char *channel, void *userdata) { int status; lcmtypes_graph_t p; memset(&p, 0, sizeof(lcmtypes_graph_t)); status = lcmtypes_graph_t_decode (rbuf->data, 0, rbuf->data_size, &p); if (status < 0) { fprintf (stderr, "error %d decoding lcmtypes_graph_t!!!\n", status); return; } lcmtypes_graph_t_subscription_t *h = (lcmtypes_graph_t_subscription_t*) userdata; h->user_handler (rbuf, channel, &p, h->userdata); lcmtypes_graph_t_decode_cleanup (&p); } lcmtypes_graph_t_subscription_t* lcmtypes_graph_t_subscribe (lcm_t *lcm, const char *channel, lcmtypes_graph_t_handler_t f, void *userdata) { lcmtypes_graph_t_subscription_t *n = (lcmtypes_graph_t_subscription_t*) malloc(sizeof(lcmtypes_graph_t_subscription_t)); n->user_handler = f; n->userdata = userdata; n->lc_h = lcm_subscribe (lcm, channel, lcmtypes_graph_t_handler_stub, n); if (n->lc_h == NULL) { fprintf (stderr,"couldn't reg lcmtypes_graph_t LCM handler!\n"); free (n); return NULL; } return n; } int lcmtypes_graph_t_subscription_set_queue_capacity (lcmtypes_graph_t_subscription_t* subs, int num_messages) { return lcm_subscription_set_queue_capacity (subs->lc_h, num_messages); } int lcmtypes_graph_t_unsubscribe(lcm_t *lcm, lcmtypes_graph_t_subscription_t* hid) { int status = lcm_unsubscribe (lcm, hid->lc_h); if (0 != status) { fprintf(stderr, "couldn't unsubscribe lcmtypes_graph_t_handler %p!\n", hid); return -1; } free (hid); return 0; } ================================================ FILE: data_generation/lcmtypes/lcmtypes/c/lcmtypes/lcmtypes_graph_t.h ================================================ // THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY // BY HAND!! // // Generated by lcm-gen #include #include #include #include #ifndef _lcmtypes_graph_t_h #define _lcmtypes_graph_t_h #ifdef __cplusplus extern "C" { #endif #include "lcmtypes/lcmtypes_vertex_t.h" #include "lcmtypes/lcmtypes_edge_t.h" typedef struct _lcmtypes_graph_t lcmtypes_graph_t; struct _lcmtypes_graph_t { int32_t num_vertices; lcmtypes_vertex_t *vertices; int32_t num_edges; lcmtypes_edge_t *edges; }; /** * Create a deep copy of a lcmtypes_graph_t. * When no longer needed, destroy it with lcmtypes_graph_t_destroy() */ lcmtypes_graph_t* lcmtypes_graph_t_copy(const lcmtypes_graph_t* to_copy); /** * Destroy an instance of lcmtypes_graph_t created by lcmtypes_graph_t_copy() */ void lcmtypes_graph_t_destroy(lcmtypes_graph_t* to_destroy); /** * Identifies a single subscription. This is an opaque data type. */ typedef struct _lcmtypes_graph_t_subscription_t lcmtypes_graph_t_subscription_t; /** * Prototype for a callback function invoked when a message of type * lcmtypes_graph_t is received. */ typedef void(*lcmtypes_graph_t_handler_t)(const lcm_recv_buf_t *rbuf, const char *channel, const lcmtypes_graph_t *msg, void *userdata); /** * Publish a message of type lcmtypes_graph_t using LCM. * * @param lcm The LCM instance to publish with. * @param channel The channel to publish on. * @param msg The message to publish. * @return 0 on success, <0 on error. Success means LCM has transferred * responsibility of the message data to the OS. */ int lcmtypes_graph_t_publish(lcm_t *lcm, const char *channel, const lcmtypes_graph_t *msg); /** * Subscribe to messages of type lcmtypes_graph_t using LCM. * * @param lcm The LCM instance to subscribe with. * @param channel The channel to subscribe to. * @param handler The callback function invoked by LCM when a message is received. * This function is invoked by LCM during calls to lcm_handle() and * lcm_handle_timeout(). * @param userdata An opaque pointer passed to @p handler when it is invoked. * @return 0 on success, <0 if an error occured */ lcmtypes_graph_t_subscription_t* lcmtypes_graph_t_subscribe(lcm_t *lcm, const char *channel, lcmtypes_graph_t_handler_t handler, void *userdata); /** * Removes and destroys a subscription created by lcmtypes_graph_t_subscribe() */ int lcmtypes_graph_t_unsubscribe(lcm_t *lcm, lcmtypes_graph_t_subscription_t* hid); /** * Sets the queue capacity for a subscription. * Some LCM providers (e.g., the default multicast provider) are implemented * using a background receive thread that constantly revceives messages from * the network. As these messages are received, they are buffered on * per-subscription queues until dispatched by lcm_handle(). This function * how many messages are queued before dropping messages. * * @param subs the subscription to modify. * @param num_messages The maximum number of messages to queue * on the subscription. * @return 0 on success, <0 if an error occured */ int lcmtypes_graph_t_subscription_set_queue_capacity(lcmtypes_graph_t_subscription_t* subs, int num_messages); /** * Encode a message of type lcmtypes_graph_t into binary form. * * @param buf The output buffer. * @param offset Encoding starts at this byte offset into @p buf. * @param maxlen Maximum number of bytes to write. This should generally * be equal to lcmtypes_graph_t_encoded_size(). * @param msg The message to encode. * @return The number of bytes encoded, or <0 if an error occured. */ int lcmtypes_graph_t_encode(void *buf, int offset, int maxlen, const lcmtypes_graph_t *p); /** * Decode a message of type lcmtypes_graph_t from binary form. * When decoding messages containing strings or variable-length arrays, this * function may allocate memory. When finished with the decoded message, * release allocated resources with lcmtypes_graph_t_decode_cleanup(). * * @param buf The buffer containing the encoded message * @param offset The byte offset into @p buf where the encoded message starts. * @param maxlen The maximum number of bytes to read while decoding. * @param msg Output parameter where the decoded message is stored * @return The number of bytes decoded, or <0 if an error occured. */ int lcmtypes_graph_t_decode(const void *buf, int offset, int maxlen, lcmtypes_graph_t *msg); /** * Release resources allocated by lcmtypes_graph_t_decode() * @return 0 */ int lcmtypes_graph_t_decode_cleanup(lcmtypes_graph_t *p); /** * Check how many bytes are required to encode a message of type lcmtypes_graph_t */ int lcmtypes_graph_t_encoded_size(const lcmtypes_graph_t *p); // LCM support functions. Users should not call these int64_t __lcmtypes_graph_t_get_hash(void); uint64_t __lcmtypes_graph_t_hash_recursive(const __lcm_hash_ptr *p); int __lcmtypes_graph_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_graph_t *p, int elements); int __lcmtypes_graph_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_graph_t *p, int elements); int __lcmtypes_graph_t_decode_array_cleanup(lcmtypes_graph_t *p, int elements); int __lcmtypes_graph_t_encoded_array_size(const lcmtypes_graph_t *p, int elements); int __lcmtypes_graph_t_clone_array(const lcmtypes_graph_t *p, lcmtypes_graph_t *q, int elements); #ifdef __cplusplus } #endif #endif ================================================ FILE: data_generation/lcmtypes/lcmtypes/c/lcmtypes/lcmtypes_region_3d_t.c ================================================ // THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY // BY HAND!! // // Generated by lcm-gen #include #include "lcmtypes/lcmtypes_region_3d_t.h" static int __lcmtypes_region_3d_t_hash_computed; static uint64_t __lcmtypes_region_3d_t_hash; uint64_t __lcmtypes_region_3d_t_hash_recursive(const __lcm_hash_ptr *p) { const __lcm_hash_ptr *fp; for (fp = p; fp != NULL; fp = fp->parent) if (fp->v == __lcmtypes_region_3d_t_get_hash) return 0; __lcm_hash_ptr cp; cp.parent = p; cp.v = (void*)__lcmtypes_region_3d_t_get_hash; (void) cp; uint64_t hash = (uint64_t)0x94830fc8d7404191LL + __double_hash_recursive(&cp) + __double_hash_recursive(&cp) ; return (hash<<1) + ((hash>>63)&1); } int64_t __lcmtypes_region_3d_t_get_hash(void) { if (!__lcmtypes_region_3d_t_hash_computed) { __lcmtypes_region_3d_t_hash = (int64_t)__lcmtypes_region_3d_t_hash_recursive(NULL); __lcmtypes_region_3d_t_hash_computed = 1; } return __lcmtypes_region_3d_t_hash; } int __lcmtypes_region_3d_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_region_3d_t *p, int elements) { int pos = 0, element; int thislen; for (element = 0; element < elements; element++) { thislen = __double_encode_array(buf, offset + pos, maxlen - pos, p[element].center, 3); if (thislen < 0) return thislen; else pos += thislen; thislen = __double_encode_array(buf, offset + pos, maxlen - pos, p[element].size, 3); if (thislen < 0) return thislen; else pos += thislen; } return pos; } int lcmtypes_region_3d_t_encode(void *buf, int offset, int maxlen, const lcmtypes_region_3d_t *p) { int pos = 0, thislen; int64_t hash = __lcmtypes_region_3d_t_get_hash(); thislen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, &hash, 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_region_3d_t_encode_array(buf, offset + pos, maxlen - pos, p, 1); if (thislen < 0) return thislen; else pos += thislen; return pos; } int __lcmtypes_region_3d_t_encoded_array_size(const lcmtypes_region_3d_t *p, int elements) { int size = 0, element; for (element = 0; element < elements; element++) { size += __double_encoded_array_size(p[element].center, 3); size += __double_encoded_array_size(p[element].size, 3); } return size; } int lcmtypes_region_3d_t_encoded_size(const lcmtypes_region_3d_t *p) { return 8 + __lcmtypes_region_3d_t_encoded_array_size(p, 1); } int __lcmtypes_region_3d_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_region_3d_t *p, int elements) { int pos = 0, thislen, element; for (element = 0; element < elements; element++) { thislen = __double_decode_array(buf, offset + pos, maxlen - pos, p[element].center, 3); if (thislen < 0) return thislen; else pos += thislen; thislen = __double_decode_array(buf, offset + pos, maxlen - pos, p[element].size, 3); if (thislen < 0) return thislen; else pos += thislen; } return pos; } int __lcmtypes_region_3d_t_decode_array_cleanup(lcmtypes_region_3d_t *p, int elements) { int element; for (element = 0; element < elements; element++) { __double_decode_array_cleanup(p[element].center, 3); __double_decode_array_cleanup(p[element].size, 3); } return 0; } int lcmtypes_region_3d_t_decode(const void *buf, int offset, int maxlen, lcmtypes_region_3d_t *p) { int pos = 0, thislen; int64_t hash = __lcmtypes_region_3d_t_get_hash(); int64_t this_hash; thislen = __int64_t_decode_array(buf, offset + pos, maxlen - pos, &this_hash, 1); if (thislen < 0) return thislen; else pos += thislen; if (this_hash != hash) return -1; thislen = __lcmtypes_region_3d_t_decode_array(buf, offset + pos, maxlen - pos, p, 1); if (thislen < 0) return thislen; else pos += thislen; return pos; } int lcmtypes_region_3d_t_decode_cleanup(lcmtypes_region_3d_t *p) { return __lcmtypes_region_3d_t_decode_array_cleanup(p, 1); } int __lcmtypes_region_3d_t_clone_array(const lcmtypes_region_3d_t *p, lcmtypes_region_3d_t *q, int elements) { int element; for (element = 0; element < elements; element++) { __double_clone_array(p[element].center, q[element].center, 3); __double_clone_array(p[element].size, q[element].size, 3); } return 0; } lcmtypes_region_3d_t *lcmtypes_region_3d_t_copy(const lcmtypes_region_3d_t *p) { lcmtypes_region_3d_t *q = (lcmtypes_region_3d_t*) malloc(sizeof(lcmtypes_region_3d_t)); __lcmtypes_region_3d_t_clone_array(p, q, 1); return q; } void lcmtypes_region_3d_t_destroy(lcmtypes_region_3d_t *p) { __lcmtypes_region_3d_t_decode_array_cleanup(p, 1); free(p); } int lcmtypes_region_3d_t_publish(lcm_t *lc, const char *channel, const lcmtypes_region_3d_t *p) { int max_data_size = lcmtypes_region_3d_t_encoded_size (p); uint8_t *buf = (uint8_t*) malloc (max_data_size); if (!buf) return -1; int data_size = lcmtypes_region_3d_t_encode (buf, 0, max_data_size, p); if (data_size < 0) { free (buf); return data_size; } int status = lcm_publish (lc, channel, buf, data_size); free (buf); return status; } struct _lcmtypes_region_3d_t_subscription_t { lcmtypes_region_3d_t_handler_t user_handler; void *userdata; lcm_subscription_t *lc_h; }; static void lcmtypes_region_3d_t_handler_stub (const lcm_recv_buf_t *rbuf, const char *channel, void *userdata) { int status; lcmtypes_region_3d_t p; memset(&p, 0, sizeof(lcmtypes_region_3d_t)); status = lcmtypes_region_3d_t_decode (rbuf->data, 0, rbuf->data_size, &p); if (status < 0) { fprintf (stderr, "error %d decoding lcmtypes_region_3d_t!!!\n", status); return; } lcmtypes_region_3d_t_subscription_t *h = (lcmtypes_region_3d_t_subscription_t*) userdata; h->user_handler (rbuf, channel, &p, h->userdata); lcmtypes_region_3d_t_decode_cleanup (&p); } lcmtypes_region_3d_t_subscription_t* lcmtypes_region_3d_t_subscribe (lcm_t *lcm, const char *channel, lcmtypes_region_3d_t_handler_t f, void *userdata) { lcmtypes_region_3d_t_subscription_t *n = (lcmtypes_region_3d_t_subscription_t*) malloc(sizeof(lcmtypes_region_3d_t_subscription_t)); n->user_handler = f; n->userdata = userdata; n->lc_h = lcm_subscribe (lcm, channel, lcmtypes_region_3d_t_handler_stub, n); if (n->lc_h == NULL) { fprintf (stderr,"couldn't reg lcmtypes_region_3d_t LCM handler!\n"); free (n); return NULL; } return n; } int lcmtypes_region_3d_t_subscription_set_queue_capacity (lcmtypes_region_3d_t_subscription_t* subs, int num_messages) { return lcm_subscription_set_queue_capacity (subs->lc_h, num_messages); } int lcmtypes_region_3d_t_unsubscribe(lcm_t *lcm, lcmtypes_region_3d_t_subscription_t* hid) { int status = lcm_unsubscribe (lcm, hid->lc_h); if (0 != status) { fprintf(stderr, "couldn't unsubscribe lcmtypes_region_3d_t_handler %p!\n", hid); return -1; } free (hid); return 0; } ================================================ FILE: data_generation/lcmtypes/lcmtypes/c/lcmtypes/lcmtypes_region_3d_t.h ================================================ // THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY // BY HAND!! // // Generated by lcm-gen #include #include #include #include #ifndef _lcmtypes_region_3d_t_h #define _lcmtypes_region_3d_t_h #ifdef __cplusplus extern "C" { #endif typedef struct _lcmtypes_region_3d_t lcmtypes_region_3d_t; struct _lcmtypes_region_3d_t { double center[3]; double size[3]; }; /** * Create a deep copy of a lcmtypes_region_3d_t. * When no longer needed, destroy it with lcmtypes_region_3d_t_destroy() */ lcmtypes_region_3d_t* lcmtypes_region_3d_t_copy(const lcmtypes_region_3d_t* to_copy); /** * Destroy an instance of lcmtypes_region_3d_t created by lcmtypes_region_3d_t_copy() */ void lcmtypes_region_3d_t_destroy(lcmtypes_region_3d_t* to_destroy); /** * Identifies a single subscription. This is an opaque data type. */ typedef struct _lcmtypes_region_3d_t_subscription_t lcmtypes_region_3d_t_subscription_t; /** * Prototype for a callback function invoked when a message of type * lcmtypes_region_3d_t is received. */ typedef void(*lcmtypes_region_3d_t_handler_t)(const lcm_recv_buf_t *rbuf, const char *channel, const lcmtypes_region_3d_t *msg, void *userdata); /** * Publish a message of type lcmtypes_region_3d_t using LCM. * * @param lcm The LCM instance to publish with. * @param channel The channel to publish on. * @param msg The message to publish. * @return 0 on success, <0 on error. Success means LCM has transferred * responsibility of the message data to the OS. */ int lcmtypes_region_3d_t_publish(lcm_t *lcm, const char *channel, const lcmtypes_region_3d_t *msg); /** * Subscribe to messages of type lcmtypes_region_3d_t using LCM. * * @param lcm The LCM instance to subscribe with. * @param channel The channel to subscribe to. * @param handler The callback function invoked by LCM when a message is received. * This function is invoked by LCM during calls to lcm_handle() and * lcm_handle_timeout(). * @param userdata An opaque pointer passed to @p handler when it is invoked. * @return 0 on success, <0 if an error occured */ lcmtypes_region_3d_t_subscription_t* lcmtypes_region_3d_t_subscribe(lcm_t *lcm, const char *channel, lcmtypes_region_3d_t_handler_t handler, void *userdata); /** * Removes and destroys a subscription created by lcmtypes_region_3d_t_subscribe() */ int lcmtypes_region_3d_t_unsubscribe(lcm_t *lcm, lcmtypes_region_3d_t_subscription_t* hid); /** * Sets the queue capacity for a subscription. * Some LCM providers (e.g., the default multicast provider) are implemented * using a background receive thread that constantly revceives messages from * the network. As these messages are received, they are buffered on * per-subscription queues until dispatched by lcm_handle(). This function * how many messages are queued before dropping messages. * * @param subs the subscription to modify. * @param num_messages The maximum number of messages to queue * on the subscription. * @return 0 on success, <0 if an error occured */ int lcmtypes_region_3d_t_subscription_set_queue_capacity(lcmtypes_region_3d_t_subscription_t* subs, int num_messages); /** * Encode a message of type lcmtypes_region_3d_t into binary form. * * @param buf The output buffer. * @param offset Encoding starts at this byte offset into @p buf. * @param maxlen Maximum number of bytes to write. This should generally * be equal to lcmtypes_region_3d_t_encoded_size(). * @param msg The message to encode. * @return The number of bytes encoded, or <0 if an error occured. */ int lcmtypes_region_3d_t_encode(void *buf, int offset, int maxlen, const lcmtypes_region_3d_t *p); /** * Decode a message of type lcmtypes_region_3d_t from binary form. * When decoding messages containing strings or variable-length arrays, this * function may allocate memory. When finished with the decoded message, * release allocated resources with lcmtypes_region_3d_t_decode_cleanup(). * * @param buf The buffer containing the encoded message * @param offset The byte offset into @p buf where the encoded message starts. * @param maxlen The maximum number of bytes to read while decoding. * @param msg Output parameter where the decoded message is stored * @return The number of bytes decoded, or <0 if an error occured. */ int lcmtypes_region_3d_t_decode(const void *buf, int offset, int maxlen, lcmtypes_region_3d_t *msg); /** * Release resources allocated by lcmtypes_region_3d_t_decode() * @return 0 */ int lcmtypes_region_3d_t_decode_cleanup(lcmtypes_region_3d_t *p); /** * Check how many bytes are required to encode a message of type lcmtypes_region_3d_t */ int lcmtypes_region_3d_t_encoded_size(const lcmtypes_region_3d_t *p); // LCM support functions. Users should not call these int64_t __lcmtypes_region_3d_t_get_hash(void); uint64_t __lcmtypes_region_3d_t_hash_recursive(const __lcm_hash_ptr *p); int __lcmtypes_region_3d_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_region_3d_t *p, int elements); int __lcmtypes_region_3d_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_region_3d_t *p, int elements); int __lcmtypes_region_3d_t_decode_array_cleanup(lcmtypes_region_3d_t *p, int elements); int __lcmtypes_region_3d_t_encoded_array_size(const lcmtypes_region_3d_t *p, int elements); int __lcmtypes_region_3d_t_clone_array(const lcmtypes_region_3d_t *p, lcmtypes_region_3d_t *q, int elements); #ifdef __cplusplus } #endif #endif ================================================ FILE: data_generation/lcmtypes/lcmtypes/c/lcmtypes/lcmtypes_state_t.c ================================================ // THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY // BY HAND!! // // Generated by lcm-gen #include #include "lcmtypes/lcmtypes_state_t.h" static int __lcmtypes_state_t_hash_computed; static uint64_t __lcmtypes_state_t_hash; uint64_t __lcmtypes_state_t_hash_recursive(const __lcm_hash_ptr *p) { const __lcm_hash_ptr *fp; for (fp = p; fp != NULL; fp = fp->parent) if (fp->v == __lcmtypes_state_t_get_hash) return 0; __lcm_hash_ptr cp; cp.parent = p; cp.v = (void*)__lcmtypes_state_t_get_hash; (void) cp; uint64_t hash = (uint64_t)0x573f2fdd2f76508fLL + __double_hash_recursive(&cp) + __double_hash_recursive(&cp) + __double_hash_recursive(&cp) ; return (hash<<1) + ((hash>>63)&1); } int64_t __lcmtypes_state_t_get_hash(void) { if (!__lcmtypes_state_t_hash_computed) { __lcmtypes_state_t_hash = (int64_t)__lcmtypes_state_t_hash_recursive(NULL); __lcmtypes_state_t_hash_computed = 1; } return __lcmtypes_state_t_hash; } int __lcmtypes_state_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_state_t *p, int elements) { int pos = 0, element; int thislen; for (element = 0; element < elements; element++) { thislen = __double_encode_array(buf, offset + pos, maxlen - pos, &(p[element].x), 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __double_encode_array(buf, offset + pos, maxlen - pos, &(p[element].y), 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __double_encode_array(buf, offset + pos, maxlen - pos, &(p[element].z), 1); if (thislen < 0) return thislen; else pos += thislen; } return pos; } int lcmtypes_state_t_encode(void *buf, int offset, int maxlen, const lcmtypes_state_t *p) { int pos = 0, thislen; int64_t hash = __lcmtypes_state_t_get_hash(); thislen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, &hash, 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_state_t_encode_array(buf, offset + pos, maxlen - pos, p, 1); if (thislen < 0) return thislen; else pos += thislen; return pos; } int __lcmtypes_state_t_encoded_array_size(const lcmtypes_state_t *p, int elements) { int size = 0, element; for (element = 0; element < elements; element++) { size += __double_encoded_array_size(&(p[element].x), 1); size += __double_encoded_array_size(&(p[element].y), 1); size += __double_encoded_array_size(&(p[element].z), 1); } return size; } int lcmtypes_state_t_encoded_size(const lcmtypes_state_t *p) { return 8 + __lcmtypes_state_t_encoded_array_size(p, 1); } int __lcmtypes_state_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_state_t *p, int elements) { int pos = 0, thislen, element; for (element = 0; element < elements; element++) { thislen = __double_decode_array(buf, offset + pos, maxlen - pos, &(p[element].x), 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __double_decode_array(buf, offset + pos, maxlen - pos, &(p[element].y), 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __double_decode_array(buf, offset + pos, maxlen - pos, &(p[element].z), 1); if (thislen < 0) return thislen; else pos += thislen; } return pos; } int __lcmtypes_state_t_decode_array_cleanup(lcmtypes_state_t *p, int elements) { int element; for (element = 0; element < elements; element++) { __double_decode_array_cleanup(&(p[element].x), 1); __double_decode_array_cleanup(&(p[element].y), 1); __double_decode_array_cleanup(&(p[element].z), 1); } return 0; } int lcmtypes_state_t_decode(const void *buf, int offset, int maxlen, lcmtypes_state_t *p) { int pos = 0, thislen; int64_t hash = __lcmtypes_state_t_get_hash(); int64_t this_hash; thislen = __int64_t_decode_array(buf, offset + pos, maxlen - pos, &this_hash, 1); if (thislen < 0) return thislen; else pos += thislen; if (this_hash != hash) return -1; thislen = __lcmtypes_state_t_decode_array(buf, offset + pos, maxlen - pos, p, 1); if (thislen < 0) return thislen; else pos += thislen; return pos; } int lcmtypes_state_t_decode_cleanup(lcmtypes_state_t *p) { return __lcmtypes_state_t_decode_array_cleanup(p, 1); } int __lcmtypes_state_t_clone_array(const lcmtypes_state_t *p, lcmtypes_state_t *q, int elements) { int element; for (element = 0; element < elements; element++) { __double_clone_array(&(p[element].x), &(q[element].x), 1); __double_clone_array(&(p[element].y), &(q[element].y), 1); __double_clone_array(&(p[element].z), &(q[element].z), 1); } return 0; } lcmtypes_state_t *lcmtypes_state_t_copy(const lcmtypes_state_t *p) { lcmtypes_state_t *q = (lcmtypes_state_t*) malloc(sizeof(lcmtypes_state_t)); __lcmtypes_state_t_clone_array(p, q, 1); return q; } void lcmtypes_state_t_destroy(lcmtypes_state_t *p) { __lcmtypes_state_t_decode_array_cleanup(p, 1); free(p); } int lcmtypes_state_t_publish(lcm_t *lc, const char *channel, const lcmtypes_state_t *p) { int max_data_size = lcmtypes_state_t_encoded_size (p); uint8_t *buf = (uint8_t*) malloc (max_data_size); if (!buf) return -1; int data_size = lcmtypes_state_t_encode (buf, 0, max_data_size, p); if (data_size < 0) { free (buf); return data_size; } int status = lcm_publish (lc, channel, buf, data_size); free (buf); return status; } struct _lcmtypes_state_t_subscription_t { lcmtypes_state_t_handler_t user_handler; void *userdata; lcm_subscription_t *lc_h; }; static void lcmtypes_state_t_handler_stub (const lcm_recv_buf_t *rbuf, const char *channel, void *userdata) { int status; lcmtypes_state_t p; memset(&p, 0, sizeof(lcmtypes_state_t)); status = lcmtypes_state_t_decode (rbuf->data, 0, rbuf->data_size, &p); if (status < 0) { fprintf (stderr, "error %d decoding lcmtypes_state_t!!!\n", status); return; } lcmtypes_state_t_subscription_t *h = (lcmtypes_state_t_subscription_t*) userdata; h->user_handler (rbuf, channel, &p, h->userdata); lcmtypes_state_t_decode_cleanup (&p); } lcmtypes_state_t_subscription_t* lcmtypes_state_t_subscribe (lcm_t *lcm, const char *channel, lcmtypes_state_t_handler_t f, void *userdata) { lcmtypes_state_t_subscription_t *n = (lcmtypes_state_t_subscription_t*) malloc(sizeof(lcmtypes_state_t_subscription_t)); n->user_handler = f; n->userdata = userdata; n->lc_h = lcm_subscribe (lcm, channel, lcmtypes_state_t_handler_stub, n); if (n->lc_h == NULL) { fprintf (stderr,"couldn't reg lcmtypes_state_t LCM handler!\n"); free (n); return NULL; } return n; } int lcmtypes_state_t_subscription_set_queue_capacity (lcmtypes_state_t_subscription_t* subs, int num_messages) { return lcm_subscription_set_queue_capacity (subs->lc_h, num_messages); } int lcmtypes_state_t_unsubscribe(lcm_t *lcm, lcmtypes_state_t_subscription_t* hid) { int status = lcm_unsubscribe (lcm, hid->lc_h); if (0 != status) { fprintf(stderr, "couldn't unsubscribe lcmtypes_state_t_handler %p!\n", hid); return -1; } free (hid); return 0; } ================================================ FILE: data_generation/lcmtypes/lcmtypes/c/lcmtypes/lcmtypes_state_t.h ================================================ // THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY // BY HAND!! // // Generated by lcm-gen #include #include #include #include #ifndef _lcmtypes_state_t_h #define _lcmtypes_state_t_h #ifdef __cplusplus extern "C" { #endif typedef struct _lcmtypes_state_t lcmtypes_state_t; struct _lcmtypes_state_t { double x; double y; double z; }; /** * Create a deep copy of a lcmtypes_state_t. * When no longer needed, destroy it with lcmtypes_state_t_destroy() */ lcmtypes_state_t* lcmtypes_state_t_copy(const lcmtypes_state_t* to_copy); /** * Destroy an instance of lcmtypes_state_t created by lcmtypes_state_t_copy() */ void lcmtypes_state_t_destroy(lcmtypes_state_t* to_destroy); /** * Identifies a single subscription. This is an opaque data type. */ typedef struct _lcmtypes_state_t_subscription_t lcmtypes_state_t_subscription_t; /** * Prototype for a callback function invoked when a message of type * lcmtypes_state_t is received. */ typedef void(*lcmtypes_state_t_handler_t)(const lcm_recv_buf_t *rbuf, const char *channel, const lcmtypes_state_t *msg, void *userdata); /** * Publish a message of type lcmtypes_state_t using LCM. * * @param lcm The LCM instance to publish with. * @param channel The channel to publish on. * @param msg The message to publish. * @return 0 on success, <0 on error. Success means LCM has transferred * responsibility of the message data to the OS. */ int lcmtypes_state_t_publish(lcm_t *lcm, const char *channel, const lcmtypes_state_t *msg); /** * Subscribe to messages of type lcmtypes_state_t using LCM. * * @param lcm The LCM instance to subscribe with. * @param channel The channel to subscribe to. * @param handler The callback function invoked by LCM when a message is received. * This function is invoked by LCM during calls to lcm_handle() and * lcm_handle_timeout(). * @param userdata An opaque pointer passed to @p handler when it is invoked. * @return 0 on success, <0 if an error occured */ lcmtypes_state_t_subscription_t* lcmtypes_state_t_subscribe(lcm_t *lcm, const char *channel, lcmtypes_state_t_handler_t handler, void *userdata); /** * Removes and destroys a subscription created by lcmtypes_state_t_subscribe() */ int lcmtypes_state_t_unsubscribe(lcm_t *lcm, lcmtypes_state_t_subscription_t* hid); /** * Sets the queue capacity for a subscription. * Some LCM providers (e.g., the default multicast provider) are implemented * using a background receive thread that constantly revceives messages from * the network. As these messages are received, they are buffered on * per-subscription queues until dispatched by lcm_handle(). This function * how many messages are queued before dropping messages. * * @param subs the subscription to modify. * @param num_messages The maximum number of messages to queue * on the subscription. * @return 0 on success, <0 if an error occured */ int lcmtypes_state_t_subscription_set_queue_capacity(lcmtypes_state_t_subscription_t* subs, int num_messages); /** * Encode a message of type lcmtypes_state_t into binary form. * * @param buf The output buffer. * @param offset Encoding starts at this byte offset into @p buf. * @param maxlen Maximum number of bytes to write. This should generally * be equal to lcmtypes_state_t_encoded_size(). * @param msg The message to encode. * @return The number of bytes encoded, or <0 if an error occured. */ int lcmtypes_state_t_encode(void *buf, int offset, int maxlen, const lcmtypes_state_t *p); /** * Decode a message of type lcmtypes_state_t from binary form. * When decoding messages containing strings or variable-length arrays, this * function may allocate memory. When finished with the decoded message, * release allocated resources with lcmtypes_state_t_decode_cleanup(). * * @param buf The buffer containing the encoded message * @param offset The byte offset into @p buf where the encoded message starts. * @param maxlen The maximum number of bytes to read while decoding. * @param msg Output parameter where the decoded message is stored * @return The number of bytes decoded, or <0 if an error occured. */ int lcmtypes_state_t_decode(const void *buf, int offset, int maxlen, lcmtypes_state_t *msg); /** * Release resources allocated by lcmtypes_state_t_decode() * @return 0 */ int lcmtypes_state_t_decode_cleanup(lcmtypes_state_t *p); /** * Check how many bytes are required to encode a message of type lcmtypes_state_t */ int lcmtypes_state_t_encoded_size(const lcmtypes_state_t *p); // LCM support functions. Users should not call these int64_t __lcmtypes_state_t_get_hash(void); uint64_t __lcmtypes_state_t_hash_recursive(const __lcm_hash_ptr *p); int __lcmtypes_state_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_state_t *p, int elements); int __lcmtypes_state_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_state_t *p, int elements); int __lcmtypes_state_t_decode_array_cleanup(lcmtypes_state_t *p, int elements); int __lcmtypes_state_t_encoded_array_size(const lcmtypes_state_t *p, int elements); int __lcmtypes_state_t_clone_array(const lcmtypes_state_t *p, lcmtypes_state_t *q, int elements); #ifdef __cplusplus } #endif #endif ================================================ FILE: data_generation/lcmtypes/lcmtypes/c/lcmtypes/lcmtypes_trajectory_t.c ================================================ // THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY // BY HAND!! // // Generated by lcm-gen #include #include "lcmtypes/lcmtypes_trajectory_t.h" static int __lcmtypes_trajectory_t_hash_computed; static uint64_t __lcmtypes_trajectory_t_hash; uint64_t __lcmtypes_trajectory_t_hash_recursive(const __lcm_hash_ptr *p) { const __lcm_hash_ptr *fp; for (fp = p; fp != NULL; fp = fp->parent) if (fp->v == __lcmtypes_trajectory_t_get_hash) return 0; __lcm_hash_ptr cp; cp.parent = p; cp.v = (void*)__lcmtypes_trajectory_t_get_hash; (void) cp; uint64_t hash = (uint64_t)0x67039c5ec5ece44fLL + __int32_t_hash_recursive(&cp) + __lcmtypes_state_t_hash_recursive(&cp) ; return (hash<<1) + ((hash>>63)&1); } int64_t __lcmtypes_trajectory_t_get_hash(void) { if (!__lcmtypes_trajectory_t_hash_computed) { __lcmtypes_trajectory_t_hash = (int64_t)__lcmtypes_trajectory_t_hash_recursive(NULL); __lcmtypes_trajectory_t_hash_computed = 1; } return __lcmtypes_trajectory_t_hash; } int __lcmtypes_trajectory_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_trajectory_t *p, int elements) { int pos = 0, element; int thislen; for (element = 0; element < elements; element++) { thislen = __int32_t_encode_array(buf, offset + pos, maxlen - pos, &(p[element].num_states), 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_state_t_encode_array(buf, offset + pos, maxlen - pos, p[element].states, p[element].num_states); if (thislen < 0) return thislen; else pos += thislen; } return pos; } int lcmtypes_trajectory_t_encode(void *buf, int offset, int maxlen, const lcmtypes_trajectory_t *p) { int pos = 0, thislen; int64_t hash = __lcmtypes_trajectory_t_get_hash(); thislen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, &hash, 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_trajectory_t_encode_array(buf, offset + pos, maxlen - pos, p, 1); if (thislen < 0) return thislen; else pos += thislen; return pos; } int __lcmtypes_trajectory_t_encoded_array_size(const lcmtypes_trajectory_t *p, int elements) { int size = 0, element; for (element = 0; element < elements; element++) { size += __int32_t_encoded_array_size(&(p[element].num_states), 1); size += __lcmtypes_state_t_encoded_array_size(p[element].states, p[element].num_states); } return size; } int lcmtypes_trajectory_t_encoded_size(const lcmtypes_trajectory_t *p) { return 8 + __lcmtypes_trajectory_t_encoded_array_size(p, 1); } int __lcmtypes_trajectory_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_trajectory_t *p, int elements) { int pos = 0, thislen, element; for (element = 0; element < elements; element++) { thislen = __int32_t_decode_array(buf, offset + pos, maxlen - pos, &(p[element].num_states), 1); if (thislen < 0) return thislen; else pos += thislen; p[element].states = (lcmtypes_state_t*) lcm_malloc(sizeof(lcmtypes_state_t) * p[element].num_states); thislen = __lcmtypes_state_t_decode_array(buf, offset + pos, maxlen - pos, p[element].states, p[element].num_states); if (thislen < 0) return thislen; else pos += thislen; } return pos; } int __lcmtypes_trajectory_t_decode_array_cleanup(lcmtypes_trajectory_t *p, int elements) { int element; for (element = 0; element < elements; element++) { __int32_t_decode_array_cleanup(&(p[element].num_states), 1); __lcmtypes_state_t_decode_array_cleanup(p[element].states, p[element].num_states); if (p[element].states) free(p[element].states); } return 0; } int lcmtypes_trajectory_t_decode(const void *buf, int offset, int maxlen, lcmtypes_trajectory_t *p) { int pos = 0, thislen; int64_t hash = __lcmtypes_trajectory_t_get_hash(); int64_t this_hash; thislen = __int64_t_decode_array(buf, offset + pos, maxlen - pos, &this_hash, 1); if (thislen < 0) return thislen; else pos += thislen; if (this_hash != hash) return -1; thislen = __lcmtypes_trajectory_t_decode_array(buf, offset + pos, maxlen - pos, p, 1); if (thislen < 0) return thislen; else pos += thislen; return pos; } int lcmtypes_trajectory_t_decode_cleanup(lcmtypes_trajectory_t *p) { return __lcmtypes_trajectory_t_decode_array_cleanup(p, 1); } int __lcmtypes_trajectory_t_clone_array(const lcmtypes_trajectory_t *p, lcmtypes_trajectory_t *q, int elements) { int element; for (element = 0; element < elements; element++) { __int32_t_clone_array(&(p[element].num_states), &(q[element].num_states), 1); q[element].states = (lcmtypes_state_t*) lcm_malloc(sizeof(lcmtypes_state_t) * q[element].num_states); __lcmtypes_state_t_clone_array(p[element].states, q[element].states, p[element].num_states); } return 0; } lcmtypes_trajectory_t *lcmtypes_trajectory_t_copy(const lcmtypes_trajectory_t *p) { lcmtypes_trajectory_t *q = (lcmtypes_trajectory_t*) malloc(sizeof(lcmtypes_trajectory_t)); __lcmtypes_trajectory_t_clone_array(p, q, 1); return q; } void lcmtypes_trajectory_t_destroy(lcmtypes_trajectory_t *p) { __lcmtypes_trajectory_t_decode_array_cleanup(p, 1); free(p); } int lcmtypes_trajectory_t_publish(lcm_t *lc, const char *channel, const lcmtypes_trajectory_t *p) { int max_data_size = lcmtypes_trajectory_t_encoded_size (p); uint8_t *buf = (uint8_t*) malloc (max_data_size); if (!buf) return -1; int data_size = lcmtypes_trajectory_t_encode (buf, 0, max_data_size, p); if (data_size < 0) { free (buf); return data_size; } int status = lcm_publish (lc, channel, buf, data_size); free (buf); return status; } struct _lcmtypes_trajectory_t_subscription_t { lcmtypes_trajectory_t_handler_t user_handler; void *userdata; lcm_subscription_t *lc_h; }; static void lcmtypes_trajectory_t_handler_stub (const lcm_recv_buf_t *rbuf, const char *channel, void *userdata) { int status; lcmtypes_trajectory_t p; memset(&p, 0, sizeof(lcmtypes_trajectory_t)); status = lcmtypes_trajectory_t_decode (rbuf->data, 0, rbuf->data_size, &p); if (status < 0) { fprintf (stderr, "error %d decoding lcmtypes_trajectory_t!!!\n", status); return; } lcmtypes_trajectory_t_subscription_t *h = (lcmtypes_trajectory_t_subscription_t*) userdata; h->user_handler (rbuf, channel, &p, h->userdata); lcmtypes_trajectory_t_decode_cleanup (&p); } lcmtypes_trajectory_t_subscription_t* lcmtypes_trajectory_t_subscribe (lcm_t *lcm, const char *channel, lcmtypes_trajectory_t_handler_t f, void *userdata) { lcmtypes_trajectory_t_subscription_t *n = (lcmtypes_trajectory_t_subscription_t*) malloc(sizeof(lcmtypes_trajectory_t_subscription_t)); n->user_handler = f; n->userdata = userdata; n->lc_h = lcm_subscribe (lcm, channel, lcmtypes_trajectory_t_handler_stub, n); if (n->lc_h == NULL) { fprintf (stderr,"couldn't reg lcmtypes_trajectory_t LCM handler!\n"); free (n); return NULL; } return n; } int lcmtypes_trajectory_t_subscription_set_queue_capacity (lcmtypes_trajectory_t_subscription_t* subs, int num_messages) { return lcm_subscription_set_queue_capacity (subs->lc_h, num_messages); } int lcmtypes_trajectory_t_unsubscribe(lcm_t *lcm, lcmtypes_trajectory_t_subscription_t* hid) { int status = lcm_unsubscribe (lcm, hid->lc_h); if (0 != status) { fprintf(stderr, "couldn't unsubscribe lcmtypes_trajectory_t_handler %p!\n", hid); return -1; } free (hid); return 0; } ================================================ FILE: data_generation/lcmtypes/lcmtypes/c/lcmtypes/lcmtypes_trajectory_t.h ================================================ // THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY // BY HAND!! // // Generated by lcm-gen #include #include #include #include #ifndef _lcmtypes_trajectory_t_h #define _lcmtypes_trajectory_t_h #ifdef __cplusplus extern "C" { #endif #include "lcmtypes/lcmtypes_state_t.h" typedef struct _lcmtypes_trajectory_t lcmtypes_trajectory_t; struct _lcmtypes_trajectory_t { int32_t num_states; lcmtypes_state_t *states; }; /** * Create a deep copy of a lcmtypes_trajectory_t. * When no longer needed, destroy it with lcmtypes_trajectory_t_destroy() */ lcmtypes_trajectory_t* lcmtypes_trajectory_t_copy(const lcmtypes_trajectory_t* to_copy); /** * Destroy an instance of lcmtypes_trajectory_t created by lcmtypes_trajectory_t_copy() */ void lcmtypes_trajectory_t_destroy(lcmtypes_trajectory_t* to_destroy); /** * Identifies a single subscription. This is an opaque data type. */ typedef struct _lcmtypes_trajectory_t_subscription_t lcmtypes_trajectory_t_subscription_t; /** * Prototype for a callback function invoked when a message of type * lcmtypes_trajectory_t is received. */ typedef void(*lcmtypes_trajectory_t_handler_t)(const lcm_recv_buf_t *rbuf, const char *channel, const lcmtypes_trajectory_t *msg, void *userdata); /** * Publish a message of type lcmtypes_trajectory_t using LCM. * * @param lcm The LCM instance to publish with. * @param channel The channel to publish on. * @param msg The message to publish. * @return 0 on success, <0 on error. Success means LCM has transferred * responsibility of the message data to the OS. */ int lcmtypes_trajectory_t_publish(lcm_t *lcm, const char *channel, const lcmtypes_trajectory_t *msg); /** * Subscribe to messages of type lcmtypes_trajectory_t using LCM. * * @param lcm The LCM instance to subscribe with. * @param channel The channel to subscribe to. * @param handler The callback function invoked by LCM when a message is received. * This function is invoked by LCM during calls to lcm_handle() and * lcm_handle_timeout(). * @param userdata An opaque pointer passed to @p handler when it is invoked. * @return 0 on success, <0 if an error occured */ lcmtypes_trajectory_t_subscription_t* lcmtypes_trajectory_t_subscribe(lcm_t *lcm, const char *channel, lcmtypes_trajectory_t_handler_t handler, void *userdata); /** * Removes and destroys a subscription created by lcmtypes_trajectory_t_subscribe() */ int lcmtypes_trajectory_t_unsubscribe(lcm_t *lcm, lcmtypes_trajectory_t_subscription_t* hid); /** * Sets the queue capacity for a subscription. * Some LCM providers (e.g., the default multicast provider) are implemented * using a background receive thread that constantly revceives messages from * the network. As these messages are received, they are buffered on * per-subscription queues until dispatched by lcm_handle(). This function * how many messages are queued before dropping messages. * * @param subs the subscription to modify. * @param num_messages The maximum number of messages to queue * on the subscription. * @return 0 on success, <0 if an error occured */ int lcmtypes_trajectory_t_subscription_set_queue_capacity(lcmtypes_trajectory_t_subscription_t* subs, int num_messages); /** * Encode a message of type lcmtypes_trajectory_t into binary form. * * @param buf The output buffer. * @param offset Encoding starts at this byte offset into @p buf. * @param maxlen Maximum number of bytes to write. This should generally * be equal to lcmtypes_trajectory_t_encoded_size(). * @param msg The message to encode. * @return The number of bytes encoded, or <0 if an error occured. */ int lcmtypes_trajectory_t_encode(void *buf, int offset, int maxlen, const lcmtypes_trajectory_t *p); /** * Decode a message of type lcmtypes_trajectory_t from binary form. * When decoding messages containing strings or variable-length arrays, this * function may allocate memory. When finished with the decoded message, * release allocated resources with lcmtypes_trajectory_t_decode_cleanup(). * * @param buf The buffer containing the encoded message * @param offset The byte offset into @p buf where the encoded message starts. * @param maxlen The maximum number of bytes to read while decoding. * @param msg Output parameter where the decoded message is stored * @return The number of bytes decoded, or <0 if an error occured. */ int lcmtypes_trajectory_t_decode(const void *buf, int offset, int maxlen, lcmtypes_trajectory_t *msg); /** * Release resources allocated by lcmtypes_trajectory_t_decode() * @return 0 */ int lcmtypes_trajectory_t_decode_cleanup(lcmtypes_trajectory_t *p); /** * Check how many bytes are required to encode a message of type lcmtypes_trajectory_t */ int lcmtypes_trajectory_t_encoded_size(const lcmtypes_trajectory_t *p); // LCM support functions. Users should not call these int64_t __lcmtypes_trajectory_t_get_hash(void); uint64_t __lcmtypes_trajectory_t_hash_recursive(const __lcm_hash_ptr *p); int __lcmtypes_trajectory_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_trajectory_t *p, int elements); int __lcmtypes_trajectory_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_trajectory_t *p, int elements); int __lcmtypes_trajectory_t_decode_array_cleanup(lcmtypes_trajectory_t *p, int elements); int __lcmtypes_trajectory_t_encoded_array_size(const lcmtypes_trajectory_t *p, int elements); int __lcmtypes_trajectory_t_clone_array(const lcmtypes_trajectory_t *p, lcmtypes_trajectory_t *q, int elements); #ifdef __cplusplus } #endif #endif ================================================ FILE: data_generation/lcmtypes/lcmtypes/c/lcmtypes/lcmtypes_vertex_t.c ================================================ // THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY // BY HAND!! // // Generated by lcm-gen #include #include "lcmtypes/lcmtypes_vertex_t.h" static int __lcmtypes_vertex_t_hash_computed; static uint64_t __lcmtypes_vertex_t_hash; uint64_t __lcmtypes_vertex_t_hash_recursive(const __lcm_hash_ptr *p) { const __lcm_hash_ptr *fp; for (fp = p; fp != NULL; fp = fp->parent) if (fp->v == __lcmtypes_vertex_t_get_hash) return 0; __lcm_hash_ptr cp; cp.parent = p; cp.v = (void*)__lcmtypes_vertex_t_get_hash; (void) cp; uint64_t hash = (uint64_t)0x780573746198cdacLL + __lcmtypes_state_t_hash_recursive(&cp) ; return (hash<<1) + ((hash>>63)&1); } int64_t __lcmtypes_vertex_t_get_hash(void) { if (!__lcmtypes_vertex_t_hash_computed) { __lcmtypes_vertex_t_hash = (int64_t)__lcmtypes_vertex_t_hash_recursive(NULL); __lcmtypes_vertex_t_hash_computed = 1; } return __lcmtypes_vertex_t_hash; } int __lcmtypes_vertex_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_vertex_t *p, int elements) { int pos = 0, element; int thislen; for (element = 0; element < elements; element++) { thislen = __lcmtypes_state_t_encode_array(buf, offset + pos, maxlen - pos, &(p[element].state), 1); if (thislen < 0) return thislen; else pos += thislen; } return pos; } int lcmtypes_vertex_t_encode(void *buf, int offset, int maxlen, const lcmtypes_vertex_t *p) { int pos = 0, thislen; int64_t hash = __lcmtypes_vertex_t_get_hash(); thislen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, &hash, 1); if (thislen < 0) return thislen; else pos += thislen; thislen = __lcmtypes_vertex_t_encode_array(buf, offset + pos, maxlen - pos, p, 1); if (thislen < 0) return thislen; else pos += thislen; return pos; } int __lcmtypes_vertex_t_encoded_array_size(const lcmtypes_vertex_t *p, int elements) { int size = 0, element; for (element = 0; element < elements; element++) { size += __lcmtypes_state_t_encoded_array_size(&(p[element].state), 1); } return size; } int lcmtypes_vertex_t_encoded_size(const lcmtypes_vertex_t *p) { return 8 + __lcmtypes_vertex_t_encoded_array_size(p, 1); } int __lcmtypes_vertex_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_vertex_t *p, int elements) { int pos = 0, thislen, element; for (element = 0; element < elements; element++) { thislen = __lcmtypes_state_t_decode_array(buf, offset + pos, maxlen - pos, &(p[element].state), 1); if (thislen < 0) return thislen; else pos += thislen; } return pos; } int __lcmtypes_vertex_t_decode_array_cleanup(lcmtypes_vertex_t *p, int elements) { int element; for (element = 0; element < elements; element++) { __lcmtypes_state_t_decode_array_cleanup(&(p[element].state), 1); } return 0; } int lcmtypes_vertex_t_decode(const void *buf, int offset, int maxlen, lcmtypes_vertex_t *p) { int pos = 0, thislen; int64_t hash = __lcmtypes_vertex_t_get_hash(); int64_t this_hash; thislen = __int64_t_decode_array(buf, offset + pos, maxlen - pos, &this_hash, 1); if (thislen < 0) return thislen; else pos += thislen; if (this_hash != hash) return -1; thislen = __lcmtypes_vertex_t_decode_array(buf, offset + pos, maxlen - pos, p, 1); if (thislen < 0) return thislen; else pos += thislen; return pos; } int lcmtypes_vertex_t_decode_cleanup(lcmtypes_vertex_t *p) { return __lcmtypes_vertex_t_decode_array_cleanup(p, 1); } int __lcmtypes_vertex_t_clone_array(const lcmtypes_vertex_t *p, lcmtypes_vertex_t *q, int elements) { int element; for (element = 0; element < elements; element++) { __lcmtypes_state_t_clone_array(&(p[element].state), &(q[element].state), 1); } return 0; } lcmtypes_vertex_t *lcmtypes_vertex_t_copy(const lcmtypes_vertex_t *p) { lcmtypes_vertex_t *q = (lcmtypes_vertex_t*) malloc(sizeof(lcmtypes_vertex_t)); __lcmtypes_vertex_t_clone_array(p, q, 1); return q; } void lcmtypes_vertex_t_destroy(lcmtypes_vertex_t *p) { __lcmtypes_vertex_t_decode_array_cleanup(p, 1); free(p); } int lcmtypes_vertex_t_publish(lcm_t *lc, const char *channel, const lcmtypes_vertex_t *p) { int max_data_size = lcmtypes_vertex_t_encoded_size (p); uint8_t *buf = (uint8_t*) malloc (max_data_size); if (!buf) return -1; int data_size = lcmtypes_vertex_t_encode (buf, 0, max_data_size, p); if (data_size < 0) { free (buf); return data_size; } int status = lcm_publish (lc, channel, buf, data_size); free (buf); return status; } struct _lcmtypes_vertex_t_subscription_t { lcmtypes_vertex_t_handler_t user_handler; void *userdata; lcm_subscription_t *lc_h; }; static void lcmtypes_vertex_t_handler_stub (const lcm_recv_buf_t *rbuf, const char *channel, void *userdata) { int status; lcmtypes_vertex_t p; memset(&p, 0, sizeof(lcmtypes_vertex_t)); status = lcmtypes_vertex_t_decode (rbuf->data, 0, rbuf->data_size, &p); if (status < 0) { fprintf (stderr, "error %d decoding lcmtypes_vertex_t!!!\n", status); return; } lcmtypes_vertex_t_subscription_t *h = (lcmtypes_vertex_t_subscription_t*) userdata; h->user_handler (rbuf, channel, &p, h->userdata); lcmtypes_vertex_t_decode_cleanup (&p); } lcmtypes_vertex_t_subscription_t* lcmtypes_vertex_t_subscribe (lcm_t *lcm, const char *channel, lcmtypes_vertex_t_handler_t f, void *userdata) { lcmtypes_vertex_t_subscription_t *n = (lcmtypes_vertex_t_subscription_t*) malloc(sizeof(lcmtypes_vertex_t_subscription_t)); n->user_handler = f; n->userdata = userdata; n->lc_h = lcm_subscribe (lcm, channel, lcmtypes_vertex_t_handler_stub, n); if (n->lc_h == NULL) { fprintf (stderr,"couldn't reg lcmtypes_vertex_t LCM handler!\n"); free (n); return NULL; } return n; } int lcmtypes_vertex_t_subscription_set_queue_capacity (lcmtypes_vertex_t_subscription_t* subs, int num_messages) { return lcm_subscription_set_queue_capacity (subs->lc_h, num_messages); } int lcmtypes_vertex_t_unsubscribe(lcm_t *lcm, lcmtypes_vertex_t_subscription_t* hid) { int status = lcm_unsubscribe (lcm, hid->lc_h); if (0 != status) { fprintf(stderr, "couldn't unsubscribe lcmtypes_vertex_t_handler %p!\n", hid); return -1; } free (hid); return 0; } ================================================ FILE: data_generation/lcmtypes/lcmtypes/c/lcmtypes/lcmtypes_vertex_t.h ================================================ // THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY // BY HAND!! // // Generated by lcm-gen #include #include #include #include #ifndef _lcmtypes_vertex_t_h #define _lcmtypes_vertex_t_h #ifdef __cplusplus extern "C" { #endif #include "lcmtypes/lcmtypes_state_t.h" typedef struct _lcmtypes_vertex_t lcmtypes_vertex_t; struct _lcmtypes_vertex_t { lcmtypes_state_t state; }; /** * Create a deep copy of a lcmtypes_vertex_t. * When no longer needed, destroy it with lcmtypes_vertex_t_destroy() */ lcmtypes_vertex_t* lcmtypes_vertex_t_copy(const lcmtypes_vertex_t* to_copy); /** * Destroy an instance of lcmtypes_vertex_t created by lcmtypes_vertex_t_copy() */ void lcmtypes_vertex_t_destroy(lcmtypes_vertex_t* to_destroy); /** * Identifies a single subscription. This is an opaque data type. */ typedef struct _lcmtypes_vertex_t_subscription_t lcmtypes_vertex_t_subscription_t; /** * Prototype for a callback function invoked when a message of type * lcmtypes_vertex_t is received. */ typedef void(*lcmtypes_vertex_t_handler_t)(const lcm_recv_buf_t *rbuf, const char *channel, const lcmtypes_vertex_t *msg, void *userdata); /** * Publish a message of type lcmtypes_vertex_t using LCM. * * @param lcm The LCM instance to publish with. * @param channel The channel to publish on. * @param msg The message to publish. * @return 0 on success, <0 on error. Success means LCM has transferred * responsibility of the message data to the OS. */ int lcmtypes_vertex_t_publish(lcm_t *lcm, const char *channel, const lcmtypes_vertex_t *msg); /** * Subscribe to messages of type lcmtypes_vertex_t using LCM. * * @param lcm The LCM instance to subscribe with. * @param channel The channel to subscribe to. * @param handler The callback function invoked by LCM when a message is received. * This function is invoked by LCM during calls to lcm_handle() and * lcm_handle_timeout(). * @param userdata An opaque pointer passed to @p handler when it is invoked. * @return 0 on success, <0 if an error occured */ lcmtypes_vertex_t_subscription_t* lcmtypes_vertex_t_subscribe(lcm_t *lcm, const char *channel, lcmtypes_vertex_t_handler_t handler, void *userdata); /** * Removes and destroys a subscription created by lcmtypes_vertex_t_subscribe() */ int lcmtypes_vertex_t_unsubscribe(lcm_t *lcm, lcmtypes_vertex_t_subscription_t* hid); /** * Sets the queue capacity for a subscription. * Some LCM providers (e.g., the default multicast provider) are implemented * using a background receive thread that constantly revceives messages from * the network. As these messages are received, they are buffered on * per-subscription queues until dispatched by lcm_handle(). This function * how many messages are queued before dropping messages. * * @param subs the subscription to modify. * @param num_messages The maximum number of messages to queue * on the subscription. * @return 0 on success, <0 if an error occured */ int lcmtypes_vertex_t_subscription_set_queue_capacity(lcmtypes_vertex_t_subscription_t* subs, int num_messages); /** * Encode a message of type lcmtypes_vertex_t into binary form. * * @param buf The output buffer. * @param offset Encoding starts at this byte offset into @p buf. * @param maxlen Maximum number of bytes to write. This should generally * be equal to lcmtypes_vertex_t_encoded_size(). * @param msg The message to encode. * @return The number of bytes encoded, or <0 if an error occured. */ int lcmtypes_vertex_t_encode(void *buf, int offset, int maxlen, const lcmtypes_vertex_t *p); /** * Decode a message of type lcmtypes_vertex_t from binary form. * When decoding messages containing strings or variable-length arrays, this * function may allocate memory. When finished with the decoded message, * release allocated resources with lcmtypes_vertex_t_decode_cleanup(). * * @param buf The buffer containing the encoded message * @param offset The byte offset into @p buf where the encoded message starts. * @param maxlen The maximum number of bytes to read while decoding. * @param msg Output parameter where the decoded message is stored * @return The number of bytes decoded, or <0 if an error occured. */ int lcmtypes_vertex_t_decode(const void *buf, int offset, int maxlen, lcmtypes_vertex_t *msg); /** * Release resources allocated by lcmtypes_vertex_t_decode() * @return 0 */ int lcmtypes_vertex_t_decode_cleanup(lcmtypes_vertex_t *p); /** * Check how many bytes are required to encode a message of type lcmtypes_vertex_t */ int lcmtypes_vertex_t_encoded_size(const lcmtypes_vertex_t *p); // LCM support functions. Users should not call these int64_t __lcmtypes_vertex_t_get_hash(void); uint64_t __lcmtypes_vertex_t_hash_recursive(const __lcm_hash_ptr *p); int __lcmtypes_vertex_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_vertex_t *p, int elements); int __lcmtypes_vertex_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_vertex_t *p, int elements); int __lcmtypes_vertex_t_decode_array_cleanup(lcmtypes_vertex_t *p, int elements); int __lcmtypes_vertex_t_encoded_array_size(const lcmtypes_vertex_t *p, int elements); int __lcmtypes_vertex_t_clone_array(const lcmtypes_vertex_t *p, lcmtypes_vertex_t *q, int elements); #ifdef __cplusplus } #endif #endif ================================================ FILE: data_generation/lcmtypes/lcmtypes/java/lcmtypes/edge_t.java ================================================ /* LCM type definition class file * This file was automatically generated by lcm-gen * DO NOT MODIFY BY HAND!!!! */ package lcmtypes; import java.io.*; import java.util.*; import lcm.lcm.*; public final class edge_t implements lcm.lcm.LCMEncodable { public lcmtypes.vertex_t vertex_src; public lcmtypes.vertex_t vertex_dst; public lcmtypes.trajectory_t trajectory; public edge_t() { } public static final long LCM_FINGERPRINT; public static final long LCM_FINGERPRINT_BASE = 0x1fae492d71eedf94L; static { LCM_FINGERPRINT = _hashRecursive(new ArrayList>()); } public static long _hashRecursive(ArrayList> classes) { if (classes.contains(lcmtypes.edge_t.class)) return 0L; classes.add(lcmtypes.edge_t.class); long hash = LCM_FINGERPRINT_BASE + lcmtypes.vertex_t._hashRecursive(classes) + lcmtypes.vertex_t._hashRecursive(classes) + lcmtypes.trajectory_t._hashRecursive(classes) ; classes.remove(classes.size() - 1); return (hash<<1) + ((hash>>63)&1); } public void encode(DataOutput outs) throws IOException { outs.writeLong(LCM_FINGERPRINT); _encodeRecursive(outs); } public void _encodeRecursive(DataOutput outs) throws IOException { this.vertex_src._encodeRecursive(outs); this.vertex_dst._encodeRecursive(outs); this.trajectory._encodeRecursive(outs); } public edge_t(byte[] data) throws IOException { this(new LCMDataInputStream(data)); } public edge_t(DataInput ins) throws IOException { if (ins.readLong() != LCM_FINGERPRINT) throw new IOException("LCM Decode error: bad fingerprint"); _decodeRecursive(ins); } public static lcmtypes.edge_t _decodeRecursiveFactory(DataInput ins) throws IOException { lcmtypes.edge_t o = new lcmtypes.edge_t(); o._decodeRecursive(ins); return o; } public void _decodeRecursive(DataInput ins) throws IOException { this.vertex_src = lcmtypes.vertex_t._decodeRecursiveFactory(ins); this.vertex_dst = lcmtypes.vertex_t._decodeRecursiveFactory(ins); this.trajectory = lcmtypes.trajectory_t._decodeRecursiveFactory(ins); } public lcmtypes.edge_t copy() { lcmtypes.edge_t outobj = new lcmtypes.edge_t(); outobj.vertex_src = this.vertex_src.copy(); outobj.vertex_dst = this.vertex_dst.copy(); outobj.trajectory = this.trajectory.copy(); return outobj; } } ================================================ FILE: data_generation/lcmtypes/lcmtypes/java/lcmtypes/environment_t.java ================================================ /* LCM type definition class file * This file was automatically generated by lcm-gen * DO NOT MODIFY BY HAND!!!! */ package lcmtypes; import java.io.*; import java.util.*; import lcm.lcm.*; public final class environment_t implements lcm.lcm.LCMEncodable { public lcmtypes.region_3d_t operating; public lcmtypes.region_3d_t goal; public int num_obstacles; public lcmtypes.region_3d_t obstacles[]; public environment_t() { } public static final long LCM_FINGERPRINT; public static final long LCM_FINGERPRINT_BASE = 0x8caabc2a2ba0f9c7L; static { LCM_FINGERPRINT = _hashRecursive(new ArrayList>()); } public static long _hashRecursive(ArrayList> classes) { if (classes.contains(lcmtypes.environment_t.class)) return 0L; classes.add(lcmtypes.environment_t.class); long hash = LCM_FINGERPRINT_BASE + lcmtypes.region_3d_t._hashRecursive(classes) + lcmtypes.region_3d_t._hashRecursive(classes) + lcmtypes.region_3d_t._hashRecursive(classes) ; classes.remove(classes.size() - 1); return (hash<<1) + ((hash>>63)&1); } public void encode(DataOutput outs) throws IOException { outs.writeLong(LCM_FINGERPRINT); _encodeRecursive(outs); } public void _encodeRecursive(DataOutput outs) throws IOException { this.operating._encodeRecursive(outs); this.goal._encodeRecursive(outs); outs.writeInt(this.num_obstacles); for (int a = 0; a < this.num_obstacles; a++) { this.obstacles[a]._encodeRecursive(outs); } } public environment_t(byte[] data) throws IOException { this(new LCMDataInputStream(data)); } public environment_t(DataInput ins) throws IOException { if (ins.readLong() != LCM_FINGERPRINT) throw new IOException("LCM Decode error: bad fingerprint"); _decodeRecursive(ins); } public static lcmtypes.environment_t _decodeRecursiveFactory(DataInput ins) throws IOException { lcmtypes.environment_t o = new lcmtypes.environment_t(); o._decodeRecursive(ins); return o; } public void _decodeRecursive(DataInput ins) throws IOException { this.operating = lcmtypes.region_3d_t._decodeRecursiveFactory(ins); this.goal = lcmtypes.region_3d_t._decodeRecursiveFactory(ins); this.num_obstacles = ins.readInt(); this.obstacles = new lcmtypes.region_3d_t[(int) num_obstacles]; for (int a = 0; a < this.num_obstacles; a++) { this.obstacles[a] = lcmtypes.region_3d_t._decodeRecursiveFactory(ins); } } public lcmtypes.environment_t copy() { lcmtypes.environment_t outobj = new lcmtypes.environment_t(); outobj.operating = this.operating.copy(); outobj.goal = this.goal.copy(); outobj.num_obstacles = this.num_obstacles; outobj.obstacles = new lcmtypes.region_3d_t[(int) num_obstacles]; for (int a = 0; a < this.num_obstacles; a++) { outobj.obstacles[a] = this.obstacles[a].copy(); } return outobj; } } ================================================ FILE: data_generation/lcmtypes/lcmtypes/java/lcmtypes/graph_t.java ================================================ /* LCM type definition class file * This file was automatically generated by lcm-gen * DO NOT MODIFY BY HAND!!!! */ package lcmtypes; import java.io.*; import java.util.*; import lcm.lcm.*; public final class graph_t implements lcm.lcm.LCMEncodable { public int num_vertices; public lcmtypes.vertex_t vertices[]; public int num_edges; public lcmtypes.edge_t edges[]; public graph_t() { } public static final long LCM_FINGERPRINT; public static final long LCM_FINGERPRINT_BASE = 0x49189ad7b639b453L; static { LCM_FINGERPRINT = _hashRecursive(new ArrayList>()); } public static long _hashRecursive(ArrayList> classes) { if (classes.contains(lcmtypes.graph_t.class)) return 0L; classes.add(lcmtypes.graph_t.class); long hash = LCM_FINGERPRINT_BASE + lcmtypes.vertex_t._hashRecursive(classes) + lcmtypes.edge_t._hashRecursive(classes) ; classes.remove(classes.size() - 1); return (hash<<1) + ((hash>>63)&1); } public void encode(DataOutput outs) throws IOException { outs.writeLong(LCM_FINGERPRINT); _encodeRecursive(outs); } public void _encodeRecursive(DataOutput outs) throws IOException { outs.writeInt(this.num_vertices); for (int a = 0; a < this.num_vertices; a++) { this.vertices[a]._encodeRecursive(outs); } outs.writeInt(this.num_edges); for (int a = 0; a < this.num_edges; a++) { this.edges[a]._encodeRecursive(outs); } } public graph_t(byte[] data) throws IOException { this(new LCMDataInputStream(data)); } public graph_t(DataInput ins) throws IOException { if (ins.readLong() != LCM_FINGERPRINT) throw new IOException("LCM Decode error: bad fingerprint"); _decodeRecursive(ins); } public static lcmtypes.graph_t _decodeRecursiveFactory(DataInput ins) throws IOException { lcmtypes.graph_t o = new lcmtypes.graph_t(); o._decodeRecursive(ins); return o; } public void _decodeRecursive(DataInput ins) throws IOException { this.num_vertices = ins.readInt(); this.vertices = new lcmtypes.vertex_t[(int) num_vertices]; for (int a = 0; a < this.num_vertices; a++) { this.vertices[a] = lcmtypes.vertex_t._decodeRecursiveFactory(ins); } this.num_edges = ins.readInt(); this.edges = new lcmtypes.edge_t[(int) num_edges]; for (int a = 0; a < this.num_edges; a++) { this.edges[a] = lcmtypes.edge_t._decodeRecursiveFactory(ins); } } public lcmtypes.graph_t copy() { lcmtypes.graph_t outobj = new lcmtypes.graph_t(); outobj.num_vertices = this.num_vertices; outobj.vertices = new lcmtypes.vertex_t[(int) num_vertices]; for (int a = 0; a < this.num_vertices; a++) { outobj.vertices[a] = this.vertices[a].copy(); } outobj.num_edges = this.num_edges; outobj.edges = new lcmtypes.edge_t[(int) num_edges]; for (int a = 0; a < this.num_edges; a++) { outobj.edges[a] = this.edges[a].copy(); } return outobj; } } ================================================ FILE: data_generation/lcmtypes/lcmtypes/java/lcmtypes/region_3d_t.java ================================================ /* LCM type definition class file * This file was automatically generated by lcm-gen * DO NOT MODIFY BY HAND!!!! */ package lcmtypes; import java.io.*; import java.util.*; import lcm.lcm.*; public final class region_3d_t implements lcm.lcm.LCMEncodable { public double center[]; public double size[]; public region_3d_t() { center = new double[3]; size = new double[3]; } public static final long LCM_FINGERPRINT; public static final long LCM_FINGERPRINT_BASE = 0x94830fc8d7404191L; static { LCM_FINGERPRINT = _hashRecursive(new ArrayList>()); } public static long _hashRecursive(ArrayList> classes) { if (classes.contains(lcmtypes.region_3d_t.class)) return 0L; classes.add(lcmtypes.region_3d_t.class); long hash = LCM_FINGERPRINT_BASE ; classes.remove(classes.size() - 1); return (hash<<1) + ((hash>>63)&1); } public void encode(DataOutput outs) throws IOException { outs.writeLong(LCM_FINGERPRINT); _encodeRecursive(outs); } public void _encodeRecursive(DataOutput outs) throws IOException { for (int a = 0; a < 3; a++) { outs.writeDouble(this.center[a]); } for (int a = 0; a < 3; a++) { outs.writeDouble(this.size[a]); } } public region_3d_t(byte[] data) throws IOException { this(new LCMDataInputStream(data)); } public region_3d_t(DataInput ins) throws IOException { if (ins.readLong() != LCM_FINGERPRINT) throw new IOException("LCM Decode error: bad fingerprint"); _decodeRecursive(ins); } public static lcmtypes.region_3d_t _decodeRecursiveFactory(DataInput ins) throws IOException { lcmtypes.region_3d_t o = new lcmtypes.region_3d_t(); o._decodeRecursive(ins); return o; } public void _decodeRecursive(DataInput ins) throws IOException { this.center = new double[(int) 3]; for (int a = 0; a < 3; a++) { this.center[a] = ins.readDouble(); } this.size = new double[(int) 3]; for (int a = 0; a < 3; a++) { this.size[a] = ins.readDouble(); } } public lcmtypes.region_3d_t copy() { lcmtypes.region_3d_t outobj = new lcmtypes.region_3d_t(); outobj.center = new double[(int) 3]; System.arraycopy(this.center, 0, outobj.center, 0, 3); outobj.size = new double[(int) 3]; System.arraycopy(this.size, 0, outobj.size, 0, 3); return outobj; } } ================================================ FILE: data_generation/lcmtypes/lcmtypes/java/lcmtypes/state_t.java ================================================ /* LCM type definition class file * This file was automatically generated by lcm-gen * DO NOT MODIFY BY HAND!!!! */ package lcmtypes; import java.io.*; import java.util.*; import lcm.lcm.*; public final class state_t implements lcm.lcm.LCMEncodable { public double x; public double y; public double z; public state_t() { } public static final long LCM_FINGERPRINT; public static final long LCM_FINGERPRINT_BASE = 0x573f2fdd2f76508fL; static { LCM_FINGERPRINT = _hashRecursive(new ArrayList>()); } public static long _hashRecursive(ArrayList> classes) { if (classes.contains(lcmtypes.state_t.class)) return 0L; classes.add(lcmtypes.state_t.class); long hash = LCM_FINGERPRINT_BASE ; classes.remove(classes.size() - 1); return (hash<<1) + ((hash>>63)&1); } public void encode(DataOutput outs) throws IOException { outs.writeLong(LCM_FINGERPRINT); _encodeRecursive(outs); } public void _encodeRecursive(DataOutput outs) throws IOException { outs.writeDouble(this.x); outs.writeDouble(this.y); outs.writeDouble(this.z); } public state_t(byte[] data) throws IOException { this(new LCMDataInputStream(data)); } public state_t(DataInput ins) throws IOException { if (ins.readLong() != LCM_FINGERPRINT) throw new IOException("LCM Decode error: bad fingerprint"); _decodeRecursive(ins); } public static lcmtypes.state_t _decodeRecursiveFactory(DataInput ins) throws IOException { lcmtypes.state_t o = new lcmtypes.state_t(); o._decodeRecursive(ins); return o; } public void _decodeRecursive(DataInput ins) throws IOException { this.x = ins.readDouble(); this.y = ins.readDouble(); this.z = ins.readDouble(); } public lcmtypes.state_t copy() { lcmtypes.state_t outobj = new lcmtypes.state_t(); outobj.x = this.x; outobj.y = this.y; outobj.z = this.z; return outobj; } } ================================================ FILE: data_generation/lcmtypes/lcmtypes/java/lcmtypes/trajectory_t.java ================================================ /* LCM type definition class file * This file was automatically generated by lcm-gen * DO NOT MODIFY BY HAND!!!! */ package lcmtypes; import java.io.*; import java.util.*; import lcm.lcm.*; public final class trajectory_t implements lcm.lcm.LCMEncodable { public int num_states; public lcmtypes.state_t states[]; public trajectory_t() { } public static final long LCM_FINGERPRINT; public static final long LCM_FINGERPRINT_BASE = 0x67039c5ec5ece44fL; static { LCM_FINGERPRINT = _hashRecursive(new ArrayList>()); } public static long _hashRecursive(ArrayList> classes) { if (classes.contains(lcmtypes.trajectory_t.class)) return 0L; classes.add(lcmtypes.trajectory_t.class); long hash = LCM_FINGERPRINT_BASE + lcmtypes.state_t._hashRecursive(classes) ; classes.remove(classes.size() - 1); return (hash<<1) + ((hash>>63)&1); } public void encode(DataOutput outs) throws IOException { outs.writeLong(LCM_FINGERPRINT); _encodeRecursive(outs); } public void _encodeRecursive(DataOutput outs) throws IOException { outs.writeInt(this.num_states); for (int a = 0; a < this.num_states; a++) { this.states[a]._encodeRecursive(outs); } } public trajectory_t(byte[] data) throws IOException { this(new LCMDataInputStream(data)); } public trajectory_t(DataInput ins) throws IOException { if (ins.readLong() != LCM_FINGERPRINT) throw new IOException("LCM Decode error: bad fingerprint"); _decodeRecursive(ins); } public static lcmtypes.trajectory_t _decodeRecursiveFactory(DataInput ins) throws IOException { lcmtypes.trajectory_t o = new lcmtypes.trajectory_t(); o._decodeRecursive(ins); return o; } public void _decodeRecursive(DataInput ins) throws IOException { this.num_states = ins.readInt(); this.states = new lcmtypes.state_t[(int) num_states]; for (int a = 0; a < this.num_states; a++) { this.states[a] = lcmtypes.state_t._decodeRecursiveFactory(ins); } } public lcmtypes.trajectory_t copy() { lcmtypes.trajectory_t outobj = new lcmtypes.trajectory_t(); outobj.num_states = this.num_states; outobj.states = new lcmtypes.state_t[(int) num_states]; for (int a = 0; a < this.num_states; a++) { outobj.states[a] = this.states[a].copy(); } return outobj; } } ================================================ FILE: data_generation/lcmtypes/lcmtypes/java/lcmtypes/vertex_t.java ================================================ /* LCM type definition class file * This file was automatically generated by lcm-gen * DO NOT MODIFY BY HAND!!!! */ package lcmtypes; import java.io.*; import java.util.*; import lcm.lcm.*; public final class vertex_t implements lcm.lcm.LCMEncodable { public lcmtypes.state_t state; public vertex_t() { } public static final long LCM_FINGERPRINT; public static final long LCM_FINGERPRINT_BASE = 0x780573746198cdacL; static { LCM_FINGERPRINT = _hashRecursive(new ArrayList>()); } public static long _hashRecursive(ArrayList> classes) { if (classes.contains(lcmtypes.vertex_t.class)) return 0L; classes.add(lcmtypes.vertex_t.class); long hash = LCM_FINGERPRINT_BASE + lcmtypes.state_t._hashRecursive(classes) ; classes.remove(classes.size() - 1); return (hash<<1) + ((hash>>63)&1); } public void encode(DataOutput outs) throws IOException { outs.writeLong(LCM_FINGERPRINT); _encodeRecursive(outs); } public void _encodeRecursive(DataOutput outs) throws IOException { this.state._encodeRecursive(outs); } public vertex_t(byte[] data) throws IOException { this(new LCMDataInputStream(data)); } public vertex_t(DataInput ins) throws IOException { if (ins.readLong() != LCM_FINGERPRINT) throw new IOException("LCM Decode error: bad fingerprint"); _decodeRecursive(ins); } public static lcmtypes.vertex_t _decodeRecursiveFactory(DataInput ins) throws IOException { lcmtypes.vertex_t o = new lcmtypes.vertex_t(); o._decodeRecursive(ins); return o; } public void _decodeRecursive(DataInput ins) throws IOException { this.state = lcmtypes.state_t._decodeRecursiveFactory(ins); } public lcmtypes.vertex_t copy() { lcmtypes.vertex_t outobj = new lcmtypes.vertex_t(); outobj.state = this.state.copy(); return outobj; } } ================================================ FILE: data_generation/lcmtypes/lcmtypes/lcmtypes_edge_t.lcm ================================================ package lcmtypes; struct edge_t { vertex_t vertex_src; vertex_t vertex_dst; trajectory_t trajectory; } ================================================ FILE: data_generation/lcmtypes/lcmtypes/lcmtypes_environment_t.lcm ================================================ package lcmtypes; struct environment_t { region_3d_t operating; region_3d_t goal; int32_t num_obstacles; region_3d_t obstacles[num_obstacles]; } ================================================ FILE: data_generation/lcmtypes/lcmtypes/lcmtypes_graph_t.lcm ================================================ package lcmtypes; struct graph_t { int32_t num_vertices; vertex_t vertices[num_vertices]; int32_t num_edges; edge_t edges[num_edges]; } ================================================ FILE: data_generation/lcmtypes/lcmtypes/lcmtypes_region_3d_t.lcm ================================================ package lcmtypes; struct region_3d_t { double center[3]; double size[3]; } ================================================ FILE: data_generation/lcmtypes/lcmtypes/lcmtypes_state_t.lcm ================================================ package lcmtypes; struct state_t { double x; double y; double z; } ================================================ FILE: data_generation/lcmtypes/lcmtypes/lcmtypes_trajectory_t.lcm ================================================ package lcmtypes; struct trajectory_t { int32_t num_states; state_t states[num_states]; } ================================================ FILE: data_generation/lcmtypes/lcmtypes/lcmtypes_vertex_t.lcm ================================================ package lcmtypes; struct vertex_t { state_t state; } ================================================ FILE: data_generation/lcmtypes/lcmtypes/python/lcmtypes/__init__.py ================================================ """LCM package __init__.py file This file automatically generated by lcm-gen. DO NOT MODIFY BY HAND!!!! """ from .environment_t import environment_t from .region_3d_t import region_3d_t from .trajectory_t import trajectory_t from .graph_t import graph_t from .edge_t import edge_t from .vertex_t import vertex_t from .state_t import state_t ================================================ FILE: data_generation/lcmtypes/lcmtypes/python/lcmtypes/edge_t.py ================================================ """LCM type definitions This file automatically generated by lcm. DO NOT MODIFY BY HAND!!!! """ try: import cStringIO.StringIO as BytesIO except ImportError: from io import BytesIO import struct import lcmtypes.trajectory_t import lcmtypes.vertex_t class edge_t(object): __slots__ = ["vertex_src", "vertex_dst", "trajectory"] def __init__(self): self.vertex_src = lcmtypes.vertex_t() self.vertex_dst = lcmtypes.vertex_t() self.trajectory = lcmtypes.trajectory_t() def encode(self): buf = BytesIO() buf.write(edge_t._get_packed_fingerprint()) self._encode_one(buf) return buf.getvalue() def _encode_one(self, buf): assert self.vertex_src._get_packed_fingerprint() == lcmtypes.vertex_t._get_packed_fingerprint() self.vertex_src._encode_one(buf) assert self.vertex_dst._get_packed_fingerprint() == lcmtypes.vertex_t._get_packed_fingerprint() self.vertex_dst._encode_one(buf) assert self.trajectory._get_packed_fingerprint() == lcmtypes.trajectory_t._get_packed_fingerprint() self.trajectory._encode_one(buf) def decode(data): if hasattr(data, 'read'): buf = data else: buf = BytesIO(data) if buf.read(8) != edge_t._get_packed_fingerprint(): raise ValueError("Decode error") return edge_t._decode_one(buf) decode = staticmethod(decode) def _decode_one(buf): self = edge_t() self.vertex_src = lcmtypes.vertex_t._decode_one(buf) self.vertex_dst = lcmtypes.vertex_t._decode_one(buf) self.trajectory = lcmtypes.trajectory_t._decode_one(buf) return self _decode_one = staticmethod(_decode_one) _hash = None def _get_hash_recursive(parents): if edge_t in parents: return 0 newparents = parents + [edge_t] tmphash = (0x1fae492d71eedf94+ lcmtypes.vertex_t._get_hash_recursive(newparents)+ lcmtypes.vertex_t._get_hash_recursive(newparents)+ lcmtypes.trajectory_t._get_hash_recursive(newparents)) & 0xffffffffffffffff tmphash = (((tmphash<<1)&0xffffffffffffffff) + (tmphash>>63)) & 0xffffffffffffffff return tmphash _get_hash_recursive = staticmethod(_get_hash_recursive) _packed_fingerprint = None def _get_packed_fingerprint(): if edge_t._packed_fingerprint is None: edge_t._packed_fingerprint = struct.pack(">Q", edge_t._get_hash_recursive([])) return edge_t._packed_fingerprint _get_packed_fingerprint = staticmethod(_get_packed_fingerprint) ================================================ FILE: data_generation/lcmtypes/lcmtypes/python/lcmtypes/environment_t.py ================================================ """LCM type definitions This file automatically generated by lcm. DO NOT MODIFY BY HAND!!!! """ try: import cStringIO.StringIO as BytesIO except ImportError: from io import BytesIO import struct import lcmtypes.region_3d_t class environment_t(object): __slots__ = ["operating", "goal", "num_obstacles", "obstacles"] def __init__(self): self.operating = lcmtypes.region_3d_t() self.goal = lcmtypes.region_3d_t() self.num_obstacles = 0 self.obstacles = [] def encode(self): buf = BytesIO() buf.write(environment_t._get_packed_fingerprint()) self._encode_one(buf) return buf.getvalue() def _encode_one(self, buf): assert self.operating._get_packed_fingerprint() == lcmtypes.region_3d_t._get_packed_fingerprint() self.operating._encode_one(buf) assert self.goal._get_packed_fingerprint() == lcmtypes.region_3d_t._get_packed_fingerprint() self.goal._encode_one(buf) buf.write(struct.pack(">i", self.num_obstacles)) for i0 in range(self.num_obstacles): assert self.obstacles[i0]._get_packed_fingerprint() == lcmtypes.region_3d_t._get_packed_fingerprint() self.obstacles[i0]._encode_one(buf) def decode(data): if hasattr(data, 'read'): buf = data else: buf = BytesIO(data) if buf.read(8) != environment_t._get_packed_fingerprint(): raise ValueError("Decode error") return environment_t._decode_one(buf) decode = staticmethod(decode) def _decode_one(buf): self = environment_t() self.operating = lcmtypes.region_3d_t._decode_one(buf) self.goal = lcmtypes.region_3d_t._decode_one(buf) self.num_obstacles = struct.unpack(">i", buf.read(4))[0] self.obstacles = [] for i0 in range(self.num_obstacles): self.obstacles.append(lcmtypes.region_3d_t._decode_one(buf)) return self _decode_one = staticmethod(_decode_one) _hash = None def _get_hash_recursive(parents): if environment_t in parents: return 0 newparents = parents + [environment_t] tmphash = (0x8caabc2a2ba0f9c7+ lcmtypes.region_3d_t._get_hash_recursive(newparents)+ lcmtypes.region_3d_t._get_hash_recursive(newparents)+ lcmtypes.region_3d_t._get_hash_recursive(newparents)) & 0xffffffffffffffff tmphash = (((tmphash<<1)&0xffffffffffffffff) + (tmphash>>63)) & 0xffffffffffffffff return tmphash _get_hash_recursive = staticmethod(_get_hash_recursive) _packed_fingerprint = None def _get_packed_fingerprint(): if environment_t._packed_fingerprint is None: environment_t._packed_fingerprint = struct.pack(">Q", environment_t._get_hash_recursive([])) return environment_t._packed_fingerprint _get_packed_fingerprint = staticmethod(_get_packed_fingerprint) ================================================ FILE: data_generation/lcmtypes/lcmtypes/python/lcmtypes/graph_t.py ================================================ """LCM type definitions This file automatically generated by lcm. DO NOT MODIFY BY HAND!!!! """ try: import cStringIO.StringIO as BytesIO except ImportError: from io import BytesIO import struct import lcmtypes.vertex_t import lcmtypes.edge_t class graph_t(object): __slots__ = ["num_vertices", "vertices", "num_edges", "edges"] def __init__(self): self.num_vertices = 0 self.vertices = [] self.num_edges = 0 self.edges = [] def encode(self): buf = BytesIO() buf.write(graph_t._get_packed_fingerprint()) self._encode_one(buf) return buf.getvalue() def _encode_one(self, buf): buf.write(struct.pack(">i", self.num_vertices)) for i0 in range(self.num_vertices): assert self.vertices[i0]._get_packed_fingerprint() == lcmtypes.vertex_t._get_packed_fingerprint() self.vertices[i0]._encode_one(buf) buf.write(struct.pack(">i", self.num_edges)) for i0 in range(self.num_edges): assert self.edges[i0]._get_packed_fingerprint() == lcmtypes.edge_t._get_packed_fingerprint() self.edges[i0]._encode_one(buf) def decode(data): if hasattr(data, 'read'): buf = data else: buf = BytesIO(data) if buf.read(8) != graph_t._get_packed_fingerprint(): raise ValueError("Decode error") return graph_t._decode_one(buf) decode = staticmethod(decode) def _decode_one(buf): self = graph_t() self.num_vertices = struct.unpack(">i", buf.read(4))[0] self.vertices = [] for i0 in range(self.num_vertices): self.vertices.append(lcmtypes.vertex_t._decode_one(buf)) self.num_edges = struct.unpack(">i", buf.read(4))[0] self.edges = [] for i0 in range(self.num_edges): self.edges.append(lcmtypes.edge_t._decode_one(buf)) return self _decode_one = staticmethod(_decode_one) _hash = None def _get_hash_recursive(parents): if graph_t in parents: return 0 newparents = parents + [graph_t] tmphash = (0x49189ad7b639b453+ lcmtypes.vertex_t._get_hash_recursive(newparents)+ lcmtypes.edge_t._get_hash_recursive(newparents)) & 0xffffffffffffffff tmphash = (((tmphash<<1)&0xffffffffffffffff) + (tmphash>>63)) & 0xffffffffffffffff return tmphash _get_hash_recursive = staticmethod(_get_hash_recursive) _packed_fingerprint = None def _get_packed_fingerprint(): if graph_t._packed_fingerprint is None: graph_t._packed_fingerprint = struct.pack(">Q", graph_t._get_hash_recursive([])) return graph_t._packed_fingerprint _get_packed_fingerprint = staticmethod(_get_packed_fingerprint) ================================================ FILE: data_generation/lcmtypes/lcmtypes/python/lcmtypes/region_3d_t.py ================================================ """LCM type definitions This file automatically generated by lcm. DO NOT MODIFY BY HAND!!!! """ try: import cStringIO.StringIO as BytesIO except ImportError: from io import BytesIO import struct class region_3d_t(object): __slots__ = ["center", "size"] def __init__(self): self.center = [ 0.0 for dim0 in range(3) ] self.size = [ 0.0 for dim0 in range(3) ] def encode(self): buf = BytesIO() buf.write(region_3d_t._get_packed_fingerprint()) self._encode_one(buf) return buf.getvalue() def _encode_one(self, buf): buf.write(struct.pack('>3d', *self.center[:3])) buf.write(struct.pack('>3d', *self.size[:3])) def decode(data): if hasattr(data, 'read'): buf = data else: buf = BytesIO(data) if buf.read(8) != region_3d_t._get_packed_fingerprint(): raise ValueError("Decode error") return region_3d_t._decode_one(buf) decode = staticmethod(decode) def _decode_one(buf): self = region_3d_t() self.center = struct.unpack('>3d', buf.read(24)) self.size = struct.unpack('>3d', buf.read(24)) return self _decode_one = staticmethod(_decode_one) _hash = None def _get_hash_recursive(parents): if region_3d_t in parents: return 0 tmphash = (0x94830fc8d7404191) & 0xffffffffffffffff tmphash = (((tmphash<<1)&0xffffffffffffffff) + (tmphash>>63)) & 0xffffffffffffffff return tmphash _get_hash_recursive = staticmethod(_get_hash_recursive) _packed_fingerprint = None def _get_packed_fingerprint(): if region_3d_t._packed_fingerprint is None: region_3d_t._packed_fingerprint = struct.pack(">Q", region_3d_t._get_hash_recursive([])) return region_3d_t._packed_fingerprint _get_packed_fingerprint = staticmethod(_get_packed_fingerprint) ================================================ FILE: data_generation/lcmtypes/lcmtypes/python/lcmtypes/state_t.py ================================================ """LCM type definitions This file automatically generated by lcm. DO NOT MODIFY BY HAND!!!! """ try: import cStringIO.StringIO as BytesIO except ImportError: from io import BytesIO import struct class state_t(object): __slots__ = ["x", "y", "z"] def __init__(self): self.x = 0.0 self.y = 0.0 self.z = 0.0 def encode(self): buf = BytesIO() buf.write(state_t._get_packed_fingerprint()) self._encode_one(buf) return buf.getvalue() def _encode_one(self, buf): buf.write(struct.pack(">ddd", self.x, self.y, self.z)) def decode(data): if hasattr(data, 'read'): buf = data else: buf = BytesIO(data) if buf.read(8) != state_t._get_packed_fingerprint(): raise ValueError("Decode error") return state_t._decode_one(buf) decode = staticmethod(decode) def _decode_one(buf): self = state_t() self.x, self.y, self.z = struct.unpack(">ddd", buf.read(24)) return self _decode_one = staticmethod(_decode_one) _hash = None def _get_hash_recursive(parents): if state_t in parents: return 0 tmphash = (0x573f2fdd2f76508f) & 0xffffffffffffffff tmphash = (((tmphash<<1)&0xffffffffffffffff) + (tmphash>>63)) & 0xffffffffffffffff return tmphash _get_hash_recursive = staticmethod(_get_hash_recursive) _packed_fingerprint = None def _get_packed_fingerprint(): if state_t._packed_fingerprint is None: state_t._packed_fingerprint = struct.pack(">Q", state_t._get_hash_recursive([])) return state_t._packed_fingerprint _get_packed_fingerprint = staticmethod(_get_packed_fingerprint) ================================================ FILE: data_generation/lcmtypes/lcmtypes/python/lcmtypes/trajectory_t.py ================================================ """LCM type definitions This file automatically generated by lcm. DO NOT MODIFY BY HAND!!!! """ try: import cStringIO.StringIO as BytesIO except ImportError: from io import BytesIO import struct import lcmtypes.state_t class trajectory_t(object): __slots__ = ["num_states", "states"] def __init__(self): self.num_states = 0 self.states = [] def encode(self): buf = BytesIO() buf.write(trajectory_t._get_packed_fingerprint()) self._encode_one(buf) return buf.getvalue() def _encode_one(self, buf): buf.write(struct.pack(">i", self.num_states)) for i0 in range(self.num_states): assert self.states[i0]._get_packed_fingerprint() == lcmtypes.state_t._get_packed_fingerprint() self.states[i0]._encode_one(buf) def decode(data): if hasattr(data, 'read'): buf = data else: buf = BytesIO(data) if buf.read(8) != trajectory_t._get_packed_fingerprint(): raise ValueError("Decode error") return trajectory_t._decode_one(buf) decode = staticmethod(decode) def _decode_one(buf): self = trajectory_t() self.num_states = struct.unpack(">i", buf.read(4))[0] self.states = [] for i0 in range(self.num_states): self.states.append(lcmtypes.state_t._decode_one(buf)) return self _decode_one = staticmethod(_decode_one) _hash = None def _get_hash_recursive(parents): if trajectory_t in parents: return 0 newparents = parents + [trajectory_t] tmphash = (0x67039c5ec5ece44f+ lcmtypes.state_t._get_hash_recursive(newparents)) & 0xffffffffffffffff tmphash = (((tmphash<<1)&0xffffffffffffffff) + (tmphash>>63)) & 0xffffffffffffffff return tmphash _get_hash_recursive = staticmethod(_get_hash_recursive) _packed_fingerprint = None def _get_packed_fingerprint(): if trajectory_t._packed_fingerprint is None: trajectory_t._packed_fingerprint = struct.pack(">Q", trajectory_t._get_hash_recursive([])) return trajectory_t._packed_fingerprint _get_packed_fingerprint = staticmethod(_get_packed_fingerprint) ================================================ FILE: data_generation/lcmtypes/lcmtypes/python/lcmtypes/vertex_t.py ================================================ """LCM type definitions This file automatically generated by lcm. DO NOT MODIFY BY HAND!!!! """ try: import cStringIO.StringIO as BytesIO except ImportError: from io import BytesIO import struct import lcmtypes.state_t class vertex_t(object): __slots__ = ["state"] def __init__(self): self.state = lcmtypes.state_t() def encode(self): buf = BytesIO() buf.write(vertex_t._get_packed_fingerprint()) self._encode_one(buf) return buf.getvalue() def _encode_one(self, buf): assert self.state._get_packed_fingerprint() == lcmtypes.state_t._get_packed_fingerprint() self.state._encode_one(buf) def decode(data): if hasattr(data, 'read'): buf = data else: buf = BytesIO(data) if buf.read(8) != vertex_t._get_packed_fingerprint(): raise ValueError("Decode error") return vertex_t._decode_one(buf) decode = staticmethod(decode) def _decode_one(buf): self = vertex_t() self.state = lcmtypes.state_t._decode_one(buf) return self _decode_one = staticmethod(_decode_one) _hash = None def _get_hash_recursive(parents): if vertex_t in parents: return 0 newparents = parents + [vertex_t] tmphash = (0x780573746198cdac+ lcmtypes.state_t._get_hash_recursive(newparents)) & 0xffffffffffffffff tmphash = (((tmphash<<1)&0xffffffffffffffff) + (tmphash>>63)) & 0xffffffffffffffff return tmphash _get_hash_recursive = staticmethod(_get_hash_recursive) _packed_fingerprint = None def _get_packed_fingerprint(): if vertex_t._packed_fingerprint is None: vertex_t._packed_fingerprint = struct.pack(">Q", vertex_t._get_hash_recursive([])) return vertex_t._packed_fingerprint _get_packed_fingerprint = staticmethod(_get_packed_fingerprint) ================================================ FILE: data_generation/lcmtypes/pod.xml ================================================ racecar_lcmtypes ================================================ FILE: data_generation/permute.cpp ================================================ // To generate obstacles permutation to generate new environments #include #include #include #include using namespace std; void combinationUtil(int arr[], int data[], int start, int end, int index, int r, int &count, int (&node)[77520][7]); // The main function that prints all combinations of size r // in arr[] of size n. This function mainly uses combinationUtil() void printCombination(int arr[], int n, int r) { // A temporary array to store all combination one by one int data[r]; int count=0; int node[77520][7]; //node[0]=0; //node[1]=0; // Print all combination using temprary array 'data[]' combinationUtil(arr, data, 0, n-1, 0, r, count, node); cout<<"count: "< Input Array data[] ---> Temporary array to store current combination start & end ---> Staring and Ending indexes in arr[] index ---> Current index in data[] r ---> Size of a combination to be printed */ void combinationUtil(int arr[], int data[], int start, int end, int index, int r, int &count, int (&node)[77520][7]) { // Current combination is ready to be printed, print it if (index == r) { int j=0; for (j=0; j= r-index" makes sure that including one element // at index will make a combination with remaining elements // at remaining positions int i=0; for (i=start; i<=end && end-i+1 >= r-index; i++) { data[index] = arr[i]; combinationUtil(arr, data, i+1, end, index+1, r, count, node); } } int main() { int arr[] = {0,1, 2, 3, 4, 5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; int r = 7; int n = sizeof(arr)/sizeof(arr[0]); printCombination(arr, n, r); } ================================================ FILE: data_generation/rrtstar/CMakeLists.txt ================================================ cmake_minimum_required(VERSION 2.6.0) # pull in the pods macros. See cmake/pods.cmake for documentation set(POD_NAME rrtstar) include(cmake/pods.cmake) find_package(PkgConfig REQUIRED) pkg_check_modules(LCM REQUIRED lcm) #tell cmake to build these subdirectories add_subdirectory(src) ================================================ FILE: data_generation/rrtstar/Makefile ================================================ # Default makefile distributed with pods version: 10.11.18 default_target: all # Default to a less-verbose build. If you want all the gory compiler output, # run "make VERBOSE=1" $(VERBOSE).SILENT: # Figure out where to build the software. # Use BUILD_PREFIX if it was passed in. # If not, search up to four parent directories for a 'build' directory. # Otherwise, use ./build. ifeq "$(BUILD_PREFIX)" "" BUILD_PREFIX=$(shell for pfx in .. ../.. ../../.. ../../../..; do d=`pwd`/$$pfx/build; \ if [ -d $$d ]; then echo $$d; exit 0; fi; done; echo `pwd`/build) endif # Default to a release build. If you want to enable debugging flags, run # "make BUILD_TYPE=Debug" ifeq "$(BUILD_TYPE)" "" BUILD_TYPE="Release" endif all: pod-build/Makefile $(MAKE) -C pod-build all install pod-build/Makefile: $(MAKE) configure .PHONY: configure configure: @echo "\nBUILD_PREFIX: $(BUILD_PREFIX)\n\n" # create the build directories if necessary @[ -d $(BUILD_PREFIX) ] || mkdir -p $(BUILD_PREFIX) || exit 1 @[ -d pod-build ] || mkdir pod-build || exit 1 @echo "$(BUILD_PREFIX)" > pod-build/build_prefix # run CMake to generate and configure the build scripts @cd pod-build && cmake -DCMAKE_INSTALL_PREFIX=$(BUILD_PREFIX) \ -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) .. clean: -if [ -e pod-build/install_manifest.txt ]; then rm -f `cat pod-build/install_manifest.txt`; fi -if [ -d pod-build ]; then $(MAKE) -C pod-build clean; rm -rf pod-build; fi ================================================ FILE: data_generation/rrtstar/cmake/pods.cmake ================================================ # Macros to simplify compliance with the pods build policies. # # To enable the macros, add the following lines to CMakeLists.txt: # set(POD_NAME ) # include(cmake/pods.cmake) # # If POD_NAME is not set, then the CMake source directory is used as POD_NAME # # Next, any of the following macros can be used. See the individual macro # definitions in this file for individual documentation. # # C/C++ # pods_install_headers(...) # pods_install_libraries(...) # pods_install_executables(...) # pods_install_pkg_config_file(...) # # pods_use_pkg_config_packages(...) # # Python # pods_install_python_packages(...) # pods_install_python_script(...) # # Java # None yet # # ---- # File: pods.cmake # Distributed with pods version: 10.11.18 # pods_install_headers( ... DESTINATION ) # # Install a (list) of header files. # # Header files will all be installed to include/ # # example: # add_library(perception detector.h sensor.h) # pods_install_headers(detector.h sensor.h DESTINATION perception) # function(pods_install_headers) list(GET ARGV -2 checkword) if(NOT checkword STREQUAL DESTINATION) message(FATAL_ERROR "pods_install_headers missing DESTINATION parameter") endif() list(GET ARGV -1 dest_dir) list(REMOVE_AT ARGV -1) list(REMOVE_AT ARGV -1) #copy the headers to the INCLUDE_OUTPUT_PATH (pod-build/include) foreach(header ${ARGV}) get_filename_component(_header_name ${header} NAME) configure_file(${header} ${INCLUDE_OUTPUT_PATH}/${dest_dir}/${_header_name} COPYONLY) endforeach(header) #mark them to be installed install(FILES ${ARGV} DESTINATION include/${dest_dir}) endfunction(pods_install_headers) # pods_install_executables( ...) # # Install a (list) of executables to bin/ function(pods_install_executables) install(TARGETS ${ARGV} RUNTIME DESTINATION bin) endfunction(pods_install_executables) # pods_install_libraries( ...) # # Install a (list) of libraries to lib/ function(pods_install_libraries) install(TARGETS ${ARGV} LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) endfunction(pods_install_libraries) # pods_install_pkg_config_file( # [VERSION ] # [DESCRIPTION ] # [CFLAGS ...] # [LIBS ...] # [REQUIRES ...]) # # Create and install a pkg-config .pc file. # # example: # add_library(mylib mylib.c) # pods_install_pkg_config_file(mylib LIBS -lmylib REQUIRES glib-2.0) function(pods_install_pkg_config_file) list(GET ARGV 0 pc_name) # TODO error check set(pc_version 0.0.1) set(pc_description ${pc_name}) set(pc_requires "") set(pc_libs "") set(pc_cflags "") set(pc_fname "${PKG_CONFIG_OUTPUT_PATH}/${pc_name}.pc") set(modewords LIBS CFLAGS REQUIRES VERSION DESCRIPTION) set(curmode "") # parse function arguments and populate pkg-config parameters list(REMOVE_AT ARGV 0) foreach(word ${ARGV}) list(FIND modewords ${word} mode_index) if(${mode_index} GREATER -1) set(curmode ${word}) elseif(curmode STREQUAL LIBS) set(pc_libs "${pc_libs} ${word}") elseif(curmode STREQUAL CFLAGS) set(pc_cflags "${pc_cflags} ${word}") elseif(curmode STREQUAL REQUIRES) set(pc_requires "${pc_requires} ${word}") elseif(curmode STREQUAL VERSION) set(pc_version ${word}) set(curmode "") elseif(curmode STREQUAL DESCRIPTION) set(pc_description "${word}") set(curmode "") else(${mode_index} GREATER -1) message("WARNING incorrect use of pods_add_pkg_config (${word})") break() endif(${mode_index} GREATER -1) endforeach(word) # write the .pc file out file(WRITE ${pc_fname} "prefix=${CMAKE_INSTALL_PREFIX}\n" "exec_prefix=\${prefix}\n" "libdir=\${exec_prefix}/lib\n" "includedir=\${prefix}/include\n" "\n" "Name: ${pc_name}\n" "Description: ${pc_description}\n" "Requires: ${pc_requires}\n" "Version: ${pc_version}\n" "Libs: -L\${exec_prefix}/lib ${pc_libs}\n" "Cflags: ${pc_cflags}\n") # mark the .pc file for installation to the lib/pkgconfig directory install(FILES ${pc_fname} DESTINATION lib/pkgconfig) # find targets that this pkg-config file depends on string(REPLACE " " ";" split_lib ${pc_libs}) foreach(lib ${split_lib}) string(REGEX REPLACE "^-l" "" libname ${lib}) get_target_property(IS_TARGET ${libname} LOCATION) if (NOT IS_TARGET STREQUAL "IS_TARGET-NOTFOUND") set_property(GLOBAL APPEND PROPERTY "PODS_PKG_CONFIG_TARGETS-${pc_name}" ${libname}) endif() endforeach() endfunction(pods_install_pkg_config_file) # pods_install_python_script( ) # # Create and install a script that invokes the python interpreter with a # specified module. # # A script will be installed to bin/. The script simply # adds /lib/pythonX.Y/site-packages to the python path, and # then invokes `python -m `. # # example: # pods_install_python_script(run-pdb pdb) function(pods_install_python_script script_name py_module) find_package(PythonInterp REQUIRED) # which python version? execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(sys.version[:3])" OUTPUT_VARIABLE pyversion) # where do we install .py files to? set(python_install_dir ${CMAKE_INSTALL_PREFIX}/lib/python${pyversion}/site-packages) # write the script file file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${script_name} "#!/bin/sh\n" "export PYTHONPATH=${python_install_dir}:\${PYTHONPATH}\n" "exec ${PYTHON_EXECUTABLE} -m ${py_module} $*\n") # install it... install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${script_name} DESTINATION bin) endfunction() # pods_install_python_packages() # # Install python packages to lib/pythonX.Y/site-packages, where X.Y refers to # the current python version (e.g., 2.6) # # Recursively searches for .py files, byte-compiles them, and # installs them function(pods_install_python_packages py_src_dir) find_package(PythonInterp REQUIRED) # which python version? execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(sys.version[:3])" OUTPUT_VARIABLE pyversion) # where do we install .py files to? set(python_install_dir ${CMAKE_INSTALL_PREFIX}/lib/python${pyversion}/site-packages) if(ARGC GREATER 1) message(FATAL_ERROR "NYI") else() # get a list of all .py files file(GLOB_RECURSE py_files RELATIVE ${py_src_dir} ${py_src_dir}/*.py) # add rules for byte-compiling .py --> .pyc foreach(py_file ${py_files}) get_filename_component(py_dirname ${py_file} PATH) add_custom_command(OUTPUT "${py_src_dir}/${py_file}c" COMMAND ${PYTHON_EXECUTABLE} -m py_compile ${py_src_dir}/${py_file} DEPENDS ${py_src_dir}/${py_file}) list(APPEND pyc_files "${py_src_dir}/${py_file}c") # install python file and byte-compiled file install(FILES ${py_src_dir}/${py_file} ${py_src_dir}/${py_file}c DESTINATION "${python_install_dir}/${py_dirname}") # message("${py_src_dir}/${py_file} -> ${python_install_dir}/${py_dirname}") endforeach() string(REGEX REPLACE "[^a-zA-Z0-9]" "_" san_src_dir "${py_src_dir}") add_custom_target("pyc_${san_src_dir}" ALL DEPENDS ${pyc_files}) endif() endfunction() # pods_use_pkg_config_packages( ...) # # Convenience macro to get compiler and linker flags from pkg-config and apply them # to the specified target. # # Invokes `pkg-config --cflags-only-I ...` and adds the result to the # include directories. # # Additionally, invokes `pkg-config --libs ...` and adds the result to # the target's link flags (via target_link_libraries) # # example: # add_executable(myprogram main.c) # pods_use_pkg_config_packages(myprogram glib-2.0 opencv) macro(pods_use_pkg_config_packages target) if(${ARGC} LESS 2) message(WARNING "Useless invocation of pods_use_pkg_config_packages") return() endif() find_package(PkgConfig REQUIRED) execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --cflags-only-I ${ARGN} OUTPUT_VARIABLE _pods_pkg_include_flags) string(STRIP ${_pods_pkg_include_flags} _pods_pkg_include_flags) string(REPLACE "-I" "" _pods_pkg_include_flags "${_pods_pkg_include_flags}") separate_arguments(_pods_pkg_include_flags) # message("include: ${_pods_pkg_include_flags}") execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --libs ${ARGN} OUTPUT_VARIABLE _pods_pkg_ldflags) string(STRIP ${_pods_pkg_ldflags} _pods_pkg_ldflags) # message("ldflags: ${_pods_pkg_ldflags}") include_directories(${_pods_pkg_include_flags}) target_link_libraries(${target} ${_pods_pkg_ldflags}) # make the target depend on libraries being installed by this source build foreach(_pkg ${ARGN}) get_property(_has_dependencies GLOBAL PROPERTY "PODS_PKG_CONFIG_TARGETS-${_pkg}" SET) if(_has_dependencies) get_property(_dependencies GLOBAL PROPERTY "PODS_PKG_CONFIG_TARGETS-${_pkg}") add_dependencies(${target} ${_dependencies}) # message("Found dependencies for ${_pkg}: ${dependencies}") endif() unset(_has_dependencies) unset(_dependencies) endforeach() unset(_pods_pkg_include_flags) unset(_pods_pkg_ldflags) endmacro() # pods_config_search_paths() # # Setup include, linker, and pkg-config paths according to the pods core # policy. This macro is automatically invoked, there is no need to do so # manually. macro(pods_config_search_paths) if(NOT DEFINED __pods_setup) #set where files should be output locally set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/pod-build/lib) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/pod-build/bin) set(INCLUDE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/pod-build/include) set(PKG_CONFIG_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/pod-build/lib/pkgconfig) #set where files should be installed to set(LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib) set(EXECUTABLE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/bin) set(INCLUDE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/include) set(PKG_CONFIG_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) # add build/lib/pkgconfig to the pkg-config search path set(ENV{PKG_CONFIG_PATH} ${PKG_CONFIG_INSTALL_PATH}:$ENV{PKG_CONFIG_PATH}) set(ENV{PKG_CONFIG_PATH} ${PKG_CONFIG_OUTPUT_PATH}:$ENV{PKG_CONFIG_PATH}) # add build/include to the compiler include path include_directories(${INCLUDE_INSTALL_PATH}) include_directories(${INCLUDE_OUTPUT_PATH}) # add build/lib to the link path link_directories(${LIBRARY_INSTALL_PATH}) link_directories(${LIBRARY_OUTPUT_PATH}) # abuse RPATH if(${CMAKE_INSTALL_RPATH}) set(CMAKE_INSTALL_RPATH ${LIBRARY_INSTALL_PATH}:${CMAKE_INSTALL_RPATH}) else(${CMAKE_INSTALL_RPATH}) set(CMAKE_INSTALL_RPATH ${LIBRARY_INSTALL_PATH}) endif(${CMAKE_INSTALL_RPATH}) # for osx, which uses "install name" path rather than rpath #set(CMAKE_INSTALL_NAME_DIR ${LIBRARY_OUTPUT_PATH}) set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_RPATH}) # hack to force cmake always create install and clean targets install(FILES DESTINATION) add_custom_target(tmp) set(__pods_setup true) endif(NOT DEFINED __pods_setup) endmacro(pods_config_search_paths) macro(enforce_out_of_source) if(CMAKE_BINARY_DIR STREQUAL PROJECT_SOURCE_DIR) message(FATAL_ERROR "\n Do not run cmake directly in the pod directory. use the supplied Makefile instead! You now need to remove CMakeCache.txt and the CMakeFiles directory. Then to build, simply type: $ make ") endif() endmacro(enforce_out_of_source) #set the variable POD_NAME to the directory path, and set the cmake PROJECT_NAME if(NOT POD_NAME) get_filename_component(POD_NAME ${CMAKE_SOURCE_DIR} NAME) message(STATUS "POD_NAME is not set... Defaulting to directory name: ${POD_NAME}") endif(NOT POD_NAME) project(${POD_NAME}) #make sure we're running an out-of-source build enforce_out_of_source() #call the function to setup paths pods_config_search_paths() ================================================ FILE: data_generation/rrtstar/doxy/doxy.conf ================================================ # Doxyfile 1.7.2 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" "). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = RRT* # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = ./doc # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given extension. # Doxygen has a built-in mapping, but you can override or extend it using this # tag. The format is ext=language, where ext is a file extension, and language # is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, # C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make # doxygen treat .inc files as Fortran files (default is PHP), and .f files as C # (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions # you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. EXTENSION_MAPPING = # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate getter # and setter methods for a property. Setting this option to YES (the default) # will make doxygen replace the get and set methods by a property in the # documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penality. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will roughly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols SYMBOL_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespaces are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen # will list include files with double quotes in the documentation # rather than with sharp brackets. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen # will sort the (brief and detailed) documentation of class members so that # constructors and destructors are listed first. If set to NO (the default) # the constructors will appear in the respective orders defined by # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or macro consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and macros in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. The create the layout file # that represents doxygen's defaults, run doxygen with the -l option. # You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. LAYOUT_FILE = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # The WARN_NO_PARAMDOC option can be enabled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = ./src # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py # *.f90 *.f *.vhd *.vhdl FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = ./src/kdtree.c ./src/kdtree.h # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the stylesheet and background images # according to this color. Hue is specified as an angle on a colorwheel, # see http://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of # the colors in the HTML output. For a value of 0 the output will use # grayscales only. A value of 255 will produce the most vivid colors. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to # the luminance component of the colors in the HTML output. Values below # 100 gradually make the output lighter, whereas values above 100 make # the output darker. The value divided by 100 is the actual gamma applied, # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, # and 100 does not change the gamma. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. HTML_TIMESTAMP = YES # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated # that can be used as input for Qt's qhelpgenerator to generate a # Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to # add. For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see # # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's # filter section matches. # # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files # will be generated, which together with the HTML files, form an Eclipse help # plugin. To install this plugin and make it available under the help contents # menu in Eclipse, the contents of the directory containing the HTML and XML # files needs to be copied into the plugins directory of eclipse. The name of # the directory within the plugins directory should be the same as # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. GENERATE_ECLIPSEHELP = NO # A unique identifier for the eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have # this name. ECLIPSE_DOC_ID = org.doxygen.Project # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [0,1..20]) # that doxygen will group on one line in the generated HTML documentation. # Note that a value of 0 will completely suppress the enum values from appearing in the overview section. ENUM_VALUES_PER_LINE = 4 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). # Windows users are probably better off using the HTML help feature. GENERATE_TREEVIEW = NO # By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list. USE_INLINE_TREES = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open # links to external symbols imported via tag files in a separate window. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are # not supported properly for IE 6.0, but are supported on all modern browsers. # Note that when changing this option you need to delete any form_*.png files # in the HTML output before the changes have effect. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax # (see http://www.mathjax.org) which uses client side Javascript for the # rendering instead of using prerendered bitmaps. Use this if you do not # have LaTeX installed or if you want to formulas look prettier in the HTML # output. When enabled you also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO # When MathJax is enabled you need to specify the location relative to the # HTML output directory using the MATHJAX_RELPATH option. The destination # directory should contain the MathJax.js script. For instance, if the mathjax # directory is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to the mathjax.org site, so you can quickly see the result without installing # MathJax, but it is strongly recommended to install a local copy of MathJax # before deployment. MATHJAX_RELPATH = http://www.mathjax.org/mathjax # When the SEARCHENGINE tag is enabled doxygen will generate a search box # for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets # (GENERATE_DOCSET) there is already a search function so this one should # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a PHP enabled web server instead of at the web client # using Javascript. Doxygen will generate the search PHP script and index # file to put on the web server. The advantage of the server # based approach is that it scales better to large projects and allows # full text search. The disadvantages are that it is more difficult to setup # and does not have live searching capabilities. SERVER_BASED_SEARCH = NO #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = YES # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. # Note that when enabling USE_PDFLATEX this option is only used for # generating bitmaps for formulas in the HTML output, but not in the # Makefile that is written to the output directory. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4 # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include # source code with syntax highlighting in the LaTeX output. # Note that which sources are shown also depends on other settings # such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option also works with HAVE_DOT disabled, but it is recommended to # install and use dot, since it yields more powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is # allowed to run in parallel. When set to 0 (the default) doxygen will # base this on the number of processors available in the system. You can set it # explicitly to a value larger than 0 to get control over the balance # between CPU load and processing speed. DOT_NUM_THREADS = 0 # By default doxygen will write a font called FreeSans.ttf to the output # directory and reference it in all dot files that doxygen generates. This # font does not include all possible unicode characters however, so when you need # these (or just want a differently looking font) you can specify the font name # using DOT_FONTNAME. You need need to make sure dot is able to find the font, # which can be done by putting it in a standard location or by setting the # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. DOT_FONTNAME = FreeSans.ttf # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the output directory to look for the # FreeSans.ttf font (which doxygen will put there itself). If you specify a # different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will generate a graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif. # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the # \mscfile command). MSCFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES ================================================ FILE: data_generation/rrtstar/src/CMakeLists.txt ================================================ SET(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/opt/local/lib/pkgconfig:/usr/local/share/pkgconfig") pods_install_pkg_config_file(rrtstar CFLAGS LIBS -lrrtstar REQUIRES lcmtypes VERSION 0.0.1) include_directories( ${LCM_INCLUDE_DIRS}) add_executable(rrtstar rrts_main.cpp system_single_integrator.cpp kdtree.c) pods_use_pkg_config_packages(rrtstar bot2-core lcmtypes) pods_install_executables(rrtstar) target_link_libraries(rrtstar -llcm) ================================================ FILE: data_generation/rrtstar/src/CMakeLists.txt~ ================================================ SET(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/opt/local/lib/pkgconfig:/usr/local/share/pkgconfig") pods_install_pkg_config_file(rrtstar CFLAGS LIBS -lrrtstar REQUIRES lcmtypes VERSION 0.0.1) include_directories( ${LCM_INCLUDE_DIRS}) add_executable(rrtstar rrts_main.cpp system_single_integrator.cpp kdtree.c) pods_use_pkg_config_packages(rrtstar bot2-core lcmtypes) pods_install_executables(rrtstar) ================================================ FILE: data_generation/rrtstar/src/kdtree.c ================================================ /* This file is part of ``kdtree'', a library for working with kd-trees. Copyright (C) 2007-2009 John Tsiombikas Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* single nearest neighbor search written by Tamas Nepusz */ #include #include #include #include #include "kdtree.h" #if defined(WIN32) || defined(__WIN32__) #include #endif #ifdef USE_LIST_NODE_ALLOCATOR #ifndef NO_PTHREADS #include #else #ifndef I_WANT_THREAD_BUGS #error "You are compiling with the fast list node allocator, with pthreads disabled! This WILL break if used from multiple threads." #endif /* I want thread bugs */ #endif /* pthread support */ #endif /* use list node allocator */ struct kdhyperrect { int dim; double *min, *max; /* minimum/maximum coords */ }; struct kdnode { double *pos; int dir; void *data; struct kdnode *left, *right; /* negative/positive side */ }; struct res_node { struct kdnode *item; double dist_sq; struct res_node *next; }; struct kdtree { int dim; struct kdnode *root; struct kdhyperrect *rect; void (*destr)(void*); }; struct kdres { struct kdtree *tree; struct res_node *rlist, *riter; int size; }; #define SQ(x) ((x) * (x)) static void clear_rec(struct kdnode *node, void (*destr)(void*)); static int insert_rec(struct kdnode **node, const double *pos, void *data, int dir, int dim); static int rlist_insert(struct res_node *list, struct kdnode *item, double dist_sq); static void clear_results(struct kdres *set); static struct kdhyperrect* hyperrect_create(int dim, const double *min, const double *max); static void hyperrect_free(struct kdhyperrect *rect); static struct kdhyperrect* hyperrect_duplicate(const struct kdhyperrect *rect); static void hyperrect_extend(struct kdhyperrect *rect, const double *pos); static double hyperrect_dist_sq(struct kdhyperrect *rect, const double *pos); #ifdef USE_LIST_NODE_ALLOCATOR static struct res_node *alloc_resnode(void); static void free_resnode(struct res_node*); #else #define alloc_resnode() malloc(sizeof(struct res_node)) #define free_resnode(n) free(n) #endif struct kdtree *kd_create(int k) { struct kdtree *tree; if(!(tree = malloc(sizeof *tree))) { return 0; } tree->dim = k; tree->root = 0; tree->destr = 0; tree->rect = 0; return tree; } void kd_free(struct kdtree *tree) { if(tree) { kd_clear(tree); free(tree); } } static void clear_rec(struct kdnode *node, void (*destr)(void*)) { if(!node) return; clear_rec(node->left, destr); clear_rec(node->right, destr); if(destr) { destr(node->data); } free(node->pos); free(node); } void kd_clear(struct kdtree *tree) { clear_rec(tree->root, tree->destr); tree->root = 0; if (tree->rect) { hyperrect_free(tree->rect); tree->rect = 0; } } void kd_data_destructor(struct kdtree *tree, void (*destr)(void*)) { tree->destr = destr; } static int insert_rec(struct kdnode **nptr, const double *pos, void *data, int dir, int dim) { int new_dir; struct kdnode *node; if(!*nptr) { if(!(node = malloc(sizeof *node))) { return -1; } if(!(node->pos = malloc(dim * sizeof *node->pos))) { free(node); return -1; } memcpy(node->pos, pos, dim * sizeof *node->pos); node->data = data; node->dir = dir; node->left = node->right = 0; *nptr = node; return 0; } node = *nptr; new_dir = (node->dir + 1) % dim; if(pos[node->dir] < node->pos[node->dir]) { return insert_rec(&(*nptr)->left, pos, data, new_dir, dim); } return insert_rec(&(*nptr)->right, pos, data, new_dir, dim); } int kd_insert(struct kdtree *tree, const double *pos, void *data) { if (insert_rec(&tree->root, pos, data, 0, tree->dim)) { return -1; } if (tree->rect == 0) { tree->rect = hyperrect_create(tree->dim, pos, pos); } else { hyperrect_extend(tree->rect, pos); } return 0; } int kd_insertf(struct kdtree *tree, const float *pos, void *data) { static double sbuf[16]; double *bptr, *buf = 0; int res, dim = tree->dim; if(dim > 16) { #ifndef NO_ALLOCA if(dim <= 256) bptr = buf = alloca(dim * sizeof *bptr); else #endif if(!(bptr = buf = malloc(dim * sizeof *bptr))) { return -1; } } else { bptr = sbuf; } while(dim-- > 0) { *bptr++ = *pos++; } res = kd_insert(tree, buf, data); #ifndef NO_ALLOCA if(tree->dim > 256) #else if(tree->dim > 16) #endif free(buf); return res; } int kd_insert3(struct kdtree *tree, double x, double y, double z, void *data) { double buf[3]; buf[0] = x; buf[1] = y; buf[2] = z; return kd_insert(tree, buf, data); } int kd_insert3f(struct kdtree *tree, float x, float y, float z, void *data) { double buf[3]; buf[0] = x; buf[1] = y; buf[2] = z; return kd_insert(tree, buf, data); } static int find_nearest(struct kdnode *node, const double *pos, double range, struct res_node *list, int ordered, int dim) { double dist_sq, dx; int i, ret, added_res = 0; if(!node) return 0; dist_sq = 0; for(i=0; ipos[i] - pos[i]); } if(dist_sq <= SQ(range)) { if(rlist_insert(list, node, ordered ? dist_sq : -1.0) == -1) { return -1; } added_res = 1; } dx = pos[node->dir] - node->pos[node->dir]; ret = find_nearest(dx <= 0.0 ? node->left : node->right, pos, range, list, ordered, dim); if(ret >= 0 && fabs(dx) < range) { added_res += ret; ret = find_nearest(dx <= 0.0 ? node->right : node->left, pos, range, list, ordered, dim); } if(ret == -1) { return -1; } added_res += ret; return added_res; } static void kd_nearest_i(struct kdnode *node, const double *pos, struct kdnode **result, double *result_dist_sq, struct kdhyperrect* rect) { int dir = node->dir; int i, side; double dummy, dist_sq; struct kdnode *nearer_subtree, *farther_subtree; double *nearer_hyperrect_coord, *farther_hyperrect_coord; /* Decide whether to go left or right in the tree */ dummy = pos[dir] - node->pos[dir]; if (dummy <= 0) { nearer_subtree = node->left; farther_subtree = node->right; nearer_hyperrect_coord = rect->max + dir; farther_hyperrect_coord = rect->min + dir; side = 0; } else { nearer_subtree = node->right; farther_subtree = node->left; nearer_hyperrect_coord = rect->min + dir; farther_hyperrect_coord = rect->max + dir; side = 1; } if (nearer_subtree) { /* Slice the hyperrect to get the hyperrect of the nearer subtree */ dummy = *nearer_hyperrect_coord; *nearer_hyperrect_coord = node->pos[dir]; /* Recurse down into nearer subtree */ kd_nearest_i(nearer_subtree, pos, result, result_dist_sq, rect); /* Undo the slice */ *nearer_hyperrect_coord = dummy; } /* Check the distance of the point at the current node, compare it * with our best so far */ dist_sq = 0; for(i=0; i < rect->dim; i++) { dist_sq += SQ(node->pos[i] - pos[i]); } if (dist_sq < *result_dist_sq) { *result = node; *result_dist_sq = dist_sq; } if (farther_subtree) { /* Get the hyperrect of the farther subtree */ dummy = *farther_hyperrect_coord; *farther_hyperrect_coord = node->pos[dir]; /* Check if we have to recurse down by calculating the closest * point of the hyperrect and see if it's closer than our * minimum distance in result_dist_sq. */ if (hyperrect_dist_sq(rect, pos) < *result_dist_sq) { /* Recurse down into farther subtree */ kd_nearest_i(farther_subtree, pos, result, result_dist_sq, rect); } /* Undo the slice on the hyperrect */ *farther_hyperrect_coord = dummy; } } struct kdres *kd_nearest(struct kdtree *kd, const double *pos) { struct kdhyperrect *rect; struct kdnode *result; struct kdres *rset; double dist_sq; int i; if (!kd) return 0; if (!kd->rect) return 0; /* Allocate result set */ if(!(rset = malloc(sizeof *rset))) { return 0; } if(!(rset->rlist = alloc_resnode())) { free(rset); return 0; } rset->rlist->next = 0; rset->tree = kd; /* Duplicate the bounding hyperrectangle, we will work on the copy */ if (!(rect = hyperrect_duplicate(kd->rect))) { kd_res_free(rset); return 0; } /* Our first guesstimate is the root node */ result = kd->root; dist_sq = 0; for (i = 0; i < kd->dim; i++) dist_sq += SQ(result->pos[i] - pos[i]); /* Search for the nearest neighbour recursively */ kd_nearest_i(kd->root, pos, &result, &dist_sq, rect); /* Free the copy of the hyperrect */ hyperrect_free(rect); /* Store the result */ if (result) { if (rlist_insert(rset->rlist, result, -1.0) == -1) { kd_res_free(rset); return 0; } rset->size = 1; kd_res_rewind(rset); return rset; } else { kd_res_free(rset); return 0; } } struct kdres *kd_nearestf(struct kdtree *tree, const float *pos) { static double sbuf[16]; double *bptr, *buf = 0; int dim = tree->dim; struct kdres *res; if(dim > 16) { #ifndef NO_ALLOCA if(dim <= 256) bptr = buf = alloca(dim * sizeof *bptr); else #endif if(!(bptr = buf = malloc(dim * sizeof *bptr))) { return 0; } } else { bptr = sbuf; } while(dim-- > 0) { *bptr++ = *pos++; } res = kd_nearest(tree, buf); #ifndef NO_ALLOCA if(tree->dim > 256) #else if(tree->dim > 16) #endif free(buf); return res; } struct kdres *kd_nearest3(struct kdtree *tree, double x, double y, double z) { double pos[3]; pos[0] = x; pos[1] = y; pos[2] = z; return kd_nearest(tree, pos); } struct kdres *kd_nearest3f(struct kdtree *tree, float x, float y, float z) { double pos[3]; pos[0] = x; pos[1] = y; pos[2] = z; return kd_nearest(tree, pos); } struct kdres *kd_nearest_range(struct kdtree *kd, const double *pos, double range) { int ret; struct kdres *rset; if(!(rset = malloc(sizeof *rset))) { return 0; } if(!(rset->rlist = alloc_resnode())) { free(rset); return 0; } rset->rlist->next = 0; rset->tree = kd; if((ret = find_nearest(kd->root, pos, range, rset->rlist, 0, kd->dim)) == -1) { kd_res_free(rset); return 0; } rset->size = ret; kd_res_rewind(rset); return rset; } struct kdres *kd_nearest_rangef(struct kdtree *kd, const float *pos, float range) { static double sbuf[16]; double *bptr, *buf = 0; int dim = kd->dim; struct kdres *res; if(dim > 16) { #ifndef NO_ALLOCA if(dim <= 256) bptr = buf = alloca(dim * sizeof *bptr); else #endif if(!(bptr = buf = malloc(dim * sizeof *bptr))) { return 0; } } else { bptr = sbuf; } while(dim-- > 0) { *bptr++ = *pos++; } res = kd_nearest_range(kd, buf, range); #ifndef NO_ALLOCA if(kd->dim > 256) #else if(kd->dim > 16) #endif free(buf); return res; } struct kdres *kd_nearest_range3(struct kdtree *tree, double x, double y, double z, double range) { double buf[3]; buf[0] = x; buf[1] = y; buf[2] = z; return kd_nearest_range(tree, buf, range); } struct kdres *kd_nearest_range3f(struct kdtree *tree, float x, float y, float z, float range) { double buf[3]; buf[0] = x; buf[1] = y; buf[2] = z; return kd_nearest_range(tree, buf, range); } void kd_res_free(struct kdres *rset) { clear_results(rset); free_resnode(rset->rlist); free(rset); } int kd_res_size(struct kdres *set) { return (set->size); } void kd_res_rewind(struct kdres *rset) { rset->riter = rset->rlist->next; } int kd_res_end(struct kdres *rset) { return rset->riter == 0; } int kd_res_next(struct kdres *rset) { rset->riter = rset->riter->next; return rset->riter != 0; } void *kd_res_item(struct kdres *rset, double *pos) { if(rset->riter) { if(pos) { memcpy(pos, rset->riter->item->pos, rset->tree->dim * sizeof *pos); } return rset->riter->item->data; } return 0; } void *kd_res_itemf(struct kdres *rset, float *pos) { if(rset->riter) { if(pos) { int i; for(i=0; itree->dim; i++) { pos[i] = rset->riter->item->pos[i]; } } return rset->riter->item->data; } return 0; } void *kd_res_item3(struct kdres *rset, double *x, double *y, double *z) { if(rset->riter) { if(*x) *x = rset->riter->item->pos[0]; if(*y) *y = rset->riter->item->pos[1]; if(*z) *z = rset->riter->item->pos[2]; } return 0; } void *kd_res_item3f(struct kdres *rset, float *x, float *y, float *z) { if(rset->riter) { if(*x) *x = rset->riter->item->pos[0]; if(*y) *y = rset->riter->item->pos[1]; if(*z) *z = rset->riter->item->pos[2]; } return 0; } void *kd_res_item_data(struct kdres *set) { return kd_res_item(set, 0); } /* ---- hyperrectangle helpers ---- */ static struct kdhyperrect* hyperrect_create(int dim, const double *min, const double *max) { size_t size = dim * sizeof(double); struct kdhyperrect* rect = 0; if (!(rect = malloc(sizeof(struct kdhyperrect)))) { return 0; } rect->dim = dim; if (!(rect->min = malloc(size))) { free(rect); return 0; } if (!(rect->max = malloc(size))) { free(rect->min); free(rect); return 0; } memcpy(rect->min, min, size); memcpy(rect->max, max, size); return rect; } static void hyperrect_free(struct kdhyperrect *rect) { free(rect->min); free(rect->max); free(rect); } static struct kdhyperrect* hyperrect_duplicate(const struct kdhyperrect *rect) { return hyperrect_create(rect->dim, rect->min, rect->max); } static void hyperrect_extend(struct kdhyperrect *rect, const double *pos) { int i; for (i=0; i < rect->dim; i++) { if (pos[i] < rect->min[i]) { rect->min[i] = pos[i]; } if (pos[i] > rect->max[i]) { rect->max[i] = pos[i]; } } } static double hyperrect_dist_sq(struct kdhyperrect *rect, const double *pos) { int i; double result = 0; for (i=0; i < rect->dim; i++) { if (pos[i] < rect->min[i]) { result += SQ(rect->min[i] - pos[i]); } else if (pos[i] > rect->max[i]) { result += SQ(rect->max[i] - pos[i]); } } return result; } /* ---- static helpers ---- */ #ifdef USE_LIST_NODE_ALLOCATOR /* special list node allocators. */ static struct res_node *free_nodes; #ifndef NO_PTHREADS static pthread_mutex_t alloc_mutex = PTHREAD_MUTEX_INITIALIZER; #endif static struct res_node *alloc_resnode(void) { struct res_node *node; #ifndef NO_PTHREADS pthread_mutex_lock(&alloc_mutex); #endif if(!free_nodes) { node = malloc(sizeof *node); } else { node = free_nodes; free_nodes = free_nodes->next; node->next = 0; } #ifndef NO_PTHREADS pthread_mutex_unlock(&alloc_mutex); #endif return node; } static void free_resnode(struct res_node *node) { #ifndef NO_PTHREADS pthread_mutex_lock(&alloc_mutex); #endif node->next = free_nodes; free_nodes = node; #ifndef NO_PTHREADS pthread_mutex_unlock(&alloc_mutex); #endif } #endif /* list node allocator or not */ /* inserts the item. if dist_sq is >= 0, then do an ordered insert */ static int rlist_insert(struct res_node *list, struct kdnode *item, double dist_sq) { struct res_node *rnode; if(!(rnode = alloc_resnode())) { return -1; } rnode->item = item; rnode->dist_sq = dist_sq; if(dist_sq >= 0.0) { while(list->next && list->next->dist_sq < dist_sq) { list = list->next; } } rnode->next = list->next; list->next = rnode; return 0; } static void clear_results(struct kdres *rset) { struct res_node *tmp, *node = rset->rlist->next; while(node) { tmp = node; node = node->next; free_resnode(tmp); } rset->rlist->next = 0; } ================================================ FILE: data_generation/rrtstar/src/kdtree.h ================================================ /* This file is part of ``kdtree'', a library for working with kd-trees. Copyright (C) 2007-2009 John Tsiombikas Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _KDTREE_H_ #define _KDTREE_H_ #ifdef __cplusplus extern "C" { #endif struct kdtree; struct kdres; /* create a kd-tree for "k"-dimensional data */ struct kdtree *kd_create(int k); /* free the struct kdtree */ void kd_free(struct kdtree *tree); /* remove all the elements from the tree */ void kd_clear(struct kdtree *tree); /* if called with non-null 2nd argument, the function provided * will be called on data pointers (see kd_insert) when nodes * are to be removed from the tree. */ void kd_data_destructor(struct kdtree *tree, void (*destr)(void*)); /* insert a node, specifying its position, and optional data */ int kd_insert(struct kdtree *tree, const double *pos, void *data); int kd_insertf(struct kdtree *tree, const float *pos, void *data); int kd_insert3(struct kdtree *tree, double x, double y, double z, void *data); int kd_insert3f(struct kdtree *tree, float x, float y, float z, void *data); /* Find one of the nearest nodes from the specified point. * * This function returns a pointer to a result set with at most one element. */ struct kdres *kd_nearest(struct kdtree *tree, const double *pos); struct kdres *kd_nearestf(struct kdtree *tree, const float *pos); struct kdres *kd_nearest3(struct kdtree *tree, double x, double y, double z); struct kdres *kd_nearest3f(struct kdtree *tree, float x, float y, float z); /* Find any nearest nodes from the specified point within a range. * * This function returns a pointer to a result set, which can be manipulated * by the kd_res_* functions. * The returned pointer can be null as an indication of an error. Otherwise * a valid result set is always returned which may contain 0 or more elements. * The result set must be deallocated with kd_res_free, after use. */ struct kdres *kd_nearest_range(struct kdtree *tree, const double *pos, double range); struct kdres *kd_nearest_rangef(struct kdtree *tree, const float *pos, float range); struct kdres *kd_nearest_range3(struct kdtree *tree, double x, double y, double z, double range); struct kdres *kd_nearest_range3f(struct kdtree *tree, float x, float y, float z, float range); /* frees a result set returned by kd_nearest_range() */ void kd_res_free(struct kdres *set); /* returns the size of the result set (in elements) */ int kd_res_size(struct kdres *set); /* rewinds the result set iterator */ void kd_res_rewind(struct kdres *set); /* returns non-zero if the set iterator reached the end after the last element */ int kd_res_end(struct kdres *set); /* advances the result set iterator, returns non-zero on success, zero if * there are no more elements in the result set. */ int kd_res_next(struct kdres *set); /* returns the data pointer (can be null) of the current result set item * and optionally sets its position to the pointers(s) if not null. */ void *kd_res_item(struct kdres *set, double *pos); void *kd_res_itemf(struct kdres *set, float *pos); void *kd_res_item3(struct kdres *set, double *x, double *y, double *z); void *kd_res_item3f(struct kdres *set, float *x, float *y, float *z); /* equivalent to kd_res_item(set, 0) */ void *kd_res_item_data(struct kdres *set); #ifdef __cplusplus } #endif #endif /* _KDTREE_H_ */ ================================================ FILE: data_generation/rrtstar/src/rrts.h ================================================ /*! * \file rrts.h */ #ifndef __RRTS_H_ #define __RRTS_H_ #include "kdtree.h" #include #include #include namespace RRTstar { template class Planner; /*! * \brief RRT* Vertex class * * More elaborate description */ template class Vertex { public: Vertex *parent; State *state; std::set children; double costFromParent; double costFromRoot; Trajectory *trajFromParent; public: /*! * \brief Vertex constructor * * More elaborate description */ Vertex (); /*! * \brief Vertex destructor * * More elaborate description */ ~Vertex (); /*! * \brief Vertex copy constructor * * More elaborate description * * \param vertexIn A reference to the vertex to be copied. * */ Vertex (const Vertex &vertexIn); /*! * \brief Returns a reference to the state * * More elaborate description */ State& getState () {return *state;} /*! * \brief Returns a reference to the state (constant) * * More elaborate description */ State& getState () const {return *state;} /*! * \brief Returns a reference to the parent vertex * * More elaborate description */ Vertex& getParent () {return *parent;} /*! * \brief Returns the accumulated cost at this vertex * * More elaborate description */ double getCost () {return costFromRoot;} friend class Planner; }; /*! * \brief RRT* Planner class * * More elaborate description */ template class Planner { typedef struct kdtree KdTree; typedef struct kdres KdRes; typedef Vertex vertex_t; int numDimensions; double gamma; double lowerBoundCost; vertex_t *lowerBoundVertex; KdTree *kdtree; vertex_t *root; int insertIntoKdtree (vertex_t &vertexIn); int getNearestVertex (State& stateIn, vertex_t*& vertexPointerOut); int getNearVertices (State& stateIn, std::vector& vectorNearVerticesOut); int checkUpdateBestVertex (vertex_t& vertexIn); vertex_t* insertTrajectory (vertex_t& vertexStartIn, Trajectory& trajectoryIn); int insertTrajectory (vertex_t& vertexStartIn, Trajectory& trajectoryIn, vertex_t& vertexEndIn); int findBestParent (State& stateIn, std::vector& vectorNearVerticesIn, vertex_t*& vertexBestOut, Trajectory& trajectoryOut, bool& exactConnection); int updateBranchCost (vertex_t& vertexIn, int depth); int rewireVertices (vertex_t& vertexNew, std::vector& vectorNearVertices); public: /*! * \brief A list of all the vertices * * More elaborate description */ std::list listVertices; /*! * \brief Number of vertices in the list * * More elaborate description */ int numVertices; /*! * \brief A pointer to the system class * * More elaborate description */ System *system; /*! * \brief Planner constructor * * More elaborate description */ Planner (); /*! * \brief Planner destructor * * More elaborate description */ ~Planner (); /*! * \brief Sets the gamma constant of the RRT* * * More elaborate description * * \param gammaIn The new value of the gamma parameter * */ int setGamma (double gammaIn); /*! * \brief Sets the dynamical system used in the RRT* trajectory generation * * More elaborate description * * \param system A reference to the new dynamical system * */ int setSystem (System& system); /*! * \brief Returns a reference to the root vertex * * More elaborate description */ vertex_t& getRootVertex (); /*! * \brief Initializes the RRT* algorithm * * More elaborate description */ int initialize (); /*! * \brief Executes one iteration of the RRT* algorithm * * More elaborate description */ int iteration (double (&node)[2],double px, double py); /*! * \brief Returns the cost of the best vertex in the RRT* * * More elaborate description */ double getBestVertexCost () {return lowerBoundCost;} /*! * \brief Returns a reference to the best vertex in the RRT* * * More elaborate description */ vertex_t& getBestVertex () {return *lowerBoundVertex;} /*! * \brief Returns the best trajectory as a list of double arrays * * More elaborate description * * \param trajectory The trajectory that contains the best trajectory as a * list of double arrays of dimension system->getNumDimensions() * * */ int getBestTrajectory (std::list& trajectory); }; } #endif ================================================ FILE: data_generation/rrtstar/src/rrts.hpp ================================================ /*! * \file rrts.hpp */ #ifndef __RRTS_HPP_ #define __RRTS_HPP_ #include #include #include #include #include "rrts.h" using namespace std; template RRTstar::Vertex ::Vertex () { state = NULL; parent = NULL; trajFromParent = NULL; costFromParent = 0.0; costFromRoot = 0.0; } template RRTstar::Vertex ::~Vertex () { if (state) delete state; parent = NULL; if (trajFromParent) delete trajFromParent; children.clear(); } template RRTstar::Vertex ::Vertex(const Vertex& vertexIn) { if (vertexIn.state) state = new State (vertexIn.getState()); else state = NULL; parent = vertexIn.parent; for (typename std::set< Vertex * >::const_iterator iter = vertexIn.children.begin(); iter != vertexIn.children.end(); iter++) children.insert (*iter); costFromParent = vertexIn.costFromParent; costFromRoot = vertexIn.costFromRoot; if (vertexIn.trajFromParent) trajFromParent = new Trajectory (*(vertexIn.trajFromParent)); else trajFromParent = NULL; } // int Vertex::setState (const State &stateIn) { // *state = stateIn; // return 1; // } template RRTstar::Planner ::Planner () { gamma = 1.0; lowerBoundCost = DBL_MAX; lowerBoundVertex = NULL; kdtree = NULL; root = NULL; numVertices = 0; system = NULL; } template RRTstar::Planner ::~Planner () { // Delete the kdtree structure if (kdtree) { kd_clear (kdtree); kd_free (kdtree); } // Delete all the vertices for (typename std::list * >::iterator iter = listVertices.begin(); iter != listVertices.end(); iter++) delete *iter; } template int RRTstar::Planner ::insertIntoKdtree (Vertex& vertexIn) { double *stateKey = new double[numDimensions]; system->getStateKey ( *(vertexIn.state), stateKey); kd_insert (kdtree, stateKey, &vertexIn); delete [] stateKey; return 1; } template int RRTstar::Planner ::getNearestVertex (State& stateIn, Vertex*& vertexPointerOut) { // Get the state key for the query state double *stateKey = new double[numDimensions]; system->getStateKey (stateIn, stateKey); // Search the kdtree for the nearest vertex KdRes *kdres = kd_nearest (kdtree, stateKey); if (kd_res_end (kdres)) vertexPointerOut = NULL; vertexPointerOut = (Vertex*) kd_res_item_data (kdres); // Clear up the memory delete [] stateKey; kd_res_free (kdres); // Return a non-positive number if any errors if (vertexPointerOut == NULL) return 0; return 1; } template int RRTstar::Planner ::getNearVertices (State& stateIn, std::vector< Vertex* >& vectorNearVerticesOut) { // Get the state key for the query state double *stateKey = new double[numDimensions]; system->getStateKey (stateIn, stateKey); // Compute the ball radius double ballRadius = gamma * pow( log((double)(numVertices + 1.0))/((double)(numVertices + 1.0)), 1.0/((double)numDimensions) ); // cout<<"Ball Radius"< *vertexCurr = (Vertex *) kd_res_item_data (kdres); vectorNearVerticesOut[i] = vertexCurr; kd_res_next (kdres); i++; } // Free temporary memory kd_res_free (kdres); return 1; } template int RRTstar::Planner ::checkUpdateBestVertex (Vertex& vertexIn) { if (system->isReachingTarget(vertexIn.getState())){ double costCurr = vertexIn.getCost(); if ( (lowerBoundVertex == NULL) || ( (lowerBoundVertex != NULL) && (costCurr < lowerBoundCost)) ) { lowerBoundVertex = &vertexIn; lowerBoundCost = costCurr; } } return 1; } template RRTstar::Vertex* RRTstar::Planner ::insertTrajectory (Vertex& vertexStartIn, Trajectory& trajectoryIn) { // Check for admissible cost-to-go if (lowerBoundVertex != NULL) { double costToGo = system->evaluateCostToGo (trajectoryIn.getEndState()); if (costToGo >= 0.0) if (lowerBoundCost < vertexStartIn.getCost() + costToGo) return NULL; } // Create a new end vertex Vertex* vertexNew = new Vertex; vertexNew->state = new State; vertexNew->parent = NULL; vertexNew->getState() = trajectoryIn.getEndState(); insertIntoKdtree (*vertexNew); this->listVertices.push_front (vertexNew); this->numVertices++; // Insert the trajectory between the start and end vertices insertTrajectory (vertexStartIn, trajectoryIn, *vertexNew); return vertexNew; } template int RRTstar::Planner ::insertTrajectory (Vertex& vertexStartIn, Trajectory& trajectoryIn, Vertex& vertexEndIn) { // Update the costs vertexEndIn.costFromParent = trajectoryIn.evaluateCost(); vertexEndIn.costFromRoot = vertexStartIn.costFromRoot + vertexEndIn.costFromParent; checkUpdateBestVertex (vertexEndIn); // Update the trajectory between the two vertices if (vertexEndIn.trajFromParent) delete vertexEndIn.trajFromParent; vertexEndIn.trajFromParent = new Trajectory (trajectoryIn); // Update the parent to the end vertex if (vertexEndIn.parent) vertexEndIn.parent->children.erase (&vertexEndIn); vertexEndIn.parent = &vertexStartIn; // Add the end vertex to the set of chilren vertexStartIn.children.insert (&vertexEndIn); return 1; } template int RRTstar::Planner ::setSystem (System& systemIn) { if (system) delete system; system = &systemIn; numDimensions = system->getNumDimensions (); // Delete all the vertices for (typename std::list< Vertex* >::iterator iter = listVertices.begin(); iter != listVertices.end(); iter++) delete *iter; numVertices = 0; lowerBoundCost = DBL_MAX; lowerBoundVertex = NULL; // Clear the kdtree if (kdtree) { kd_clear (kdtree); kd_free (kdtree); } kdtree = kd_create (numDimensions); // Initialize the root vertex root = new Vertex; root->state = new State (system->getRootState()); root->costFromParent = 0.0; root->costFromRoot = 0.0; root->trajFromParent = NULL; return 1; } template RRTstar::Vertex& RRTstar::Planner ::getRootVertex () { return *root; } template int RRTstar::Planner ::initialize () { // If there is no system, then return failure if (!system) return 0; // Backup the root Vertex *rootBackup = NULL; if (root) rootBackup = new Vertex (*root); cout<)<* >::iterator iter = listVertices.begin(); iter != listVertices.end(); iter++) delete *iter; listVertices.clear(); numVertices = 0; lowerBoundCost = DBL_MAX; lowerBoundVertex = NULL; // Clear the kdtree if (kdtree) { kd_clear (kdtree); kd_free (kdtree); } kdtree = kd_create (system->getNumDimensions()); // Initialize the variables numDimensions = system->getNumDimensions(); root = rootBackup; if (root){ listVertices.push_back(root); insertIntoKdtree (*root); numVertices++; } lowerBoundCost = DBL_MAX; lowerBoundVertex = NULL; return 1; } template int RRTstar::Planner ::setGamma (double gammaIn) { if (gammaIn < 0.0) return 0; gamma = gammaIn; return 1; } template int compareVertexCostPairs (std::pair*,double> i, std::pair*,double> j) { return (i.second < j.second); } template int RRTstar::Planner ::findBestParent (State& stateIn, std::vector< Vertex* >& vectorNearVerticesIn, Vertex*& vertexBest, Trajectory& trajectoryOut, bool& exactConnection) { // Compute the cost of extension for each near vertex int numNearVertices = vectorNearVerticesIn.size(); std::vector< std::pair*,double> > vectorVertexCostPairs(numNearVertices); int i = 0; for (typename std::vector< Vertex* >::iterator iter = vectorNearVerticesIn.begin(); iter != vectorNearVerticesIn.end(); iter++) { vectorVertexCostPairs[i].first = *iter; exactConnection = false; double trajCost = system->evaluateExtensionCost ( *((*iter)->state), stateIn, exactConnection); //if(trajCost>=0) vectorVertexCostPairs[i].second = (*iter)->costFromRoot + trajCost; i++; } // Sort vertices according to cost std::sort (vectorVertexCostPairs.begin(), vectorVertexCostPairs.end(), compareVertexCostPairs); // Try out each extension according to increasing cost i = 0; bool connectionEstablished = false; for (typename std::vector< std::pair*,double> >::iterator iter = vectorVertexCostPairs.begin(); iter != vectorVertexCostPairs.end(); iter++) { Vertex* vertexCurr = iter->first; // Extend the current vertex towards stateIn (and this time check for collision with obstacles) exactConnection = false; if (system->extendTo(*(vertexCurr->state), stateIn, trajectoryOut, exactConnection) > 0) { vertexBest = vertexCurr; connectionEstablished = true; break; } } // Return success if a connection was established if (connectionEstablished) return 1; // If the connection could not be established then return zero return 0; } template int RRTstar::Planner ::updateBranchCost (Vertex& vertexIn, int depth) { // Update the cost for each children for (typename std::set< Vertex* >::iterator iter = vertexIn.children.begin(); iter != vertexIn.children.end(); iter++) { Vertex& vertex = **iter; vertex.costFromRoot = vertexIn.costFromRoot + vertex.costFromParent; checkUpdateBestVertex (vertex); updateBranchCost (vertex, depth + 1); } return 1; } template int RRTstar::Planner ::rewireVertices (Vertex& vertexNew, std::vector< Vertex* >& vectorNearVertices) { // Repeat for all vertices in the set of near vertices for (typename std::vector< Vertex* >::iterator iter = vectorNearVertices.begin(); iter != vectorNearVertices.end(); iter++) { Vertex& vertexCurr = **iter; // Check whether the extension results in an exact connection bool exactConnection = false; double costCurr = system->evaluateExtensionCost (*(vertexNew.state), *(vertexCurr.state), exactConnection); if ( (exactConnection == false) || (costCurr < 0) ) continue; // Check whether the cost of the extension is smaller than current cost double totalCost = vertexNew.costFromRoot + costCurr; if (totalCost < vertexCurr.costFromRoot - 0.001) { // Compute the extension (checking for collision) Trajectory trajectory; if (system->extendTo (*(vertexNew.state), *(vertexCurr.state), trajectory, exactConnection) <= 0 ) continue; // Insert the new trajectory to the tree by rewiring insertTrajectory (vertexNew, trajectory, vertexCurr); // Update the cost of all vertices in the rewired branch updateBranchCost (vertexCurr, 0); } } return 1; } template int RRTstar::Planner ::iteration (double (&node)[2],double px, double py) { int chexk; int s=0; //double node[2]; // 1. Sample a new state State stateRandom; system->sampleState (stateRandom, node,px,py); // 2. Compute the set of all near vertices std::vector< Vertex* > vectorNearVertices; getNearVertices (stateRandom, vectorNearVertices); // 3. Find the best parent and extend from that parent Vertex* vertexParent = NULL; Trajectory trajectory,trajectory1; bool exactConnection = false; if (vectorNearVertices.size() == 0) { // 3.a Extend the nearest if (getNearestVertex (stateRandom, vertexParent) <= 0){ return 0; } if (system->extendTo(vertexParent->getState(), stateRandom, trajectory, exactConnection) <= 0) { return 0; } } else { // 3.b Extend the best parent within the near vertices if (findBestParent (stateRandom, vectorNearVertices, vertexParent, trajectory, exactConnection) <= 0) return 0; } // 3.c add the trajectory from the best parent to the tree Vertex* vertexNew = insertTrajectory (*vertexParent, trajectory); if (vertexNew == NULL) return 0; // 4. Rewire the tree if (vectorNearVertices.size() > 0) { rewireVertices (*vertexNew, vectorNearVertices); } } template int RRTstar::Planner ::getBestTrajectory (std::list& trajectoryOut) { if (lowerBoundVertex == NULL) return 0; Vertex* vertexCurr = lowerBoundVertex; while (vertexCurr) { State& stateCurr = vertexCurr->getState(); double *stateArrCurr = new double[2]; stateArrCurr[0] = stateCurr[0]; stateArrCurr[1] = stateCurr[1]; //stateArrCurr[2] = stateCurr[2]; trajectoryOut.push_front (stateArrCurr); Vertex& vertexParent = vertexCurr->getParent(); if (&vertexParent != NULL) { State& stateParent = vertexParent.getState(); std::list trajectory; system->getTrajectory (stateParent, stateCurr, trajectory); trajectory.reverse (); for (std::list::iterator iter = trajectory.begin(); iter != trajectory.end(); iter++) { double *stateArrFromParentCurr = *iter; stateArrCurr = new double[2]; stateArrCurr[0] = stateArrFromParentCurr[0]; stateArrCurr[1] = stateArrFromParentCurr[1]; //stateArrCurr[2] = stateArrFromParentCurr[2]; trajectoryOut.push_front (stateArrCurr); delete [] stateArrFromParentCurr; } } vertexCurr = &vertexParent; } return 1; } #endif ================================================ FILE: data_generation/rrtstar/src/rrts_main.cpp ================================================ #define LIBBOT_PRESENT 0 #include #include #include #include #include #include #include "rrts.hpp" #include "system_single_integrator.h" #include #include #include #include #include using namespace RRTstar; using namespace SingleIntegrator; using namespace std; //int sw=1; //int algo=0; typedef Planner planner_t; typedef Vertex vertex_t; class obst { public: double center[3]; double size[3]; double radius; }; bool check (double* first, double* second) { if(first[0]==second[0] && first[1]==second[1]) return true; else return false; } int size=50000; int publishTree (lcm_t *lcm, planner_t& planner, System& system); int publishPC (lcm_t *lcm, double nodes[8000][2], int sze, System& system); int publishTraj (lcm_t *lcm, planner_t& planner, System& system, int num, string fod); //lcm_t *lcm, region& regionOperating, region& regionGoal,list& obstacles //int publishEnvironment (lcm_t *lcm); int publishEnvironment(lcm_t *lcm, region& regionOperating, region& regionGoal, list& obstacles); //ofstream out("nodes1", ios::out | ios::binary); // double nodes[50000][2]; string env_path="env"; mkdir(env_path.c_str(),ACCESSPERMS); // create folder with env label to store generated trajectories int main () { double nodes[size][2]; // nodes from obstacle-free space that will become random start-goal pairs srand (time(0)); /* //-In order to generate random environments, we randomly sample 20 obstacles locations in the workspace, as follow: //-Orignal workspace is 40X40 but we sample locations from 30X30 space in order to avoid obstacles going out of workspace boundry. ////////////////////////////////////////////////////// double obst[20][2]; for (int i=0;i<20;i++) for (int j = 0; j < 2; j++) obst[i][j] = (double)rand()/(RAND_MAX + 1.0)*30.0 - 15.0 + 0.0; ofstream out("obs.dat", ios::out | ios::binary); if(!out) { cout << "Cannot open file."; return 1; } out.write((char *) &obst, sizeof nodes); out.close(); ////////////////////////////////////////////////// */ // load obstacle locations double fnum[20][2]; ifstream in("obs.dat", ios::in | ios::binary); in.read((char *) &fnum, sizeof fnum); //We drop 7 obstacle blocks in the workspace to generate random environments using 20P7=77520 permutations. Note that we can have now 77520 different environments but we use 110 envs only int perm[77520][7]; ifstream in2("obs_perm2.dat", ios::in | ios::binary); in2.read((char *) &perm, sizeof perm); //start and goal region int i=0; for (i=0;i<1;i++){ string env_no; // string which will contain the result ostringstream convert2; // stream used for the conversion convert2 << i; // insert the textual representation of 'Number' in the characters in the stream env_no =convert2.str(); string path="env/e"+env_no; mkdir(path.c_str(),ACCESSPERMS); // create folder with env label to store generated trajectories /* We also generted a random set of nodes from obstacle-free space, denoted as graph. These nodes are used as start and goal pairs */ double fnum2[50000][2]; path="graph/graph"+env_no+".dat"; ifstream in3(path.c_str(), ios::in | ios::binary); in3.read((char *) &fnum2, sizeof fnum2); int t=0; for (int t=0;t<100;t++){ cout<<"t"<setNumDimensions(2); obstacle->center[0] =fnum[perm[i][0]][0]; obstacle->center[1] = fnum[perm[i][0]][1]; obstacle->center[2] = 0.0; obstacle->size[0] = 5.0; obstacle->size[1] = 5.0; obstacle->size[2] = 0.0; obstacle1->setNumDimensions(2); obstacle1->center[0] = fnum[perm[i][1]][0]; obstacle1->center[1] = fnum[perm[i][1]][1]; obstacle1->center[2] = 0.0; obstacle1->size[0] = 5.0; obstacle1->size[1] = 5.0; obstacle1->size[2] = 0.0; obstacle2->setNumDimensions(2); obstacle2->center[0] = fnum[perm[i][2]][0]; obstacle2->center[1] = fnum[perm[i][2]][1]; obstacle2->center[2] = 0.0; obstacle2->size[0] = 5.0; obstacle2->size[1] = 5.0; obstacle2->size[2] = 0.0; obstacle3->setNumDimensions(2); obstacle3->center[0] = fnum[perm[i][3]][0]; obstacle3->center[1] = fnum[perm[i][3]][1]; obstacle3->center[2] = 0.0; obstacle3->size[0] = 5.0; obstacle3->size[1] = 5.0; obstacle3->size[2] = 0.0; obstacle4->setNumDimensions(2); obstacle4->center[0] = fnum[perm[i][4]][0]; obstacle4->center[1] = fnum[perm[i][4]][1]; obstacle4->center[2] = 0.0; obstacle4->size[0] = 5.0; obstacle4->size[1] = 5.0; obstacle4->size[2] = 0.0; obstacle5->setNumDimensions(2); obstacle5->center[0] = fnum[perm[i][5]][0]; obstacle5->center[1] = fnum[perm[i][5]][1]; obstacle5->center[2] = 0.0; obstacle5->size[0] = 5.0; obstacle5->size[1] = 5.0; obstacle5->size[2] = 0.0; obstacle6->setNumDimensions(2); obstacle6->center[0] = fnum[perm[i][6]][0]; obstacle6->center[1] = fnum[perm[i][6]][1]; obstacle6->center[2] = 0.0; obstacle6->size[0] = 5.0; obstacle6->size[1] = 5.0; obstacle6->size[2] = 0.0; system.obstacles.push_front(obstacle); // Add the obstacle to the list system.obstacles.push_front(obstacle1); // Add the obstacle to the list system.obstacles.push_front(obstacle2); // Add the obstacle to the list system.obstacles.push_front(obstacle3); // Add the obstacle to the list system.obstacles.push_front(obstacle4); // Add the obstacle to the list system.obstacles.push_front(obstacle5); system.obstacles.push_front(obstacle6); // publishEnvironment(lcm, system.regionOperating, system.regionGoal, system.obstacles); // Add the system to the planner rrts.setSystem (system); //publishEnvironment (lcm); // Set up the root vertex vertex_t &root = rrts.getRootVertex(); State &rootState = root.getState(); // Define start state rootState[0] =fnum2[t+1][0]; rootState[1] =fnum2[t+1][1]; rootState[2] = 0.0; // Initialize the planner rrts.initialize (); // This parameter should be larger than 1.5 for asymptotic // optimality. Larger values will weigh on optimization // rather than exploration in the RRT* algorithm. Lower // values, such as 0.1, should recover the RRT. rrts.setGamma (1.5); clock_t start = clock(); int j=0; double node[2]; // random obstacle-free nodes generation. These nodes were generated to form random start and goal pairs. /* int s=0; while(j<80000) { rrts.iteration(node); j++; if (node[0]!=0 && node[1]!=0) { if(s::iterator iter = system.obstacles.begin(); iter != system.obstacles.end(); iter++){ region* obstacleCurr = *iter; for (int i=s; i< (200+s); i++){ for (int j = 0; j < system.getNumDimensions(); j++) obcloud[i][j] = (double)rand()/(RAND_MAX + 1.0)*obstacleCurr->size[j] - obstacleCurr->size[j]/2.0 + obstacleCurr->center[j]; } if (s< 1400) s=s+200; else break; } string Result; // string which will contain the result ostringstream convert; // stream used for the conversion convert << i; // insert the textual representation of 'Number' in the characters in the stream Result =convert.str(); ofstream out(("obs_cloud/obc"+Result+".dat").c_str(), ios::out | ios::binary); if(!out) { cout << "Cannot open file."; return 1; } out.write((char *) &obcloud, sizeof obcloud); out.close(); */ clock_t finish = clock(); cout << "Time : " << ((double)(finish-start))/CLOCKS_PER_SEC << endl; //publishTree (lcm, rrts, system); // stores path in the folder env_no publishTraj (lcm, rrts, system,t, env_no ); } } return 1; } int publishEnvironment (lcm_t *lcm, region& regionOperating, region& regionGoal, list& obstacles) { // Publish the environment lcmtypes_environment_t *environment = (lcmtypes_environment_t*) malloc (sizeof(lcmtypes_environment_t)); environment->operating.center[0] = regionOperating.center[0]; environment->operating.center[1] = regionOperating.center[1]; environment->operating.center[2] = regionOperating.center[2]; environment->operating.size[0] = regionOperating.size[0]; environment->operating.size[1] = regionOperating.size[1]; environment->operating.size[2] = regionOperating.size[2]; environment->goal.center[0] = regionGoal.center[0]; environment->goal.center[1] = regionGoal.center[1]; environment->goal.center[2] = regionGoal.center[2]; environment->goal.size[0] = regionGoal.size[0]; environment->goal.size[1] = regionGoal.size[1]; environment->goal.size[2] = regionGoal.size[2]; environment->num_obstacles = obstacles.size(); if (environment->num_obstacles > 0) environment->obstacles = (lcmtypes_region_3d_t *) malloc (sizeof(lcmtypes_region_3d_t)); int idx_obstacles = 0; for (list::iterator iter = obstacles.begin(); iter != obstacles.end(); iter++){ region* obstacleCurr = *iter; environment->obstacles[idx_obstacles].center[0] = obstacleCurr->center[0]; environment->obstacles[idx_obstacles].center[1] = obstacleCurr->center[1]; environment->obstacles[idx_obstacles].center[2] = obstacleCurr->center[2]; environment->obstacles[idx_obstacles].size[0] = obstacleCurr->size[0]; environment->obstacles[idx_obstacles].size[1] = obstacleCurr->size[1]; environment->obstacles[idx_obstacles].size[2] = obstacleCurr->size[2]; idx_obstacles++; } lcmtypes_environment_t_publish (lcm, "ENVIRONMENT", environment); lcmtypes_environment_t_destroy (environment); return 1; } int publishTraj (lcm_t *lcm, planner_t& planner, System& system, int num, string fod) { cout << "Publishing trajectory -- start" << endl; vertex_t& vertexBest = planner.getBestVertex (); if (&vertexBest == NULL) { cout << "No best vertex" << endl; double path[1][2]; path[0][0]=0; path[0][1]=0; string Result; // string which will contain the result ostringstream convert; // stream used for the conversion convert << num; // insert the textual representation of 'Number' in the characters in the stream Result =convert.str(); // set 'Result' to the contents of the stream ofstream out(("e"+fod+"/path"+Result+".dat").c_str(), ios::out | ios::binary); if(!out) { cout << "Cannot open file."; return 1; } out.write((char *) &path, sizeof path); out.close(); return 0; } cout<<"Cost From root "< stateList; planner.getBestTrajectory (stateList); lcmtypes_trajectory_t *opttraj = (lcmtypes_trajectory_t *) malloc (sizeof (lcmtypes_trajectory_t)); opttraj->num_states = stateList.size(); opttraj->states = (lcmtypes_state_t *) malloc (opttraj->num_states * sizeof (lcmtypes_state_t)); int psize=(stateList.size()-1)/2+1; int pindex=0; double path[psize][2]; int stateIndex = 0; for (list::iterator iter = stateList.begin(); iter != stateList.end(); iter++) { double* stateRef = *iter; opttraj->states[stateIndex].x = stateRef[0]; opttraj->states[stateIndex].y = stateRef[1]; if(pindex>0){ if(path[pindex-1][0]!=stateRef[0]){ path[pindex][0]=stateRef[0]; path[pindex][1]=stateRef[1]; pindex++; } } else{ path[pindex][0]=stateRef[0]; path[pindex][1]=stateRef[1]; pindex++; } if (system.getNumDimensions() > 2) opttraj->states[stateIndex].z = stateRef[2]; else opttraj->states[stateIndex].z = 0.0; delete [] stateRef; stateIndex++; } string Result; // string which will contain the result ostringstream convert; // stream used for the conversion convert << num; // insert the textual representation of 'Number' in the characters in the stream Result =convert.str(); // set 'Result' to the contents of the stream ofstream out(("env/e"+fod+"/path"+Result+".dat").c_str(), ios::out | ios::binary); if(!out) { cout << "Cannot open file."; return 1; } out.write((char *) &path, sizeof path); out.close(); lcmtypes_trajectory_t_publish (lcm, "TRAJECTORY", opttraj); lcmtypes_trajectory_t_destroy (opttraj); cout << "Publishing trajectory -- end" << endl; return 1; } int publishTree (lcm_t *lcm, planner_t& planner, System& system) { cout << "Publishing the tree -- start" << endl; bool plot3d = (system.getNumDimensions() > 2); lcmtypes_graph_t *graph = (lcmtypes_graph_t *) malloc (sizeof (lcmtypes_graph_t)); graph->num_vertices = planner.numVertices; cout<<"num_Vertices: "<< graph->num_vertices<< endl; if (graph->num_vertices > 0) { graph->vertices = (lcmtypes_vertex_t *) malloc (graph->num_vertices * sizeof(lcmtypes_vertex_t)); int vertexIndex = 0; for (list::iterator iter = planner.listVertices.begin(); iter != planner.listVertices.end(); iter++) { vertex_t &vertexCurr = **iter; State &stateCurr = vertexCurr.getState (); graph->vertices[vertexIndex].state.x = stateCurr[0]; graph->vertices[vertexIndex].state.y = stateCurr[1]; if (plot3d){ graph->vertices[vertexIndex].state.z = stateCurr[2]; } else graph->vertices[vertexIndex].state.z = 0.0; vertexIndex++; } } else { graph->vertices = NULL; } if (graph->num_vertices > 1) { graph->num_edges = graph->num_vertices - 1; graph->edges = (lcmtypes_edge_t *) malloc (graph->num_edges * sizeof(lcmtypes_edge_t)); int edgeIndex = 0; for (list::iterator iter = planner.listVertices.begin(); iter != planner.listVertices.end(); iter++) { vertex_t &vertexCurr = **iter; vertex_t &vertexParent = vertexCurr.getParent(); if ( &vertexParent == NULL ) continue; State &stateCurr = vertexCurr.getState (); State &stateParent = vertexParent.getState(); graph->edges[edgeIndex].vertex_src.state.x = stateParent[0]; graph->edges[edgeIndex].vertex_src.state.y = stateParent[1]; if (plot3d) graph->edges[edgeIndex].vertex_src.state.z = stateParent[2]; else graph->edges[edgeIndex].vertex_src.state.z = 0.0; graph->edges[edgeIndex].vertex_dst.state.x = stateCurr[0]; graph->edges[edgeIndex].vertex_dst.state.y = stateCurr[1]; if (plot3d) graph->edges[edgeIndex].vertex_dst.state.z = stateCurr[2]; else graph->edges[edgeIndex].vertex_dst.state.z = 0.0; graph->edges[edgeIndex].trajectory.num_states = 0; graph->edges[edgeIndex].trajectory.states = NULL; edgeIndex++; } } else { graph->num_edges = 0; graph->edges = NULL; } lcmtypes_graph_t_publish (lcm, "GRAPH", graph); lcmtypes_graph_t_destroy (graph); cout << "Publishing the tree -- end" << endl; return 1; } ================================================ FILE: data_generation/rrtstar/src/system.h ================================================ /*! * \file system.h * * This serves as a template to start a new system file. * It should not be included as is. */ #ifndef __RRTS_SYSTEM_H_ #define __RRTS_SYSTEM_H_ #include /*! * \brief State Class. * * A more elaborate description of the State class */ class State { public: /*! * \brief State assingment operator. * * A more elaborate description of the State assignment operator */ State& operator= (const State &stateIn); /*! * \brief State bracket operator. * * A more elaborate description of the State bracket operator */ double& operator[] (const int i); }; /*! * \brief Trajectory Class. * * A more elaborate description of the Trajectory class */ class Trajectory { public: /*! * \brief Trajecotory assignment operator. * * A more elaborate description. */ Trajectory& operator= (const Trajectory &trajectoryIn); /*! * \brief Returns a reference to the end state of this trajectory. * * A more elaborate description. */ State& getEndState (); /*! * \brief Returns a reference to the end state of this trajectory (constant). * * A more elaborate description. */ State& getEndState () const; /*! * \brief Returns the cost of this trajectory. * * A more elaborate description. */ double evaluateCost (); }; /*! * \brief System Class. * * A more elaborate description of the System class */ class System { public: /*! * \brief Returns the dimensionality of the Euclidean space. * * A more elaborate description. */ int getNumDimensions (); /*! * \brief Returns a reference to the root state. * * A more elaborate description. */ State & getRootState (); /*! * \brief Returns the statekey for the given state. * * A more elaborate description. * * \param stateIn the given state * \param stateKey the key to the state. An array of dimension getNumDimensions() * */ int getStateKey (State& stateIn, double* stateKey); /*! * \brief Returns true of the given state reaches the target. * * A more elaborate description. */ bool isReachingTarget (State& stateIn); /*! * \brief Returns a sample state. * * A more elaborate description. * * \param randomStateOut * */ int sampleState (State& randomStateOut, double (&node)[2],double px, double py); /*! * \brief Returns a the cost of the trajectory that connects stateFromIn and * stateTowardsIn. The trajectory is also returned in trajectoryOut. * * A more elaborate description. * * \param stateFromIn Initial state * \param stateTowardsIn Final state * \param trajectoryOut Trajectory that starts the from the initial state and * reaches near the final state. * \param exactConnectionOut Set to true if the initial and the final states * can be connected exactly. * */ int extendTo (State& stateFromIn, State& stateTowardsIn, Trajectory& trajectoryOut, bool& exactConnectionOut); /*! * \brief Returns the cost of the trajectory that connects stateFromIn and StateTowardsIn. * * A more elaborate description. * * \param stateFromIn Initial state * \param stateTowardsIn Final state * \param exactConnectionOut Set to true if the initial and the final states * can be connected exactly. * */ double evaluateExtensionCost (State& stateFromIn, State& stateTowardsIn, bool& exactConnectionOut); /*! * \brief Returns a lower bound on the cost to go starting from stateIn * * A more elaborate description. * * \param stateIn Starting state * */ double evaluateCostToGo (State& stateIn); /*! * \brief Returns the trajectory as a list of double arrays, each with dimension getNumDimensions. * * A more elaborate description. * * \param stateFromIn Initial state * \param stateToIn Final state * \param trajectoryOut The list of double arrays that represent the trajectory * */ int getTrajectory (State& stateFromIn, State& stateToIn, std::list< double* > & trajectoryOut); // p-rrt* int get_pfstates (State& state); }; #endif ================================================ FILE: data_generation/rrtstar/src/system_single_integrator.cpp ================================================ #include "system_single_integrator.h" #include #include #include using namespace std; using namespace SingleIntegrator; #define DISCRETIZATION_STEP 0.01 int s=0; region::region () { numDimensions = 0; center = NULL; size = NULL; radius=0; } region::~region () { if (center) delete [] center; if (size) delete [] size; } int region::setNumDimensions (int numDimensionsIn) { numDimensions = numDimensionsIn; if (center) delete [] center; center = new double[numDimensions]; if (size) delete [] size; size = new double[numDimensions]; return 1; } State::State () { numDimensions = 0; x = NULL; } State::~State () { if (x) delete [] x; } State::State (const State &stateIn) { numDimensions = stateIn.numDimensions; if (numDimensions > 0) { x = new double[numDimensions]; for (int i = 0; i < numDimensions; i++) x[i] = stateIn.x[i]; } else { x = NULL; } } State& State::operator=(const State &stateIn){ if (this == &stateIn) return *this; if (numDimensions != stateIn.numDimensions) { if (x) delete [] x; numDimensions = stateIn.numDimensions; if (numDimensions > 0) x = new double[numDimensions]; } for (int i = 0; i < numDimensions; i++) x[i] = stateIn.x[i]; return *this; } int State::setNumDimensions (int numDimensionsIn) { if (x) delete [] x; if (numDimensions < 0) return 0; numDimensions = numDimensionsIn; if (numDimensions > 0) x = new double[numDimensions]; return 1; } Trajectory::Trajectory () { endState = NULL; } Trajectory::~Trajectory () { if (endState) delete endState; } Trajectory::Trajectory (const Trajectory &trajectoryIn) { endState = new State (trajectoryIn.getEndState()); } Trajectory& Trajectory::operator=(const Trajectory &trajectoryIn) { if (this == &trajectoryIn) return *this; if (endState) delete endState; endState = new State (trajectoryIn.getEndState()); totalVariation = trajectoryIn.totalVariation; return *this; } double Trajectory::evaluateCost () { return totalVariation; } System::System () { numDimensions = 0; } System::~System () { } int System::setNumDimensions (int numDimensionsIn) { if (numDimensions < 0) return 0; numDimensions = numDimensionsIn; rootState.setNumDimensions (numDimensions); return 1; } int System::getStateKey (State& stateIn, double* stateKey) { for (int i = 0; i < numDimensions; i++){ stateKey[i] = stateIn.x[i] / regionOperating.size[i]; } return 1; } /***********************************************My new addition****************************************************/ // Implementation of Pontential function-based sampling heuristic (https://link.springer.com/article/10.1007/s10514-015-9518-0) int System::pfstates(State& rstout){ int k = 50; double lamda = 0.1; //lamda step size double prev_state[numDimensions]; for(int j=0;j 0) { //as Potential is zero in goal region if(isReachingTarget(rstout) == false) { prev_state[j]=rstout.x[j]; rstout.x[j] = rstout.x[j] - lamda; } }else if(rstout.x[j] - regionGoal.center[j] < 0) { //as Potential is zero in goal region if(isReachingTarget(rstout) == false) { prev_state[j]=rstout.x[j]; rstout.x[j] = rstout.x[j] + lamda; } } } } return 1; } bool System::isReachingTarget (State &stateIn) { for (int i = 0; i < numDimensions; i++) { if (fabs(stateIn.x[i] - regionGoal.center[i]) > regionGoal.size[i]/2.0 ) return false; } return true; } bool System::IsInCollision (double *stateIn) { for (list::iterator iter = obstacles.begin(); iter != obstacles.end(); iter++) { region *obstacleCurr = *iter; bool collisionFound = true; for (int i = 0; i < numDimensions; i++) if (fabs(obstacleCurr->center[i] - stateIn[i]) > obstacleCurr->size[i]/2.0 ) { collisionFound = false; break; } if (collisionFound) { return true; } } return false; } int System::sampleState (State &randomStateOut, double (&node)[2], double px, double py) { randomStateOut.setNumDimensions (numDimensions); if (px==-1){ for (int i = 0; i < numDimensions; i++) { randomStateOut.x[i] = (double)rand()/(RAND_MAX + 1.0)*regionOperating.size[i] - regionOperating.size[i]/2.0 + regionOperating.center[i]; } } else{ randomStateOut.x[0]=px; randomStateOut.x[1]=py; } if (IsInCollision (randomStateOut.x)){ node[0]= 0; node[1]=0; return 0; } // node contain sample from obstacle-free space (see rrts_main.cpp for random obstacle-free nodes generation) node[0]= randomStateOut.x[0]; node[1]=randomStateOut.x[1]; // comment it if you would like to use simple rrtstar. pfstates(randomStateOut); if (IsInCollision (randomStateOut.x)) return 0; return 1; } int System::steerTo (State &stateFromIn, State &stateTowardsIn) { double *dists = new double[numDimensions]; for (int i = 0; i < numDimensions; i++) dists[i] = stateTowardsIn.x[i] - stateFromIn.x[i]; double distTotal = 0.0; for (int i = 0; i < numDimensions; i++) distTotal += dists[i]*dists[i]; distTotal = sqrt (distTotal); double incrementTotal = distTotal/DISCRETIZATION_STEP; // normalize the distance according to the disretization step for (int i = 0; i < numDimensions; i++) dists[i] /= incrementTotal; int numSegments = (int)floor(incrementTotal); double *stateCurr = new double[numDimensions]; for (int i = 0; i < numDimensions; i++) stateCurr[i] = stateFromIn.x[i]; for (int i = 0; i < numSegments; i++) { if (IsInCollision (stateCurr)) return 0; for (int i = 0; i < numDimensions; i++) stateCurr[i] += dists[i]; } if (IsInCollision (stateTowardsIn.x)) return 0; delete [] dists; delete [] stateCurr; return 1; } int System::extendTo (State &stateFromIn, State &stateTowardsIn, Trajectory &trajectoryOut, bool &exactConnectionOut) { double *dists = new double[numDimensions]; for (int i = 0; i < numDimensions; i++) dists[i] = stateTowardsIn.x[i] - stateFromIn.x[i]; double distTotal = 0.0; for (int i = 0; i < numDimensions; i++) distTotal += dists[i]*dists[i]; distTotal = sqrt (distTotal); double incrementTotal = distTotal/DISCRETIZATION_STEP; // normalize the distance according to the disretization step for (int i = 0; i < numDimensions; i++) dists[i] /= incrementTotal; int numSegments = (int)floor(incrementTotal); double *stateCurr = new double[numDimensions]; for (int i = 0; i < numDimensions; i++) stateCurr[i] = stateFromIn.x[i]; for (int i = 0; i < numSegments; i++) { if (IsInCollision (stateCurr)) return 0; for (int i = 0; i < numDimensions; i++) stateCurr[i] += dists[i]; } if (IsInCollision (stateTowardsIn.x)) return 0; trajectoryOut.endState = new State (stateTowardsIn); trajectoryOut.totalVariation = distTotal; delete [] dists; delete [] stateCurr; exactConnectionOut = true; return 1; } double System::evaluateExtensionCost (State& stateFromIn, State& stateTowardsIn, bool &exactConnectionOut) { exactConnectionOut = true; double distTotal = 0.0; for (int i = 0; i < numDimensions; i++) { double distCurr = stateTowardsIn.x[i] - stateFromIn.x[i]; distTotal += distCurr*distCurr; } return sqrt(distTotal); } int System::getTrajectory (State& stateFromIn, State& stateToIn, list& trajectoryOut) { double *stateArr = new double[numDimensions]; for (int i = 0; i < numDimensions; i++) stateArr[i] = stateToIn[i]; trajectoryOut.push_front (stateArr); return 1; } double System::evaluateCostToGo (State& stateIn) { double radius = 0.0; for (int i = 0; i < numDimensions; i++) radius += regionGoal.size[i] * regionGoal.size[i]; radius = sqrt(radius); double dist = 0.0; for (int i = 0; i < numDimensions; i++) dist += (stateIn[i] - regionGoal.center[i])*(stateIn[0] - regionGoal.center[i]); dist = sqrt(dist); return dist - radius; } ================================================ FILE: data_generation/rrtstar/src/system_single_integrator.h ================================================ /*! * \file system_single_integrator.h */ #ifndef __RRTS_SYSTEM_SINGLE_INTEGRATOR_H_ #define __RRTS_SYSTEM_SINGLE_INTEGRATOR_H_ #include namespace SingleIntegrator { /*! * \brief region class * * More elaborate description */ class region { int numDimensions; public: /*! * \brief Cartesian coordinates of the center of the region * * More elaborate description */ double *center; /*! * \brief Size of the region in cartesian coordinates * * More elaborate description */ double *size; double radius; /*! * \brief region constructor * * More elaborate description */ region (); /*! * \brief region destructor * * More elaborate description */ ~region (); /*! * \brief Sets the dimensionality of the region * * More elaborate description * * \param numDimensionsIn New number of dimensions. * */ int setNumDimensions (int numDimensionsIn); }; /*! * \brief State Class. * * A more elaborate description of the State class */ class State { int numDimensions; double *x; int setNumDimensions (int numDimensions); public: /*! * \brief State constructor * * More elaborate description */ State (); /*! * \brief State desctructor * * More elaborate description */ ~State (); /*! * \brief State copy constructor * * More elaborate description */ State (const State& stateIn); /*! * \brief State assignment operator * * More elaborate description */ State& operator= (const State& stateIn); /*! * \brief State bracket operator * * More elaborate description */ double& operator[] (const int i) {return x[i];} friend class System; friend class Trajectory; }; /*! * \brief Trajectory Class. * * A more elaborate description of the State class */ class Trajectory { State *endState; double totalVariation; public: /*! * \brief Trajectory constructor * * More elaborate description */ Trajectory (); /*! * \brief Trajectory destructor * * More elaborate description */ ~Trajectory (); /*! * \brief Trajectory copy constructor * * More elaborate description * * \param trajectoryIn The trajectory to be copied. * */ Trajectory (const Trajectory& trajectoryIn); /*! * \brief Trajectory assignment constructor * * More elaborate description * * \param trajectoryIn the trajectory to be copied. * */ Trajectory& operator= (const Trajectory& trajectoryIn); /*! * \brief Returns a reference to the end state of this trajectory. * * More elaborate description */ State& getEndState () {return *endState;} /*! * \brief Returns a reference to the end state of this trajectory (constant). * * More elaborate description */ State& getEndState () const {return *endState;} /*! * \brief Returns the cost of this trajectory. * * More elaborate description */ double evaluateCost (); friend class System; }; /*! * \brief System Class. * * A more elaborate description of the State class */ class System { int numDimensions; bool IsInCollision (double *stateIn); State rootState; public: /*! * \brief The operating region * * More elaborate description */ region regionOperating; /*! * \brief The goal region * * More elaborate description */ region regionGoal; /*! * \brief The list of all obstacles * * More elaborate description */ std::list obstacles; /*! * \brief System constructor * * More elaborate description */ System (); /*! * \brief System destructor * * More elaborate description */ ~System (); int setNumDimensions (int numDimensionsIn); /*! * \brief Returns the dimensionality of the Euclidean space. * * A more elaborate description. */ int getNumDimensions () {return numDimensions;} /*! * \brief Returns a reference to the root state. * * A more elaborate description. */ State& getRootState () {return rootState;} /*! * \brief Returns the statekey for the given state. * * A more elaborate description. * * \param stateIn the given state * \param stateKey the key to the state. An array of dimension getNumDimensions() * */ int getStateKey (State &stateIn, double *stateKey); /*! * \brief Returns true of the given state reaches the target. * * A more elaborate description. */ bool isReachingTarget (State &stateIn); /*! * \brief Returns a sample state. * * A more elaborate description. * * \param randomStateOut * */ int sampleState (State &randomStateOut, double (&node)[2], double px, double py); /*! * \brief Returns a the cost of the trajectory that connects stateFromIn and * stateTowardsIn. The trajectory is also returned in trajectoryOut. * * A more elaborate description. * * \param stateFromIn Initial state * \param stateTowardsIn Final state * \param trajectoryOut Trajectory that starts the from the initial state and * reaches near the final state. * \param exactConnectionOut Set to true if the initial and the final states * can be connected exactly. * */ int extendTo (State &stateFromIn, State &stateTowardsIn, Trajectory &trajectoryOut, bool &exactConnectionOut); int steerTo (State &stateFromIn, State &stateTowardsIn); int optimization (double* stateA, double* stateC); /*! * \brief Returns the cost of the trajectory that connects stateFromIn and StateTowardsIn. * * A more elaborate description. * * \param stateFromIn Initial state * \param stateTowardsIn Final state * \param exactConnectionOut Set to true if the initial and the final states * can be connected exactly. * */ double evaluateExtensionCost (State &stateFromIn, State &stateTowardsIn, bool &exactConnectionOut); /*! * \brief Returns a lower bound on the cost to go starting from stateIn * * A more elaborate description. * * \param stateIn Starting state * */ double evaluateCostToGo (State& stateIn); /*! * \brief Returns the trajectory as a list of double arrays, each with dimension getNumDimensions. * * A more elaborate description. * * \param stateFromIn Initial state * \param stateToIn Final state * \param trajectoryOut The list of double arrays that represent the trajectory * */ int getTrajectory (State& stateFromIn, State& stateToIn, std::list& trajectoryOut); // p-rrt* int pfstates (State& state); }; } #endif ================================================ FILE: data_generation/tobuild.txt ================================================ # list of collections to build, one one each line. Empty lines # and lines starting with '#' are ignored lcmtypes viewer rrtstar ================================================ FILE: data_generation/viewer/CMakeLists.txt ================================================ cmake_minimum_required(VERSION 2.6.0) # pull in the pods macros. See cmake/pods.cmake for documentation set(POD_NAME viewer) include(cmake/pods.cmake) find_package(PkgConfig REQUIRED) find_package(OpenGL REQUIRED) list(APPEND OPENGL_LIBRARIES GL ) set(GLUT_CFLAGS "") set(GLUT_LIBRARIES -lglut) set(ZLIB_LIBRARIES -lz) pkg_check_modules(LCM REQUIRED lcm) pkg_check_modules(GTK2 REQUIRED gtk+-2.0) pkg_check_modules(BOT2_VIS REQUIRED bot2-vis) #tell cmake to build these subdirectories add_subdirectory(src/renderers) add_subdirectory(src) ================================================ FILE: data_generation/viewer/Makefile ================================================ # Default makefile distributed with pods version: 11.03.11 default_target: all # Default to a less-verbose build. If you want all the gory compiler output, # run "make VERBOSE=1" $(VERBOSE).SILENT: # Figure out where to build the software. # Use BUILD_PREFIX if it was passed in. # If not, search up to four parent directories for a 'build' directory. # Otherwise, use ./build. ifeq "$(BUILD_PREFIX)" "" BUILD_PREFIX:=$(shell for pfx in ./ .. ../.. ../../.. ../../../..; do d=`pwd`/$$pfx/build;\ if [ -d $$d ]; then echo $$d; exit 0; fi; done; echo `pwd`/build) endif # create the build directory if needed, and normalize its path name BUILD_PREFIX:=$(shell mkdir -p $(BUILD_PREFIX) && cd $(BUILD_PREFIX) && echo `pwd`) # Default to a release build. If you want to enable debugging flags, run # "make BUILD_TYPE=Debug" ifeq "$(BUILD_TYPE)" "" BUILD_TYPE="Release" endif all: pod-build/Makefile $(MAKE) -C pod-build all install pod-build/Makefile: $(MAKE) configure .PHONY: configure configure: @echo "\nBUILD_PREFIX: $(BUILD_PREFIX)\n\n" # create the temporary build directory if needed @mkdir -p pod-build # run CMake to generate and configure the build scripts @cd pod-build && cmake -DCMAKE_INSTALL_PREFIX=$(BUILD_PREFIX) \ -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) .. clean: -if [ -e pod-build/install_manifest.txt ]; then rm -f `cat pod-build/install_manifest.txt`; fi -if [ -d pod-build ]; then $(MAKE) -C pod-build clean; rm -rf pod-build; fi # other (custom) targets are passed through to the cmake-generated Makefile %:: $(MAKE) -C pod-build $@ ================================================ FILE: data_generation/viewer/README ================================================ This is a default README file, please replace its contents with information relevant to your project. This software is constructed according to the Pods software policies and templates. The policies and templates can be found at: http://sourceforge.net/projects/pods ==== Name: rrtstar-planner Maintainers: FILL-ME-IN Summary: FILL-ME-IN Description: FILL-ME-IN Requirements: FILL-ME-IN License: FILL-ME-IN ================================================ FILE: data_generation/viewer/cmake/pods.cmake ================================================ # Macros to simplify compliance with the pods build policies. # # To enable the macros, add the following lines to CMakeLists.txt: # set(POD_NAME ) # include(cmake/pods.cmake) # # If POD_NAME is not set, then the CMake source directory is used as POD_NAME # # Next, any of the following macros can be used. See the individual macro # definitions in this file for individual documentation. # # C/C++ # pods_install_headers(...) # pods_install_libraries(...) # pods_install_executables(...) # pods_install_pkg_config_file(...) # # pods_use_pkg_config_packages(...) # # Python # pods_install_python_packages(...) # pods_install_python_script(...) # # Java # None yet # # ---- # File: pods.cmake # Distributed with pods version: 11.03.11 # pods_install_headers( ... DESTINATION ) # # Install a (list) of header files. # # Header files will all be installed to include/ # # example: # add_library(perception detector.h sensor.h) # pods_install_headers(detector.h sensor.h DESTINATION perception) # function(pods_install_headers) list(GET ARGV -2 checkword) if(NOT checkword STREQUAL DESTINATION) message(FATAL_ERROR "pods_install_headers missing DESTINATION parameter") endif() list(GET ARGV -1 dest_dir) list(REMOVE_AT ARGV -1) list(REMOVE_AT ARGV -1) #copy the headers to the INCLUDE_OUTPUT_PATH (${CMAKE_BINARY_DIR}/include) foreach(header ${ARGV}) get_filename_component(_header_name ${header} NAME) configure_file(${header} ${INCLUDE_OUTPUT_PATH}/${dest_dir}/${_header_name} COPYONLY) endforeach(header) #mark them to be installed install(FILES ${ARGV} DESTINATION include/${dest_dir}) endfunction(pods_install_headers) # pods_install_executables( ...) # # Install a (list) of executables to bin/ function(pods_install_executables) install(TARGETS ${ARGV} RUNTIME DESTINATION bin) endfunction(pods_install_executables) # pods_install_libraries( ...) # # Install a (list) of libraries to lib/ function(pods_install_libraries) install(TARGETS ${ARGV} LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) endfunction(pods_install_libraries) # pods_install_pkg_config_file( # [VERSION ] # [DESCRIPTION ] # [CFLAGS ...] # [LIBS ...] # [REQUIRES ...]) # # Create and install a pkg-config .pc file. # # example: # add_library(mylib mylib.c) # pods_install_pkg_config_file(mylib LIBS -lmylib REQUIRES glib-2.0) function(pods_install_pkg_config_file) list(GET ARGV 0 pc_name) # TODO error check set(pc_version 0.0.1) set(pc_description ${pc_name}) set(pc_requires "") set(pc_libs "") set(pc_cflags "") set(pc_fname "${PKG_CONFIG_OUTPUT_PATH}/${pc_name}.pc") set(modewords LIBS CFLAGS REQUIRES VERSION DESCRIPTION) set(curmode "") # parse function arguments and populate pkg-config parameters list(REMOVE_AT ARGV 0) foreach(word ${ARGV}) list(FIND modewords ${word} mode_index) if(${mode_index} GREATER -1) set(curmode ${word}) elseif(curmode STREQUAL LIBS) set(pc_libs "${pc_libs} ${word}") elseif(curmode STREQUAL CFLAGS) set(pc_cflags "${pc_cflags} ${word}") elseif(curmode STREQUAL REQUIRES) set(pc_requires "${pc_requires} ${word}") elseif(curmode STREQUAL VERSION) set(pc_version ${word}) set(curmode "") elseif(curmode STREQUAL DESCRIPTION) set(pc_description "${word}") set(curmode "") else(${mode_index} GREATER -1) message("WARNING incorrect use of pods_add_pkg_config (${word})") break() endif(${mode_index} GREATER -1) endforeach(word) # write the .pc file out file(WRITE ${pc_fname} "prefix=${CMAKE_INSTALL_PREFIX}\n" "exec_prefix=\${prefix}\n" "libdir=\${exec_prefix}/lib\n" "includedir=\${prefix}/include\n" "\n" "Name: ${pc_name}\n" "Description: ${pc_description}\n" "Requires: ${pc_requires}\n" "Version: ${pc_version}\n" "Libs: -L\${libdir} ${pc_libs}\n" "Cflags: -I\${includedir} ${pc_cflags}\n") # mark the .pc file for installation to the lib/pkgconfig directory install(FILES ${pc_fname} DESTINATION lib/pkgconfig) # find targets that this pkg-config file depends on if (pc_libs) string(REPLACE " " ";" split_lib ${pc_libs}) foreach(lib ${split_lib}) string(REGEX REPLACE "^-l" "" libname ${lib}) get_target_property(IS_TARGET ${libname} LOCATION) if (NOT IS_TARGET STREQUAL "IS_TARGET-NOTFOUND") set_property(GLOBAL APPEND PROPERTY "PODS_PKG_CONFIG_TARGETS-${pc_name}" ${libname}) endif() endforeach() endif() endfunction(pods_install_pkg_config_file) # pods_install_python_script( ) # # Create and install a script that invokes the python interpreter with a # specified module. # # A script will be installed to bin/. The script simply # adds /lib/pythonX.Y/site-packages to the python path, and # then invokes `python -m `. # # example: # pods_install_python_script(run-pdb pdb) function(pods_install_python_script script_name py_module) find_package(PythonInterp REQUIRED) # which python version? execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(sys.version[:3])" OUTPUT_VARIABLE pyversion) # where do we install .py files to? set(python_install_dir ${CMAKE_INSTALL_PREFIX}/lib/python${pyversion}/site-packages) # write the script file file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${script_name} "#!/bin/sh\n" "export PYTHONPATH=${python_install_dir}:\${PYTHONPATH}\n" "exec ${PYTHON_EXECUTABLE} -m ${py_module} $*\n") # install it... install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${script_name} DESTINATION bin) endfunction() # pods_install_python_packages() # # Install python packages to lib/pythonX.Y/site-packages, where X.Y refers to # the current python version (e.g., 2.6) # # Recursively searches for .py files, byte-compiles them, and # installs them function(pods_install_python_packages py_src_dir) find_package(PythonInterp REQUIRED) # which python version? execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(sys.version[:3])" OUTPUT_VARIABLE pyversion) # where do we install .py files to? set(python_install_dir ${CMAKE_INSTALL_PREFIX}/lib/python${pyversion}/site-packages) if(ARGC GREATER 1) message(FATAL_ERROR "NYI") else() # get a list of all .py files file(GLOB_RECURSE py_files RELATIVE ${py_src_dir} ${py_src_dir}/*.py) # add rules for byte-compiling .py --> .pyc foreach(py_file ${py_files}) get_filename_component(py_dirname ${py_file} PATH) add_custom_command(OUTPUT "${py_src_dir}/${py_file}c" COMMAND ${PYTHON_EXECUTABLE} -m py_compile ${py_src_dir}/${py_file} DEPENDS ${py_src_dir}/${py_file}) list(APPEND pyc_files "${py_src_dir}/${py_file}c") # install python file and byte-compiled file install(FILES ${py_src_dir}/${py_file} ${py_src_dir}/${py_file}c DESTINATION "${python_install_dir}/${py_dirname}") # message("${py_src_dir}/${py_file} -> ${python_install_dir}/${py_dirname}") endforeach() string(REGEX REPLACE "[^a-zA-Z0-9]" "_" san_src_dir "${py_src_dir}") add_custom_target("pyc_${san_src_dir}" ALL DEPENDS ${pyc_files}) endif() endfunction() # pods_use_pkg_config_packages( ...) # # Convenience macro to get compiler and linker flags from pkg-config and apply them # to the specified target. # # Invokes `pkg-config --cflags-only-I ...` and adds the result to the # include directories. # # Additionally, invokes `pkg-config --libs ...` and adds the result to # the target's link flags (via target_link_libraries) # # example: # add_executable(myprogram main.c) # pods_use_pkg_config_packages(myprogram glib-2.0 opencv) macro(pods_use_pkg_config_packages target) if(${ARGC} LESS 2) message(WARNING "Useless invocation of pods_use_pkg_config_packages") return() endif() find_package(PkgConfig REQUIRED) execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --cflags-only-I ${ARGN} OUTPUT_VARIABLE _pods_pkg_include_flags) string(STRIP ${_pods_pkg_include_flags} _pods_pkg_include_flags) string(REPLACE "-I" "" _pods_pkg_include_flags "${_pods_pkg_include_flags}") separate_arguments(_pods_pkg_include_flags) # message("include: ${_pods_pkg_include_flags}") execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --libs ${ARGN} OUTPUT_VARIABLE _pods_pkg_ldflags) string(STRIP ${_pods_pkg_ldflags} _pods_pkg_ldflags) # message("ldflags: ${_pods_pkg_ldflags}") include_directories(${_pods_pkg_include_flags}) target_link_libraries(${target} ${_pods_pkg_ldflags}) # make the target depend on libraries being installed by this source build foreach(_pkg ${ARGN}) get_property(_has_dependencies GLOBAL PROPERTY "PODS_PKG_CONFIG_TARGETS-${_pkg}" SET) if(_has_dependencies) get_property(_dependencies GLOBAL PROPERTY "PODS_PKG_CONFIG_TARGETS-${_pkg}") add_dependencies(${target} ${_dependencies}) # message("Found dependencies for ${_pkg}: ${dependencies}") endif() unset(_has_dependencies) unset(_dependencies) endforeach() unset(_pods_pkg_include_flags) unset(_pods_pkg_ldflags) endmacro() # pods_config_search_paths() # # Setup include, linker, and pkg-config paths according to the pods core # policy. This macro is automatically invoked, there is no need to do so # manually. macro(pods_config_search_paths) if(NOT DEFINED __pods_setup) #set where files should be output locally set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) set(INCLUDE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/include) set(PKG_CONFIG_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/pkgconfig) #set where files should be installed to set(LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib) set(EXECUTABLE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/bin) set(INCLUDE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/include) set(PKG_CONFIG_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) # add build/lib/pkgconfig to the pkg-config search path set(ENV{PKG_CONFIG_PATH} ${PKG_CONFIG_INSTALL_PATH}:$ENV{PKG_CONFIG_PATH}) set(ENV{PKG_CONFIG_PATH} ${PKG_CONFIG_OUTPUT_PATH}:$ENV{PKG_CONFIG_PATH}) # add build/include to the compiler include path include_directories(BEFORE ${INCLUDE_OUTPUT_PATH}) include_directories(${INCLUDE_INSTALL_PATH}) # add build/lib to the link path link_directories(${LIBRARY_OUTPUT_PATH}) link_directories(${LIBRARY_INSTALL_PATH}) # abuse RPATH if(${CMAKE_INSTALL_RPATH}) set(CMAKE_INSTALL_RPATH ${LIBRARY_INSTALL_PATH}:${CMAKE_INSTALL_RPATH}) else(${CMAKE_INSTALL_RPATH}) set(CMAKE_INSTALL_RPATH ${LIBRARY_INSTALL_PATH}) endif(${CMAKE_INSTALL_RPATH}) # for osx, which uses "install name" path rather than rpath #set(CMAKE_INSTALL_NAME_DIR ${LIBRARY_OUTPUT_PATH}) set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_RPATH}) # hack to force cmake always create install and clean targets install(FILES DESTINATION) add_custom_target(tmp) set(__pods_setup true) endif(NOT DEFINED __pods_setup) endmacro(pods_config_search_paths) macro(enforce_out_of_source) if(CMAKE_BINARY_DIR STREQUAL PROJECT_SOURCE_DIR) message(FATAL_ERROR "\n Do not run cmake directly in the pod directory. use the supplied Makefile instead! You now need to remove CMakeCache.txt and the CMakeFiles directory. Then to build, simply type: $ make ") endif() endmacro(enforce_out_of_source) #set the variable POD_NAME to the directory path, and set the cmake PROJECT_NAME if(NOT POD_NAME) get_filename_component(POD_NAME ${CMAKE_SOURCE_DIR} NAME) message(STATUS "POD_NAME is not set... Defaulting to directory name: ${POD_NAME}") endif(NOT POD_NAME) project(${POD_NAME}) #make sure we're running an out-of-source build enforce_out_of_source() #call the function to setup paths pods_config_search_paths() ================================================ FILE: data_generation/viewer/src/CMakeLists.txt ================================================ SET(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/opt/local/lib/pkgconfig:/usr/local/share/pkgconfig") pods_install_pkg_config_file(viewer CFLAGS LIBS REQUIRES ${REQUIRED_PACKAGES} VERSION 0.0.1) include_directories(${PROJECT_SOURCE_DIR}/src ${GTK2_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR} ${LCM_INCLUDE_DIRS} ${BOT2_VIS_INCLUDE_DIRS}) add_executable(viewer main_viewer.cpp) pods_use_pkg_config_packages(viewer viewer bot2-core bot2-vis bot2-lcmgl-client renderers) target_link_libraries(viewer ${GTK2_LDFLAGS} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${LCM_LDFLAGS} ${BOT2_VIS_LDFLAGS}) pods_install_executables(viewer) ================================================ FILE: data_generation/viewer/src/main_viewer.cpp ================================================ #include #include //#include #include #include #ifdef __APPLE__ #include #else #include #endif #include using namespace std; typedef struct { BotViewer *viewer; lcm_t *lcm; } viewer_app_t; int main(int argc, char *argv[]) { gtk_init(&argc, &argv); glutInit(&argc, argv); g_thread_init(NULL); setlinebuf(stdout); viewer_app_t app; memset(&app, 0, sizeof(app)); BotViewer *viewer = bot_viewer_new("Viewer"); app.viewer = viewer; app.lcm = lcm_create(NULL); bot_glib_mainloop_attach_lcm(app.lcm); // setup renderers //bot_viewer_add_stock_renderer(viewer, BOT_VIEWER_STOCK_RENDERER_GRID, 0); add_graph_renderer_to_viewer (viewer, 1, app.lcm); // run the main loop gtk_main(); // cleanup bot_viewer_unref(viewer); cout << "RRTstar is alive" << endl; return 1; } ================================================ FILE: data_generation/viewer/src/renderers/CMakeLists.txt ================================================ SET(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/opt/local/lib/pkgconfig:/usr/local/share/pkgconfig") add_library(renderers SHARED graph_renderer.cpp) pods_use_pkg_config_packages(renderers bot2-vis lcmtypes) pods_install_headers(graph_renderer.h DESTINATION renderers) # make the library public pods_install_libraries(renderers) target_link_libraries(renderers ${GTK2_LDFLAGS} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${LCM_LDFLAGS} ${BOT2_VIS_LDFLAGS}) # create a pkg-config file for the library, to make it easier for other # software to use. pods_install_pkg_config_file(renderers CFLAGS LIBS -lrenderers REQUIRES bot2-core bot2-vis lcmtypes VERSION 0.0.1) ================================================ FILE: data_generation/viewer/src/renderers/graph_renderer.cpp ================================================ #include "graph_renderer.h" #include #include #include #include #include #define RENDERER_NAME "Graph Visualizer" using namespace std; class RendererGraph { public: BotRenderer renderer; BotGtkParamWidget *pw; BotViewer *viewer; lcm_t * lcm; lcmtypes_graph_t *graph_last; lcmtypes_environment_t *environment_last; lcmtypes_trajectory_t *trajectory_last; double obstacle_opacity; }; static void graph_message_handler (const lcm_recv_buf_t *rbuf, const char *channel, const lcmtypes_graph_t *msg, void *user) { RendererGraph *self = (RendererGraph *) user; if (self->graph_last) lcmtypes_graph_t_destroy (self->graph_last); self->graph_last = lcmtypes_graph_t_copy (msg); bot_viewer_request_redraw (self->viewer); } static void environment_message_handler (const lcm_recv_buf_t *rbuf, const char *channel, const lcmtypes_environment_t *msg, void *user) { cout<<"here"<environment_last) lcmtypes_environment_t_destroy (self->environment_last); self->environment_last = lcmtypes_environment_t_copy (msg); bot_viewer_request_redraw (self->viewer); } static void trajectory_message_handler (const lcm_recv_buf_t *rbuf, const char *channel, const lcmtypes_trajectory_t *msg, void *user) { RendererGraph *self = (RendererGraph *) user; if (self->trajectory_last) lcmtypes_trajectory_t_destroy (self->trajectory_last); self->trajectory_last = lcmtypes_trajectory_t_copy (msg); bot_viewer_request_redraw (self->viewer); } static void renderer_graph_draw(BotViewer *viewer, BotRenderer *renderer) { RendererGraph *self = (RendererGraph*) renderer; glEnable(GL_DEPTH_TEST); glEnable (GL_BLEND); glEnable (GL_RESCALE_NORMAL); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glShadeModel (GL_SMOOTH); glEnable (GL_LIGHTING); float color_goal[] = { 0.0, 0.0, 1.0,1.0}; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_goal); glPushMatrix (); // root/start state //glTranslated (self->environment_last->goal.center[0], self->environment_last->goal.center[1], self->environment_last->goal.center[2]); glTranslated (0.0, -60.0, 0.0); glRotatef (0.0, 0.0, 0.0, 1.0); //glScalef (self->environment_last->goal.size[0], self->environment_last->goal.size[1], self->environment_last->goal.size[2]); bot_gl_draw_disk (0.0); glPopMatrix (); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_goal); glPushMatrix (); // goal-state //glTranslated (self->environment_last->goal.center[0], self->environment_last->goal.center[1], self->environment_last->goal.center[2]); glTranslated (13.2117605209,-7.65872478485, 0.0); glRotatef (0.0, 0.0, 0.0, 1.0); bot_gl_draw_disk (0.0); glPopMatrix (); if (self->trajectory_last) // if there exist a path solution { //Draw generated trajectory for (int i = 0; i < self->trajectory_last->num_states-1; i++) { glLineWidth (4.0); float color_edge[] ={1.0, 0.0, 0.0, 1.0}; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_edge); glBegin (GL_LINE_STRIP); glVertex3f (self->trajectory_last->states[i].x, self->trajectory_last->states[i].y, self->trajectory_last->states[i].z); glVertex3f (self->trajectory_last->states[i+1].x, self->trajectory_last->states[i+1].y, self->trajectory_last->states[i+1].z); glEnd(); } // Draw the graph if (self->graph_last) { // Draw the vertices glPointSize(1.0); float color_vertex[] = {0.1, 0.1, 0.8, 1.0}; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_vertex); glEnable (GL_POINT_SMOOTH); glBegin (GL_POINTS); for (int i = 0; i < self->graph_last->num_vertices; i++) { glVertex3f (self->graph_last->vertices[i].state.x, self->graph_last->vertices[i].state.y, self->graph_last->vertices[i].state.z); } glEnd(); // Draw the edges for (int i = 0; i < self->graph_last->num_edges; i++) { glLineWidth (1.0); float color_edge[] = {0.8, 0.3, 0.3, 0.8}; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_edge); glBegin (GL_LINE_STRIP); glVertex3f (self->graph_last->edges[i].vertex_src.state.x, self->graph_last->edges[i].vertex_src.state.y, self->graph_last->edges[i].vertex_src.state.z); glVertex3f (self->graph_last->edges[i].vertex_dst.state.x, self->graph_last->edges[i].vertex_dst.state.y, self->graph_last->edges[i].vertex_dst.state.z); glEnd(); } } } //Environments //load obstacle_location file here double fnum[20][2]; ifstream in("obs.dat", ios::in | ios::binary); in.read((char *) &fnum, sizeof fnum); //load obstacle permutations here (see rrts_main for more detail on environment generation) int perm[77520][7]; ifstream in2("obs_perm2.dat", ios::in | ios::binary); in2.read((char *) &perm, sizeof perm); int i=0; //env_no float color_obstacles[] = { 0.37, 0.3, 0.3,((double)(self->obstacle_opacity))/100.0}; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_obstacles); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_obstacles); glPushMatrix (); glTranslated (fnum[perm[i][0]][0],fnum[perm[i][0]][1], 0); glRotatef (0.0, 0.0, 0.0, 1.0); glScalef (5.0,5.0,0.0); bot_gl_draw_cube (); glPopMatrix (); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_obstacles); glPushMatrix (); glTranslated (fnum[perm[i][1]][0],fnum[perm[i][1]][1], 0); glRotatef (0.0, 0.0, 0.0, 1.0); glScalef (5.0,5.0,0.0); bot_gl_draw_cube (); glPopMatrix (); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_obstacles); glPushMatrix (); glTranslated (fnum[perm[i][2]][0],fnum[perm[i][2]][1], 0); glRotatef (0.0, 0.0, 0.0, 1.0); glScalef (5.0,5.0,0.0); bot_gl_draw_cube (); glPopMatrix (); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_obstacles); glPushMatrix (); glTranslated (fnum[perm[i][3]][0],fnum[perm[i][3]][1], 0); glRotatef (0.0, 0.0, 0.0, 1.0); glScalef (5.0,5.0,0.0); bot_gl_draw_cube (); glPopMatrix (); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_obstacles); glPushMatrix (); glTranslated (fnum[perm[i][4]][0],fnum[perm[i][4]][1], 0); glRotatef (0.0, 0.0, 0.0, 1.0); glScalef (5.0,5.0,0.0); bot_gl_draw_cube (); glPopMatrix (); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_obstacles); glPushMatrix (); glTranslated (fnum[perm[i][5]][0],fnum[perm[i][5]][1], 0); glRotatef (0.0, 0.0, 0.0, 1.0); glScalef (5.0,5.0,0.0); bot_gl_draw_cube (); glPopMatrix (); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_obstacles); glPushMatrix (); glTranslated (fnum[perm[i][6]][0],fnum[perm[i][6]][1], 0); glRotatef (0.0, 0.0, 0.0, 1.0); glScalef (5.0,5.0,0.0); bot_gl_draw_cube (); glPopMatrix (); return; } /*Comment out above renderer_graph_draw function in order to use followinh Following function can be adapted to display: -obstacles point-cloud -obstacle-free space (random start-goal pairs) -MPNet generated paths -DeepSMP generated samples TO DO: -Load MPNet generated data from files to publish -Load oracle (RRT*,P-RRT*) generated paths to publish */ /* static void renderer_graph_draw(BotViewer *viewer, BotRenderer *renderer) { RendererGraph *self = (RendererGraph*) renderer; glEnable(GL_DEPTH_TEST); glEnable (GL_BLEND); glEnable (GL_RESCALE_NORMAL); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glShadeModel (GL_SMOOTH); glEnable (GL_LIGHTING); int s=1; int size=50000; double fnum[20][2]; ifstream in("obs.dat", ios::in | ios::binary); in.read((char *) &fnum, sizeof fnum); int perm[77520][7]; ifstream in2("obs_perm2.dat", ios::in | ios::binary); in2.read((char *) &perm, sizeof perm); double obs[size][2]; ifstream in3("graph/graph50.dat", ios::in | ios::binary); in3.read((char *) &obs, sizeof obs); //visualize obstacles point cloud that will be passed on to obstacle space encoder of MPNet //double obs_cloud[1400][2]; //ifstream in4("obs_cloud/obc10000.dat", ios::in | ios::binary); //in4.read((char *) &obs_cloud, sizeof obs_cloud); //cout<<"point cloud"<obstacle_opacity))/100.0}; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_obstacles); glPushMatrix (); glTranslated (fnum[perm[i][0]][0],fnum[perm[i][0]][1], 0); glRotatef (0.0, 0.0, 0.0, 1.0); glScalef (5.0,5.0,0.0); bot_gl_draw_cube (); glPopMatrix (); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_obstacles); glPushMatrix (); glTranslated (fnum[perm[i][1]][0],fnum[perm[i][1]][1], 0); glRotatef (0.0, 0.0, 0.0, 1.0); glScalef (5.0,5.0,0.0); bot_gl_draw_cube (); glPopMatrix (); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_obstacles); glPushMatrix (); glTranslated (fnum[perm[i][2]][0],fnum[perm[i][2]][1], 0); glRotatef (0.0, 0.0, 0.0, 1.0); glScalef (5.0,5.0,0.0); bot_gl_draw_cube (); glPopMatrix (); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_obstacles); glPushMatrix (); glTranslated (fnum[perm[i][3]][0],fnum[perm[i][3]][1], 0); glRotatef (0.0, 0.0, 0.0, 1.0); glScalef (5.0,5.0,0.0); bot_gl_draw_cube (); glPopMatrix (); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_obstacles); glPushMatrix (); glTranslated (fnum[perm[i][4]][0],fnum[perm[i][4]][1], 0); glRotatef (0.0, 0.0, 0.0, 1.0); glScalef (5.0,5.0,0.0); bot_gl_draw_cube (); glPopMatrix (); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_obstacles); glPushMatrix (); glTranslated (fnum[perm[i][5]][0],fnum[perm[i][5]][1], 0); glRotatef (0.0, 0.0, 0.0, 1.0); glScalef (5.0,5.0,0.0); bot_gl_draw_cube (); glPopMatrix (); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color_obstacles); glPushMatrix (); glTranslated (fnum[perm[i][6]][0],fnum[perm[i][6]][1], 0); glRotatef (0.0, 0.0, 0.0, 1.0); glScalef (5.0/s,5.0/s,0.0); bot_gl_draw_cube (); glPopMatrix (); return; }*/ static void renderer_graph_free (BotRenderer *renderer) { RendererGraph *self = (RendererGraph*) renderer; if (self->graph_last) lcmtypes_graph_t_destroy (self->graph_last); free(self); } void add_graph_renderer_to_viewer (BotViewer* viewer, int render_priority, lcm_t* lcm) { RendererGraph *self = new RendererGraph; BotRenderer *renderer = &self->renderer; self->lcm = lcm; self->viewer = viewer; renderer->draw = renderer_graph_draw; renderer->destroy = renderer_graph_free; renderer->widget = gtk_vbox_new(FALSE, 0); renderer->name = (char *) RENDERER_NAME; renderer->user = self; renderer->enabled = 1; self->graph_last = NULL; self->environment_last = NULL; self->trajectory_last = NULL; self->obstacle_opacity = 80; // subscribe to messages lcmtypes_graph_t_subscribe (lcm, "GRAPH", graph_message_handler, self); lcmtypes_environment_t_subscribe (lcm, "ENVIRONMENT", environment_message_handler, self); lcmtypes_trajectory_t_subscribe (lcm, "TRAJECTORY", trajectory_message_handler, self); bot_viewer_add_renderer(viewer, &self->renderer, render_priority); } ================================================ FILE: data_generation/viewer/src/renderers/graph_renderer.h ================================================ #ifndef RACECAR_ROAD_RENDERER_H_ #define RACECAR_ROAD_RENDERER_H_ #include #include #include #include #include #include #ifdef __APPLE__ #include #else #include #endif #ifdef __cplusplus extern "C" { #endif void add_graph_renderer_to_viewer (BotViewer* viewer, int render_priority, lcm_t* lcm); #ifdef __cplusplus } #endif #endif ================================================ FILE: data_generation/viewer/src/renderers/graph_renderer.h~ ================================================ #ifndef RACECAR_ROAD_RENDERER_H_ #define RACECAR_ROAD_RENDERER_H_ #include #include #include #include #include #include #ifdef __APPLE__ #include #else #include #endif #ifdef __cplusplus extern "C" { #endif void add_graph_renderer_to_viewer (BotViewer* viewer, int render_priority, lcm_t* lcm); #ifdef __cplusplus } #endif #endif ================================================ FILE: readme ================================================ data_generation -Contains C++ code to generate expert demonstrations in 2D and 3D environments - Follow the instructions in README file to compile c++ code. MPNet: -AE: Autoencoder codes -data_loader: loads expert demonstrations for training and testing -model: define path generator dataset -neuralplanner: Uses neural models to generate paths -Train: training code MPNet/AE: -data_loader: loads obstacles point-cloud -CAE: Contractive AutoEncoder ================================================ FILE: visualizer.py ================================================ import matplotlib #matplotlib.use('Agg') import matplotlib.pyplot as plt import struct import numpy as np import argparse def main(args): # visualize point cloud (obstacles) obs = [] temp=np.fromfile(args.obs_file) obs.append(temp) obs = np.array(obs).astype(np.float32).reshape(-1,2) plt.scatter(obs[:,0], obs[:,1], c='blue') # visualize path path = np.loadtxt(args.path_file) print(path) path = path.reshape(-1, 2) path_x = [] path_y = [] for i in range(len(path)): path_x.append(path[i][0]) path_y.append(path[i][1]) plt.plot(path_x, path_y, c='r', marker='o') plt.show() parser = argparse.ArgumentParser() # for training parser.add_argument('--obs_file', type=str, default='./data/obs_cloud/obc0.dat',help='obstacle point cloud file') parser.add_argument('--path_file', type=str, default='./results/env_0/path_0.txt',help='path file') args = parser.parse_args() print(args) main(args)