Skip to content

Commit

Permalink
Added cmake files only, not including changes with locale yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
JenniferBuehler committed Jan 14, 2016
1 parent bc81514 commit 86d61cf
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 228 deletions.
23 changes: 3 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ find_package(LAPACK REQUIRED)

SET( QT_USE_QT3SUPPORT TRUE )
find_package(Qt4 COMPONENTS QtCore REQUIRED)

# include QT_USE_FILE is needed.
include (${QT_USE_FILE})

# message ("_________________________________________")
# message (${QT_USE_FILE})

set (GSRC ${PROJECT_SOURCE_DIR})

## Uncomment this if the package has a setup.py. This macro ensures
Expand Down Expand Up @@ -110,8 +108,8 @@ set (GSRC ${PROJECT_SOURCE_DIR})
set (PQP_COLLISION false)

set (GRASPIT_DEFINES
#-DGRASPIT_RELEASE
-DGRASPIT_DEBUG
-DGRASPIT_RELEASE
#-DGRASPIT_DEBUG
-DGRASPIT_EXPORTS)

#--------------------------------------- Core sources ---------------------------------
Expand Down Expand Up @@ -152,8 +150,6 @@ set (GRASPIT_HEADERS
${GSRC}/include/gws.h
${GSRC}/include/gwsprojection.h
${GSRC}/include/ivmgr.h
# ${GSRC}/include/ivmgr_nogui.h
# ${GSRC}/include/ivmgr_abstract.h
${GSRC}/include/jacobian.h
${GSRC}/include/joint.h
${GSRC}/include/kinematicChain.h
Expand Down Expand Up @@ -249,7 +245,6 @@ set (MOC_HEADERS


set (GRASPIT_CORE_SOURCES
# ${GSRC}/src/debug.cpp
${GSRC}/src/graspitParser.cpp
${GSRC}/src/arch.cpp
${GSRC}/src/barrett.cpp
Expand All @@ -271,7 +266,6 @@ set (GRASPIT_CORE_SOURCES
${GSRC}/src/gwsprojection.cpp
${GSRC}/src/humanHand.cpp
${GSRC}/src/ivmgr.cpp
# ${GSRC}/src/ivmgr_nogui.cpp
${GSRC}/src/jacobian.cpp
${GSRC}/src/joint.cpp
${GSRC}/src/kinematicChain.cpp
Expand Down Expand Up @@ -580,19 +574,13 @@ set (GRASPIT_DEVEL_UI_DIRNAME ui)
set (GRASPIT_DEVEL_UI_PATH ${CATKIN_DEVEL_PREFIX}/include/${PROJECT_NAME}/${GRASPIT_DEVEL_UI_DIRNAME})
file(MAKE_DIRECTORY ${GRASPIT_DEVEL_UI_PATH})

#message("____________________________")
#message(${CATKIN_DEVEL_PREFIX})
#message(${CMAKE_PREFIX_PATH})

## Make Qt Moc files of GraspIT
# QT4_ADD_RESOURCES(RCC_OUTFILES ${PROJECT_SOURCE_DIR}/icons.qrc)
set (OLD_CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set (CMAKE_CURRENT_BINARY_DIR ${GRASPIT_DEVEL_UI_PATH}) #artificially changing output location for UI files
QT4_WRAP_UI(UI_OUTFILES ${GRASPIT_FORMS})
set (CMAKE_CURRENT_BINARY_DIR ${OLD_CMAKE_CURRENT_BINARY_DIR})

QT4_WRAP_CPP(MOC_OUTFILES ${MOC_HEADERS})


set (GRASPIT_INCLUDES
${GRASPIT_INCLUDES}
Expand All @@ -610,13 +598,10 @@ set (GRASPIT_INCLUDES
# include_directories(include)
include_directories(
${GRASPIT_INCLUDES}
# ${CMAKE_CURRENT_BINARY_DIR}
# ${CMAKE_CURRENT_SOURCE_DIR}
${catkin_INCLUDES}
)



###################################
## catkin specific configuration ##
###################################
Expand All @@ -634,7 +619,6 @@ catkin_package(
)



############
## Build ##
############
Expand All @@ -649,7 +633,6 @@ add_library(graspit
${GRASPIT_FORM_SOURCES}
${UI_OUTFILES}
${MOC_OUTFILES}
# ${RCC_OUTFILES}
)

## Add cmake target dependencies of the library
Expand Down
70 changes: 5 additions & 65 deletions src/EGPlanner/searchState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@
//#define GRASPITDBG
#include "debug.h"


// add locale in order to back up existing locale settings and force them to US
// when using fprintf and scanf commands
#include <locale.h>


SearchVariable::SearchVariable(QString name, double min, double max, double maxJump, bool circular)
{
mName = name;
Expand Down Expand Up @@ -228,41 +222,23 @@ VariableSet::removeParameter(QString name)
void
VariableSet::writeToFile(FILE *fp) const
{

// change locale to make sure all floats in the files read (e.g. with fscanf) are
// expected to have a "dot" floating point (not comma). Backup previous locale setting
// first in order to restore current setting below.
std::locale usLocale("en_US.UTF-8");
std::locale previousLocale=std::locale::global(usLocale);

fprintf(fp,"%d ",getType());
for (int i=0; i<getNumVariables(); i++)
fprintf(fp,"%f ",mVariables[i]->getValue() );
fprintf(fp,"\n");

std::locale::global(previousLocale);
}

bool
VariableSet::readFromFile(FILE *fp)
{
// change locale to make sure all floats in the files read (e.g. with fscanf) are
// expected to have a "dot" floating point (not comma). Backup previous locale setting
// first in order to restore current setting below.
std::locale usLocale("en_US.UTF-8");
std::locale previousLocale=std::locale::global(usLocale);


//read the type first and check against my own
int type;
if( fscanf(fp,"%d",&type) <= 0) {
DBGA("VariableSet::readFromFile - failed to get variable set type");
std::locale::global(previousLocale);
return false;
}
if (type != getType()) {
fprintf(stderr,"Wrong type %d in state file (%d expected)\n",type,getType());
std::locale::global(previousLocale);
return false;
}

Expand All @@ -271,7 +247,6 @@ VariableSet::readFromFile(FILE *fp)
float v;
if (!fgets(line, 10000, fp)) {
fprintf(stderr,"Failed to read data from file!\n");
std::locale::global(previousLocale);
return false;
}
// should really learn how to use streams instead of these hacks...
Expand All @@ -280,15 +255,13 @@ VariableSet::readFromFile(FILE *fp)
for (int i=0; i<getNumVariables(); i++) {
if ( line[offset]=='\0' ) {
fprintf(stderr,"Line to short to read all state variables\n");
std::locale::global(previousLocale);
return false;
}
while( isspace(*(line+offset)) ) offset++;
sscanf(line+offset,"%f",&v);
mVariables[i]->setValue(v);
while( !isspace(*(line+offset)) ) offset++;
}
std::locale::global(previousLocale);
return true;
}

Expand Down Expand Up @@ -342,20 +315,12 @@ VariableSet::distance(const VariableSet *s) const
void
VariableSet::print() const
{
// change locale to make sure all floats in the files read (e.g. with fscanf) are
// expected to have a "dot" floating point (not comma). Backup previous locale setting
// first in order to restore current setting below.
std::locale usLocale("en_US.UTF-8");
std::locale previousLocale=std::locale::global(usLocale);

fprintf(stderr,"\n");
fprintf(stderr,"Type: %d\n",getType());
for (int i=0; i<getNumVariables(); i++) {
fprintf(stderr,"%s = %.2f; ",mVariables[i]->getName().latin1(),mVariables[i]->getValue());
}
fprintf(stderr,"\n");

std::locale::global(previousLocale);
}
//------------------------------- POSTURE STATES -----------------------------------
PostureState* PostureState::createInstance(StateType type, const Hand *h)
Expand Down Expand Up @@ -507,55 +472,30 @@ void HandObjectState::setRefTran(transf t, bool sticky)

bool HandObjectState::readFromFile(FILE *fp)
{

// change locale to make sure all floats in the files read (e.g. with fscanf) are
// expected to have a "dot" floating point (not comma). Backup previous locale setting
// first in order to restore current setting below.
std::locale usLocale("en_US.UTF-8");
std::locale previousLocale=std::locale::global(usLocale);

//this whole read-write system is one big hack.
int type; fpos_t pos;
fgetpos(fp,&pos);
if (!fscanf(fp,"%d",&type)) {
std::locale::global(previousLocale);
return false;
}

if (!fscanf(fp,"%d",&type)) return false;
DBGP("Pose type: " << type);
if ( (StateType)type != POSE_DOF && (StateType)type != POSE_EIGEN ) {
std::locale::global(previousLocale);
return false;
}

if ( (StateType)type != POSE_DOF && (StateType)type != POSE_EIGEN ) return false;
if ( type != mPosture->getType() ) {
setPostureType((StateType)type);
}
fsetpos(fp,&pos);
if ( !mPosture->readFromFile(fp) ) {
DBGA("Failed");
std::locale::global(previousLocale);
return false;
}
fgetpos(fp,&pos);
if (!fscanf(fp,"%d",&type)) {
std::locale::global(previousLocale);
return false;
}
if (!fscanf(fp,"%d",&type)) return false;
DBGP("Space type: " << type);
if ( (StateType)type != SPACE_COMPLETE && (StateType)type != SPACE_APPROACH &&
(StateType)type != SPACE_AXIS_ANGLE && (StateType)type != SPACE_ELLIPSOID ) {
std::locale::global(previousLocale);
return false;
}
(StateType)type != SPACE_AXIS_ANGLE && (StateType)type != SPACE_ELLIPSOID ) return false;
if ( type != mPosition->getType() ) {
setPositionType((StateType)type);
}
fsetpos(fp,&pos);

std::locale::global(previousLocale);

if ( !mPosition->readFromFile(fp) ) return false;
if ( !mPosition->readFromFile(fp) ) return false;
return true;
}

Expand Down
Loading

0 comments on commit 86d61cf

Please sign in to comment.