Skip to content

Commit

Permalink
make cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Toussaint committed Mar 16, 2018
1 parent 1730517 commit 04245c2
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 27 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ bin_paths = $(shell find bin -maxdepth 2 -name 'Makefile' -printf "%h ")
################################################################################

initUbuntuPackages: force
@echo "##### calling make installUbuntuPackages in each lib"
@find rai -mindepth 1 -maxdepth 1 -type d -exec make installUbuntuPackages -C {} \;
@echo "##### calling make installUbuntu in each lib"
@find rai -mindepth 1 -maxdepth 1 -type d -exec make installUbuntu -C {} \;

tests: $(test_paths:%=makePath/%)
tests: $(test_paths:%=inPath_make/%)

bin: $(bin_paths:%=makePath/%)
bin: $(bin_paths:%=inPath_make/%)

src: $(src_paths:%=makeDepend/%)
src: $(src_paths:%=inPath_makeLib/%)

depend: $(src_paths:%=dependPath/%)

clean: $(src_paths:%=cleanPath/%) cleanLocks
clean: $(src_paths:%=inPath_clean/%) cleanLocks

cleanStart: force
@read -p " *** WARNING: This will rm ALL local files/changes (e.g. project/temporary/data files) - abort if you don't want to continue" yn
Expand All @@ -34,7 +34,7 @@ cleanStart: force

################################################################################

# test: setConfigFlag $(exa_paths:%=cleanPath/%) cleanLocks $(exa_paths:%=makePath/%)
# test: setConfigFlag $(exa_paths:%=inPath_clean/%) cleanLocks $(exa_paths:%=inPath_make/%)

# setConfigFlag: force
# echo "MLR_TESTS = 1" > build/z.mk
Expand Down
6 changes: 6 additions & 0 deletions build/defines.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ ifeq ($(OPENMP),1)
CXXFLAGS += -fopenmp -DOPENMP
endif

ifeq ($(PYBIND),1)
CXXFLAGS += -DRAI_PYBIND `python3-config --cflags`
LIBS += `python3-config --ldflags`
CPATH := $(CPATH):$(BASE)/../pybind11/include
endif

ifeq ($(CUDA),1)
CXXFLAGS += -DMLR_CUDA
NXX = nvcc #$(MLR_LIBPATH)/cuda/bin/
Expand Down
36 changes: 16 additions & 20 deletions build/generic.mk
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,18 @@ include $(BASE)/build/defines.mk
#
################################################################################

ifndef MLR_PATH
MLR_PATH=$(HOME)/git/mlr
endif

MODULE_NAME=$(shell echo $(notdir $(CURDIR)) | tr A-Z a-z)

SWC_FLAGS=-std=c++0x -g
SWC_INCLUDES=-I$(MLR_PATH)/share/src -I/usr/include/python2.7
SWC_LIB_PATH=-L$(MLR_PATH)/share/lib -Xlinker -rpath $(MLR_PATH)/share/lib
SWC_INCLUDES=-I$(BASE)/src -I/usr/include/python2.7
SWC_LIB_PATH=-L$(BASE)/lib -Xlinker -rpath $(BASE)/lib
SWC_CXXFLAGS=-c $(SWC_FLAGS) -fPIC $(SWC_INCLUDES) -DSWIG_TYPE_TABLE=mlr
SWC_LDFLAGS=$(SWC_FLAGS) -shared $(SWC_LIB_PATH) $(SWC_INCLUDES) $(DEPEND:%=-l%) -l$(notdir $(CURDIR))

ifndef SWIG
SWIG=swig2.0
endif
SWIG_INCLUDE=-I$(MLR_PATH)/share/src -I$(MLR_PATH)/share/include/numpy
SWIG_INCLUDE=-I$(BASE)/src -I$(BASE)/include/numpy
SWIG_FLAGS=-c++ -python $(SWIG_INCLUDE)


Expand All @@ -125,7 +121,7 @@ SWIG_FLAGS=-c++ -python $(SWIG_INCLUDE)
#
################################################################################

BUILDS := $(DEPEND:%=makeDepend/%) $(BUILDS)
BUILDS := $(DEPEND:%=inPath_makeLib/%) $(BUILDS)
LIBS := $(DEPEND:%=-l%) $(LIBS)
CXXFLAGS := $(DEPEND:%=-DMLR_%) $(CXXFLAGS)

Expand Down Expand Up @@ -177,7 +173,7 @@ cleanLibs: force
cleanDepends: force
@find $(BASE) -type f -name 'Makefile.dep' -delete -print

installUbuntuPackages: force
installUbuntu: force
sudo apt-get $(APTGETYES) install $(DEPEND_UBUNTU)

depend: generate_Makefile.dep
Expand Down Expand Up @@ -323,39 +319,39 @@ includeAll.cxx: force
#
################################################################################

makeDepend/extern_%: %
inPath_makeLib/extern_%: %
+@-$(BASE)/build/make-path.sh $< libextern_$*.a

makeDepend/Hardware_%: $(BASE)/rai/Hardware/%
inPath_makeLib/Hardware_%: $(BASE)/rai/Hardware/%
+@-$(BASE)/build/make-path.sh $< libHardware_$*.so

makeDepend/%: $(BASE)/rai/%
inPath_makeLib/%: $(BASE)/rai/%
+@-$(BASE)/build/make-path.sh $< lib$*.so

makePath/%: %
inPath_make/%: %
+@-$(BASE)/build/make-path.sh $< x.exe

makeTest/%: %
inPath_makeTest/%: %
+@-$(BASE)/build/make-path.sh $< x.exe MLR_TESTS=1

runPath/%: %
inPath_run/%: %
+@-$(BASE)/build/run-path.sh $< x.exe

cleanPath/%: %
inPath_clean/%: %
@echo " ***** clean " $*
@-rm -f $*/Makefile.dep
@-$(MAKE) -C $* -f Makefile clean --no-print-directory

cleanPath/%: $(BASE)/rai/%
inPath_clean/%: $(BASE)/rai/%
@echo " ***** clean " $<
@-rm -f $</Makefile.dep
@-$(MAKE) -C $< -f Makefile clean --no-print-directory

initUbuntuPackages/%: $(BASE)/rai/%
inPath_installUbuntu/%: $(BASE)/rai/%
@echo " ***** init " $*
@-$(MAKE) -C $< installUbuntuPackages --no-print-directory
@-$(MAKE) -C $< installUbuntu --no-print-directory

makePythonPath/%: %
inPath_makePython/%: %
make --directory=$< pywrapper

$(BASE)/build/config.mk: $(BASE)/../config.mk
Expand Down
85 changes: 85 additions & 0 deletions rai/Kin/retired/contact-18-03-09.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#include "contact.h"
#include <Gui/opengl.h>

double mlr::Contact::getDistance() const{
TM_ContactNegDistance map(*this);
arr y;
map.phi(y, NoArr, a.K);
return -y.scalar();
}

TaskMap *mlr::Contact::getTM_ContactNegDistance() const{
return new TM_ContactNegDistance(*this);
}

void mlr::TM_ContactNegDistance::phi(arr &y, arr &J, const mlr::KinematicWorld &K, int t){
if(C.a_type==2 && C.b_type!=2){
HALT("not checked");
arr ap,an,bp, Jap, Jan, Jbp;
K.kinematicsPos(ap, Jap, &C.a, C.a_rel);
K.kinematicsVec(an, Jan, &C.a, C.a_norm);
K.kinematicsPos(bp, Jbp, &C.b, C.b_rel);

y.resize(1);
y = scalarProduct(bp-ap, an) - (C.a_rad+C.b_rad);
y *= -1.;
if(&J){
J = ~(bp-ap)*Jan + ~an*(Jbp-Jap);
J *= -1.;
}
}
else if(C.b_type==2 && C.a_type!=2){
HALT("not checked");
arr ap,bn,bp, Jap, Jbn, Jbp;
K.kinematicsPos(ap, Jap, &C.a, C.a_rel);
K.kinematicsVec(bn, Jbn, &C.b, C.b_norm);
K.kinematicsPos(bp, Jbp, &C.b, C.b_rel);

y.resize(1);
y = scalarProduct(bp-ap, bn) - (C.a_rad+C.b_rad);
y *= -1.;
if(&J){
J = ~(bp-ap)*Jbn + ~bn*(Jbp-Jap);
J *= -1.;
}
}
else{
arr ap, an, bp, bn, Jap, Jan, Jbp, Jbn;
K.kinematicsPos(ap, (&J?Jap:NoArr), K.frames(C.a.ID), C.a_rel);
K.kinematicsVec(an, (&J?Jan:NoArr), K.frames(C.a.ID), C.a_norm);
K.kinematicsPos(bp, (&J?Jbp:NoArr), K.frames(C.b.ID), C.b_rel);
K.kinematicsVec(bn, (&J?Jbn:NoArr), K.frames(C.b.ID), C.b_norm);


y = ARR( .5*scalarProduct(bp-ap, an-bn) - (C.a_rad+C.b_rad) );
y *= -1.;
if(&J){
J = ~(bp-ap)*(Jan-Jbn) + ~(an-bn)*(Jbp-Jap);
J *= -.5;
}
}
}

#ifdef MLR_GL
void mlr::Contact::glDraw(OpenGL& gl){
mlr::Vector pa = a.X * a_rel;
mlr::Vector pb = b.X * b_rel;
mlr::Vector n = .5*((b.X.rot * b_norm) - (a.X.rot * a_norm));

glLoadIdentity();
glColor(1., 0., 0., 1.);
glLineWidth(3.f);
glDrawProxy(pa.getArr(), pb.getArr(), .05, 0, n.getArr(), a_rad, b_rad);
glLineWidth(2.f);
glLoadIdentity();

// f.pos=.5*(posA+posB);
// f.getAffineMatrixGL(GLmatrix);
// glLoadMatrixd(GLmatrix);
// glDrawText(STRING(a <<'-' <<b <<':' <<d), 0.,0.,0.);
}
#endif

void mlr::Contact::write(std::ostream &os) const{
os <<a.name <<'-' <<b.name <<" type=" <<a_type <<'-' <<b_type <<" dist=" <<getDistance() <<" pDist=" <<get_pDistance() <<" y=" <<y <<" l=" <<lagrangeParameter;
}

0 comments on commit 04245c2

Please sign in to comment.