Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for compiling in Windows #7

Merged
merged 7 commits into from
Oct 2, 2015
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,22 @@ add_subdirectory(urdf_model_state)
add_subdirectory(urdf_world)
add_subdirectory(urdf_exception)

if(WIN32 AND NOT CYGWIN)
set(CMAKE_CONFIG_INSTALL_DIR CMake)
else()
set(CMAKE_CONFIG_INSTALL_DIR share/${PROJECT_NAME}/cmake/)
endif()

set(PACKAGE_NAME ${PROJECT_NAME})
set(cmake_conf_file "${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}-config.cmake")
configure_file("${cmake_conf_file}.in" "${CMAKE_BINARY_DIR}/${cmake_conf_file}" @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/${cmake_conf_file}" DESTINATION share/${PROJECT_NAME}/cmake/ COMPONENT cmake)
set(cmake_conf_file "${PROJECT_NAME}-config.cmake")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/${cmake_conf_file}.in" "${CMAKE_BINARY_DIR}/${cmake_conf_file}" @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/${cmake_conf_file}" DESTINATION ${CMAKE_CONFIG_INSTALL_DIR} COMPONENT cmake)

# Make the package config file
if (NOT MSVC)
set(PACKAGE_DESC "Unified Robot Description Format")
set(pkg_conf_file "${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkgconfig/urdfdom_headers.pc")
configure_file("${pkg_conf_file}.in" "${CMAKE_BINARY_DIR}/${pkg_conf_file}" @ONLY)
set(pkg_conf_file "urdfdom_headers.pc")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkgconfig/${pkg_conf_file}.in" "${CMAKE_BINARY_DIR}/${pkg_conf_file}" @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/${pkg_conf_file}" DESTINATION lib/pkgconfig/ COMPONENT pkgconfig)
endif()

Expand Down
10 changes: 10 additions & 0 deletions urdf_model/include/urdf_model/pose.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,19 @@
#ifndef URDF_INTERFACE_POSE_H
#define URDF_INTERFACE_POSE_H

//For using the M_PI macro in visual studio it
//is necessary to define _USE_MATH_DEFINES
#ifdef _MSC_VER
#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#endif

#include <cmath>
#include <string>
#include <sstream>
#include <vector>

#include <cmath>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<cmath> is already included on line 53

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the second one.

#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
Expand Down
11 changes: 11 additions & 0 deletions urdf_model_state/include/urdf_model_state/model_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@

namespace urdf{

//round is not defined in C++98
//So in Visual Studio <= 2012 is necessary to define it
#ifdef _MSC_VER
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should add a check of version on this. I guess that round was eventually implemented in some recent versions of Visual Studio for C++11 compatibility ( http://www.cplusplus.com/reference/cmath/round/ ).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems std::round was implemented since VS2013. I found some posts that says it's not implemented until VS2012: 1, 2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember that I was developing this PR to compile a project depending on urdfdom in VS2012, so I think this is make sense.

#if (_MSC_VER <= 1700)
double round(double value)
{
return (value >= 0.0f)?(floor(value + 0.5f)):(ceil(value - 0.5f));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of defining this, why not just add 0.5 to the arg of round and call floor() instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they give different results:

round(0.5) = 1.0
round(-0.5) = -1.0
floor(0.5 + 0.5) = 1.0
floor(-0.5 + 0.5) = 0.0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, thanks! i guess we care about negative values :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

}
#endif
#endif

class Time
{
public:
Expand Down