Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • gsaurel/dynamic_graph_bridge
  • stack-of-tasks/dynamic_graph_bridge
2 results
Show changes
Commits on Source (165)
Showing
with 350 additions and 498 deletions
# format (Guilhem Saurel, 2022-09-06)
426c21a7f4e5b445d17825235f983e2f8e1a86ec
# Please don't edit this file, and use the version generated at include: http://rainboard.laas.fr/project/dynamic_graph_bridge/.gitlab-ci.yml
# http://rainboard.laas.fr/project/dynamic_graph_bridge/.gitlab-ci.yml
variables:
GIT_SUBMODULE_STRATEGY: "recursive"
CCACHE_BASEDIR: "${CI_PROJECT_DIR}"
CCACHE_DIR: "${CI_PROJECT_DIR}/ccache"
cache:
paths:
- ccache
.robotpkg-py-dynamic-graph-bridge-v3: &robotpkg-py-dynamic-graph-bridge-v3
except:
- gh-pages
script:
- mkdir -p ccache
- cd /root/robotpkg/wip
- git pull
- cd py-dynamic-graph-bridge-v3
- make checkout MASTER_REPOSITORY="dir ${CI_PROJECT_DIR}"
- make install
- cd work.$(hostname)/$(make show-var VARNAME=DISTNAME)
- make test
robotpkg-py-dynamic-graph-bridge-v3-14.04-release:
<<: *robotpkg-py-dynamic-graph-bridge-v3
image: eur0c.laas.fr:5000/stack-of-tasks/dynamic_graph_bridge/py-dynamic-graph-bridge-v3:14.04
robotpkg-py-dynamic-graph-bridge-v3-16.04-release:
<<: *robotpkg-py-dynamic-graph-bridge-v3
image: eur0c.laas.fr:5000/stack-of-tasks/dynamic_graph_bridge/py-dynamic-graph-bridge-v3:16.04
robotpkg-py-dynamic-graph-bridge-v3-18.04-release:
<<: *robotpkg-py-dynamic-graph-bridge-v3
image: eur0c.laas.fr:5000/stack-of-tasks/dynamic_graph_bridge/py-dynamic-graph-bridge-v3:18.04
doc-coverage:
<<: *robotpkg-py-dynamic-graph-bridge-v3
image: eur0c.laas.fr:5000/stack-of-tasks/dynamic_graph_bridge/py-dynamic-graph-bridge-v3:16.04
before_script:
- echo -e 'CXXFLAGS+= --coverage\nLDFLAGS+= --coverage\nPKG_DEFAULT_OPTIONS= debug' >> /opt/openrobots/etc/robotpkg.conf
after_script:
- cd /root/robotpkg/wip/py-dynamic-graph-bridge-v3
- cd work.$(hostname)/$(make show-var VARNAME=DISTNAME)
- make doc
- mv doc/doxygen-html ${CI_PROJECT_DIR}
- mkdir -p ${CI_PROJECT_DIR}/coverage/
- gcovr -r .
- gcovr -r . --html --html-details -o ${CI_PROJECT_DIR}/coverage/index.html
artifacts:
expire_in: 1 day
paths:
- doxygen-html/
- coverage/
[submodule "cmake"] [submodule "cmake"]
path = cmake path = cmake
url = git://github.com/jrl-umi3218/jrl-cmakemodules.git url = https://github.com/jrl-umi3218/jrl-cmakemodules.git
ci:
autoupdate_branch: 'devel'
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
args: [--style=Google]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
sudo: required
services:
- docker
before_install:
- docker build -t dyngb-trusty -f ./travis_custom/Dockerfile .
- docker run -t -d --name dyngb-trusty-test dyngb-trusty
- docker exec dyngb-trusty-test sudo mkdir -p /catkin_ws_dyngb/src
- docker exec dyngb-trusty-test sudo sh -c "cd /catkin_ws_dyngb/src;. /opt/ros/indigo/setup.sh;catkin_init_workspace"
- docker exec dyngb-trusty-test sudo git clone --recursive https://github.com/stack-of-tasks/dynamic_graph_bridge.git /catkin_ws_dyngb/src/dynamic_graph_bridge
script:
- docker exec dyngb-trusty-test sudo sh -c "cd /catkin_ws_dyngb;. /opt/ros/indigo/setup.sh;. /home/docker/setup-opt-robotpkg.sh;catkin_make"
# Copyright (C) 2008-2013 LAAS-CNRS, JRL AIST-CNRS. # Copyright (C) 2008-2020 LAAS-CNRS, JRL AIST-CNRS.
# #
# Author: Florent Lamiraux, Nirmal Giftsun # Author: Florent Lamiraux, Nirmal Giftsun, Guilhem Saurel
# #
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Catkin part cmake_minimum_required(VERSION 3.1)
# Project properties
set(PROJECT_ORG stack-of-tasks)
set(PROJECT_NAME dynamic_graph_bridge)
set(PROJECT_DESCRIPTION "Dynamic graph bridge library")
set(PROJECT_URL "https://github.com/${PROJECT_ORG}/${PROJECT_NAME}")
# Project options
option(BUILD_PYTHON_INTERFACE "Build the python bindings" ON)
cmake_minimum_required(VERSION 2.4.6) # Project configuration
set(PROJECT_USE_CMAKE_EXPORT TRUE)
set(CUSTOM_HEADER_DIR ${PROJECT_NAME})
set(CXX_DISABLE_WERROR FALSE)
set(DOXYGEN_USE_MATHJAX YES)
set(CATKIN_ENABLE_TESTING OFF)
# JRL-cmakemodule setup
include(cmake/base.cmake) include(cmake/base.cmake)
INCLUDE(cmake/boost.cmake) include(cmake/boost.cmake)
INCLUDE(cmake/eigen.cmake)
include(cmake/ros.cmake) include(cmake/ros.cmake)
include(cmake/GNUInstallDirs.cmake)
include(cmake/python.cmake)
include(cmake/test.cmake)
project(dynamic_graph_bridge)
SET(CATKIN_REQUIRED_COMPONENTS roscpp std_msgs message_generation std_srvs geometry_msgs sensor_msgs tf)
SET(CATKIN_DEPENDS_LIBRARIES ros_bridge sot_loader)
## LAAS cmake submodule part
set(PROJECT_DESCRIPTION "Dynamic graph bridge library")
set(PROJECT_NAME dynamic_graph_bridge)
set(PROJECT_URL "https://github.com/stack-of-tasks/dynamic_graph_bridge")
set(PROJECT_SUFFIX "-v3")
SET(DOXYGEN_USE_MATHJAX YES)
OPTION (BUILD_PYTHON_INTERFACE "Build the python binding" ON) # Project definition
IF(BUILD_PYTHON_INTERFACE) compute_project_args(PROJECT_ARGS LANGUAGES CXX)
FINDPYTHON() project(${PROJECT_NAME} ${PROJECT_ARGS})
STRING(REGEX REPLACE "-" "_" PY_NAME ${PROJECT_NAME})
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS}) # Project dependencies
ADD_REQUIRED_DEPENDENCY("dynamic-graph-python >= 3.0.0") set(CATKIN_REQUIRED_COMPONENTS
SET(CATKIN_REQUIRED_COMPONENTS ${CATKIN_REQUIRED_COMPONENTS} rospy) roscpp
SET(CATKIN_DEPENDS_LIBRARIES ${CATKIN_DEPENDS_LIBRARIES} ros_interpreter) std_msgs
ENDIF(BUILD_PYTHON_INTERFACE) message_generation
std_srvs
SET(CATKIN_ENABLE_TESTING OFF) geometry_msgs
sensor_msgs
tf2_ros
realtime_tools)
if(BUILD_PYTHON_INTERFACE)
add_project_dependency(dynamic-graph-python 4.0.0 REQUIRED)
string(REGEX REPLACE "-" "_" PY_NAME ${PROJECT_NAME})
set(CATKIN_REQUIRED_COMPONENTS ${CATKIN_REQUIRED_COMPONENTS} rospy)
endif(BUILD_PYTHON_INTERFACE)
add_project_dependency(Boost REQUIRED COMPONENTS program_options)
add_project_dependency(dynamic_graph_bridge_msgs 0.3.0 REQUIRED)
add_project_dependency(sot-core REQUIRED)
if(Boost_VERSION GREATER 107299 OR Boost_VERSION_MACRO GREATER 107299)
# Silence a warning about a deprecated use of boost bind by boost >= 1.73
# without dropping support for boost < 1.73
add_definitions(-DBOOST_BIND_GLOBAL_PLACEHOLDERS)
endif()
find_package(catkin REQUIRED COMPONENTS ${CATKIN_REQUIRED_COMPONENTS}) find_package(catkin REQUIRED COMPONENTS ${CATKIN_REQUIRED_COMPONENTS})
find_package(realtime_tools)
set(CXX_DISABLE_WERROR False) # Main Library
set(CUSTOM_HEADER_DIR dynamic_graph_bridge)
set(${PROJECT_NAME}_HEADERS set(${PROJECT_NAME}_HEADERS
include/dynamic_graph_bridge/ros_init.hh include/${PROJECT_NAME}/fwd.hh
include/dynamic_graph_bridge/sot_loader.hh include/${PROJECT_NAME}/ros_init.hh
include/dynamic_graph_bridge/sot_loader_basic.hh include/${PROJECT_NAME}/sot_loader.hh
) include/${PROJECT_NAME}/sot_loader_basic.hh
include/${PROJECT_NAME}/ros_interpreter.hh
IF(BUILD_PYTHON_INTERFACE) src/converter.hh
set(${PROJECT_NAME}_HEADERS ${${PROJECT_NAME}_HEADERS} src/sot_to_ros.hh)
include/dynamic_graph_bridge/ros_interpreter.hh )
ENDIF(BUILD_PYTHON_INTERFACE) set(${PROJECT_NAME}_SOURCES src/ros_init.cpp src/sot_to_ros.cpp
src/ros_parameter.cpp)
SEARCH_FOR_EIGEN()
SEARCH_FOR_BOOST() add_library(ros_bridge SHARED ${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS})
SETUP_PROJECT() target_include_directories(ros_bridge SYSTEM PUBLIC ${catkin_INCLUDE_DIRS})
target_include_directories(ros_bridge PUBLIC $<INSTALL_INTERFACE:include>)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) target_link_libraries(
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) ros_bridge ${catkin_LIBRARIES} sot-core::sot-core pinocchio::pinocchio
set(CMAKE_INSTALL_RPATH "${LIBRARY_OUTPUT_PATH}") dynamic_graph_bridge_msgs::dynamic_graph_bridge_msgs)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${LIBRARY_OUTPUT_PATH}")
set(PKG_CONFIG_ADDITIONAL_VARIABLES if(SUFFIX_SO_VERSION)
${PKG_CONFIG_ADDITIONAL_VARIABLES} set_target_properties(ros_bridge PROPERTIES SOVERSION ${PROJECT_VERSION})
plugindirname endif(SUFFIX_SO_VERSION)
plugindir
) if(NOT INSTALL_PYTHON_INTERFACE_ONLY)
install(
# Add dependency to SoT specific packages. TARGETS ros_bridge
SET(SOT_PKGNAMES EXPORT ${TARGETS_EXPORT_NAME}
dynamic_graph_bridge_msgs) DESTINATION lib)
endif(NOT INSTALL_PYTHON_INTERFACE_ONLY)
add_required_dependency(roscpp)
add_required_dependency(tf)
add_required_dependency("realtime_tools >= 1.8")
add_required_dependency(tf2_bullet)
ADD_REQUIRED_DEPENDENCY("dynamic-graph >= 3.0.0")
ADD_REQUIRED_DEPENDENCY("sot-core >= 3.0.0")
add_required_dependency(dynamic_graph_bridge_msgs)
foreach(sot_pkgname ${SOT_PKGNAMES})
add_required_dependency(${sot_pkgname})
pkg_check_modules(SOT_${sot_pkgname} REQUIRED ${sot_pkgname})
endforeach(sot_pkgname)
# Build ros_bridge library
add_library(ros_bridge
src/converter.hh
include/dynamic_graph_bridge/ros_init.hh src/ros_init.cpp
src/sot_to_ros.hh src/sot_to_ros.cpp
)
pkg_config_use_dependency(ros_bridge tf2_bullet)
pkg_config_use_dependency(ros_bridge dynamic_graph_bridge_msgs)
install(TARGETS ros_bridge DESTINATION lib)
# Add ros_bridge in the dynamic-graph-bridge pkg-config file.
# Make sure rpath are preserved during the install as ROS dependencies
# are not installed.
set_target_properties(ros_bridge PROPERTIES BUILD_WITH_INSTALL_RPATH True
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
macro(compile_plugin NAME)
message(lib path ${LIBRARY_OUTPUT_PATH})
file(MAKE_DIRECTORY "${LIBRARY_OUTPUT_PATH}/dynamic_graph/ros/${NAME}")
add_library(${NAME} SHARED src/${NAME}.cpp src/${NAME}.hh)
pkg_config_use_dependency(${NAME} dynamic-graph)
pkg_config_use_dependency(${NAME} sot-core)
pkg_config_use_dependency(${NAME} dynamic_graph_bridge_msgs)
add_dependencies(${NAME} ros_bridge)
target_link_libraries(${NAME} ros_bridge)
set_target_properties(${NAME} PROPERTIES BUILD_WITH_INSTALL_RPATH True)
set_target_properties(${NAME} PROPERTIES PREFIX "")
install(TARGETS ${NAME} DESTINATION lib/plugin)
endmacro()
# Build Sot Entities
set(listplugins ros_publish ros_subscribe ros_queued_subscribe ros_tf_listener ros_time)
foreach(aplugin ${listplugins})
compile_plugin(${aplugin})
endforeach()
target_link_libraries(ros_publish ros_bridge)
IF(BUILD_PYTHON_INTERFACE)
foreach(NAME ${listplugins})
dynamic_graph_python_module("ros/${NAME}"
${NAME}
ros/${NAME}/wrap
)
PKG_CONFIG_USE_DEPENDENCY(ros/${NAME}/wrap realtime_tools)
PKG_CONFIG_USE_DEPENDENCY(ros/${NAME}/wrap dynamic_graph)
PKG_CONFIG_USE_DEPENDENCY(ros/${NAME}/wrap sot-core)
PKG_CONFIG_USE_DEPENDENCY(ros/${NAME}/wrap dynamic_graph_bridge_msgs)
endforeach()
# ros_interperter library.
add_library(ros_interpreter src/ros_interpreter.cpp)
pkg_config_use_dependency(ros_interpreter dynamic-graph)
pkg_config_use_dependency(ros_interpreter sot-core)
pkg_config_use_dependency(ros_interpreter roscpp)
pkg_config_use_dependency(ros_interpreter dynamic_graph_bridge_msgs)
pkg_config_use_dependency(ros_interpreter dynamic-graph-python)
add_dependencies(ros_interpreter ros_bridge)
target_link_libraries(ros_interpreter ros_bridge)
set_target_properties(ros_interpreter PROPERTIES BUILD_WITH_INSTALL_RPATH True
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
message(cmakeinstalllibdir " is ${CMAKE_INSTALL_LIBDIR} ")
install(TARGETS ros_interpreter DESTINATION lib)
ENDIF(BUILD_PYTHON_INTERFACE)
# Stand alone embedded intepreter with a robot controller.
add_executable(geometric_simu src/geometric_simu.cpp src/sot_loader.cpp src/sot_loader_basic.cpp)
pkg_config_use_dependency(geometric_simu tf)
pkg_config_use_dependency(geometric_simu roscpp)
pkg_config_use_dependency(geometric_simu dynamic-graph)
target_link_libraries(geometric_simu ros_bridge tf ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
# Sot loader library
add_library(sot_loader src/sot_loader.cpp src/sot_loader_basic.cpp)
pkg_config_use_dependency(sot_loader dynamic-graph)
pkg_config_use_dependency(sot_loader sot-core)
target_link_libraries(sot_loader ${Boost_LIBRARIES} roscpp ros_bridge tf)
install(TARGETS sot_loader DESTINATION lib)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(tests) add_subdirectory(tests)
# Deal with the ROS part. # install ros executables
add_service_files( FILES RunPythonFile.srv ) install(PROGRAMS scripts/robot_pose_publisher scripts/run_command
generate_messages( DEPENDENCIES std_msgs ) scripts/tf_publisher DESTINATION share/${PROJECT_NAME})
# This is necessary so that the pc file generated by catking is similar to the on
# done directly by jrl-cmake-modules
catkin_package(CATKIN_DEPENDS message_runtime roscpp realtime_tools tf2_bullet ${SOT_PKGNAMES} tf
LIBRARIES ${CATKIN_DEPENDS_LIBRARIES}
)
# Add libraries in pc file generated by cmake submodule
PKG_CONFIG_APPEND_LIBS(ros_bridge sot_loader)
IF(BUILD_PYTHON_INTERFACE)
PKG_CONFIG_APPEND_LIBS(ros_interpreter)
#install ros executables
install(PROGRAMS
${CMAKE_SOURCE_DIR}/scripts/robot_pose_publisher
${CMAKE_SOURCE_DIR}/scripts/run_command
${CMAKE_SOURCE_DIR}/scripts/tf_publisher
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
# Service file.
install(FILES ./srv/RunPythonFile.srv DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/srv)
ENDIF(BUILD_PYTHON_INTERFACE)
message(cmake_install_bindir " is ${CMAKE_INSTALL_BINDIR} ")
install(TARGETS geometric_simu DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
install(FILES manifest.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/)
SETUP_PROJECT_FINALIZE() # Install package information
install(FILES manifest.xml package.xml DESTINATION share/${PROJECT_NAME})
dynamic-graph bindings # Dynamic Graph bindings
======================
[![Building Status](https://travis-ci.org/stack-of-tasks/dynamic_graph_bridge.svg?branch=master)](https://travis-ci.org/stack-of-tasks/dynamic_graph_bridge) [![Pipeline status](https://gitlab.laas.fr/stack-of-tasks/dynamic_graph_bridge/badges/master/pipeline.svg)](https://gitlab.laas.fr/stack-of-tasks/dynamic_graph_bridge/commits/master)
[![Pipeline status](https://gepgitlab.laas.fr/stack-of-tasks/dynamic_graph_bridge/badges/master/pipeline.svg)](https://gepgitlab.laas.fr/stack-of-tasks/dynamic_graph_bridge/commits/master) [![Coverage report](https://gitlab.laas.fr/stack-of-tasks/dynamic_graph_bridge/badges/master/coverage.svg?job=doc-coverage)](https://gepettoweb.laas.fr/doc/stack-of-tasks/dynamic_graph_bridge/master/coverage/)
[![Coverage report](https://gepgitlab.laas.fr/stack-of-tasks/dynamic_graph_bridge/badges/master/coverage.svg?job=doc-coverage)](http://projects.laas.fr/gepetto/doc/stack-of-tasks/dynamic_graph_bridge/master/coverage/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/stack-of-tasks/dynamic_graph_bridge/master.svg)](https://results.pre-commit.ci/latest/github/stack-of-tasks/dynamic_graph_bridge)
This ROS package binds together the ROS framework with the This ROS package binds together the ROS framework with the
dynamic-graph real-time control architecture. dynamic-graph real-time control architecture.
Subproject commit 99aafa43694125e67046bdc91c7b6485b5b6ca45 Subproject commit 57c46b2d7b26bb0c25f8f98cfc2a9868e03be603
INPUT = @PROJECT_SOURCE_DIR@/include \ INPUT = @PROJECT_SOURCE_DIR@/include \
@PROJECT_SOURCE_DIR@/doc @PROJECT_SOURCE_DIR@/doc
/*
* Copyright CNRS 2021
*
* Author: Florent Lamiraux
*
* This file is part of sot-core.
*/
#ifndef DYNAMIC_GRAPH_BRIDGE_FWD_HH
#define DYNAMIC_GRAPH_BRIDGE_FWD_HH
#include <dynamic-graph/fwd.hh>
namespace dynamicgraph {
// classes defined in sot-core
class Interpreter;
typedef std::shared_ptr<Interpreter> InterpreterPtr_t;
} // namespace dynamicgraph
#endif // DYNAMIC_GRAPH_PYTHON_FWD_HH
#ifndef ROS_INIT_HH #ifndef ROS_INIT_HH
# define ROS_INIT_HH #define ROS_INIT_HH
# include <ros/ros.h> #include <ros/ros.h>
namespace dynamicgraph namespace dynamicgraph {
{ ros::NodeHandle& rosInit(bool createAsyncSpinner = false,
ros::NodeHandle& rosInit (bool createAsyncSpinner=false, bool createMultiThreadSpinner=true); bool createMultiThreadSpinner = true);
/// \brief Return spinner or throw an exception if spinner /// \brief Return spinner or throw an exception if spinner
/// creation has been disabled at startup. /// creation has been disabled at startup.
ros::AsyncSpinner& spinner (); ros::AsyncSpinner& spinner();
/// \brief Return multi threaded spinner or throw an exception if spinner /// \brief Return multi threaded spinner or throw an exception if spinner
/// creation has been disabled at startup. /// creation has been disabled at startup.
ros::MultiThreadedSpinner& mtSpinner (); ros::MultiThreadedSpinner& mtSpinner();
} // end of namespace dynamicgraph.
} // end of namespace dynamicgraph. #endif //! ROS_INIT_HH
#endif //! ROS_INIT_HH
#ifndef DYNAMIC_GRAPH_BRIDGE_INTERPRETER_HH #ifndef DYNAMIC_GRAPH_BRIDGE_INTERPRETER_HH
# define DYNAMIC_GRAPH_BRIDGE_INTERPRETER_HH #define DYNAMIC_GRAPH_BRIDGE_INTERPRETER_HH
# include <ros/ros.h> #pragma GCC diagnostic push
# include <dynamic_graph_bridge_msgs/RunCommand.h> #pragma GCC system_header
# include <dynamic_graph_bridge_msgs/RunPythonFile.h> #include <ros/ros.h>
# include <dynamic-graph/python/interpreter.hh> #pragma GCC diagnostic pop
namespace dynamicgraph #include <dynamic_graph_bridge_msgs/RunCommand.h>
{ #include <dynamic_graph_bridge_msgs/RunPythonFile.h>
/// \brief This class wraps the implementation of the runCommand
/// service. #include <dynamic-graph/python/interpreter.hh>
/// #include <dynamic_graph_bridge/fwd.hh>
/// This takes as input a ROS node handle and do not handle the
/// callback so that the service behavior can be controlled from namespace dynamicgraph {
/// the outside. /// \brief This class wraps the implementation of the runCommand
class Interpreter /// service.
{ ///
public: /// This takes as input a ROS node handle and do not handle the
typedef boost::function< /// callback so that the service behavior can be controlled from
bool (dynamic_graph_bridge_msgs::RunCommand::Request&, /// the outside.
dynamic_graph_bridge_msgs::RunCommand::Response&)> class Interpreter {
runCommandCallback_t; public:
typedef boost::function<bool(
typedef boost::function< dynamic_graph_bridge_msgs::RunCommand::Request&,
bool (dynamic_graph_bridge_msgs::RunPythonFile::Request&, dynamic_graph_bridge_msgs::RunCommand::Response&)>
dynamic_graph_bridge_msgs::RunPythonFile::Response&)> runCommandCallback_t;
runPythonFileCallback_t;
typedef boost::function<bool(
explicit Interpreter (ros::NodeHandle& nodeHandle); dynamic_graph_bridge_msgs::RunPythonFile::Request&,
dynamic_graph_bridge_msgs::RunPythonFile::Response&)>
/// \brief Method to start python interpreter and deal with messages. runPythonFileCallback_t;
/// \param Command string to execute, result, stdout, stderr strings.
void runCommand(const std::string & command, std::string &result, explicit Interpreter(ros::NodeHandle& nodeHandle);
std::string &out, std::string &err);
/// \brief Method to start python interpreter and deal with messages.
/// \brief Method to parse python scripts. /// \param Command string to execute, result, stdout, stderr strings.
/// \param Input file name to parse. void runCommand(const std::string& command, std::string& result,
void runPythonFile(std::string ifilename); std::string& out, std::string& err);
/// Initialize service run_command /// \brief Method to parse python scripts.
void startRosService (); /// \param Input file name to parse.
void runPythonFile(std::string ifilename);
protected:
/// \brief Run a Python command and return result, stderr and stdout. /// Initialize service run_command
bool runCommandCallback (dynamic_graph_bridge_msgs::RunCommand::Request& req, void startRosService();
dynamic_graph_bridge_msgs::RunCommand::Response& res);
protected:
/// \brief Run a Python file. /// \brief Run a Python command and return result, stderr and stdout.
bool runPythonFileCallback (dynamic_graph_bridge_msgs::RunPythonFile::Request& req, bool runCommandCallback(dynamic_graph_bridge_msgs::RunCommand::Request& req,
dynamic_graph_bridge_msgs::RunPythonFile::Response& res); dynamic_graph_bridge_msgs::RunCommand::Response& res);
private: /// \brief Run a Python file.
python::Interpreter interpreter_; bool runPythonFileCallback(
ros::NodeHandle& nodeHandle_; dynamic_graph_bridge_msgs::RunPythonFile::Request& req,
ros::ServiceServer runCommandSrv_; dynamic_graph_bridge_msgs::RunPythonFile::Response& res);
ros::ServiceServer runPythonFileSrv_;
}; private:
} // end of namespace dynamicgraph. python::Interpreter interpreter_;
ros::NodeHandle& nodeHandle_;
#endif //! DYNAMIC_GRAPH_BRIDGE_INTERPRETER_HH ros::ServiceServer runCommandSrv_;
ros::ServiceServer runPythonFileSrv_;
};
} // end of namespace dynamicgraph.
#endif //! DYNAMIC_GRAPH_BRIDGE_INTERPRETER_HH
#ifndef _ROS_DYNAMIC_GRAPH_PARAMETER_
#define _ROS_DYNAMIC_GRAPH_PARAMETER_
namespace dynamicgraph {
bool parameter_server_read_robot_description();
}
#endif /* _ROS_DYNAMIC_GRAPH_PARAMETER_ */
...@@ -4,17 +4,6 @@ ...@@ -4,17 +4,6 @@
* *
* CNRS * CNRS
* *
* This file is part of dynamic-graph-bridge.
* dynamic-graph-bridge is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
* dynamic-graph-bridge is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. You should
* have received a copy of the GNU Lesser General Public License along
* with dynamic-graph-bridge. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* --- INCLUDES ------------------------------------------------------------- */ /* --- INCLUDES ------------------------------------------------------------- */
...@@ -29,21 +18,25 @@ ...@@ -29,21 +18,25 @@
// STL includes // STL includes
#include <map> #include <map>
// Pinocchio includes
#include <pinocchio/fwd.hpp>
// Boost includes // Boost includes
#include <boost/program_options.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/program_options.hpp>
#include <boost/thread/thread.hpp> #include <boost/thread/thread.hpp>
// ROS includes // ROS includes
#include <sensor_msgs/JointState.h>
#include <tf2_ros/transform_broadcaster.h>
#include "ros/ros.h" #include "ros/ros.h"
#include "std_srvs/Empty.h" #include "std_srvs/Empty.h"
#include <sensor_msgs/JointState.h>
#include <tf/transform_broadcaster.h>
// Sot Framework includes // Sot Framework includes
#include <sot/core/debug.hh>
#include <sot/core/abstract-sot-external-interface.hh> #include <sot/core/abstract-sot-external-interface.hh>
#include <sot/core/debug.hh>
// Dynamic-graph-bridge includes. // Dynamic-graph-bridge includes.
#include <dynamic_graph_bridge/sot_loader_basic.hh> #include <dynamic_graph_bridge/sot_loader_basic.hh>
...@@ -51,20 +44,15 @@ ...@@ -51,20 +44,15 @@
namespace po = boost::program_options; namespace po = boost::program_options;
namespace dgs = dynamicgraph::sot; namespace dgs = dynamicgraph::sot;
class SotLoader : public SotLoaderBasic {
class SotLoader: public SotLoaderBasic protected:
{
protected:
/// Map of sensor readings /// Map of sensor readings
std::map <std::string,dgs::SensorValues> sensorsIn_; std::map<std::string, dgs::SensorValues> sensorsIn_;
/// Map of control values /// Map of control values
std::map<std::string,dgs::ControlValues> controlValues_; std::map<std::string, dgs::ControlValues> controlValues_;
/// Angular values read by encoders /// Angular values read by encoders
std::vector <double> angleEncoder_; std::vector<double> angleEncoder_;
/// Angular values sent to motors /// Angular values sent to motors
std::vector<double> angleControl_; std::vector<double> angleControl_;
/// Forces read by force sensors /// Forces read by force sensors
...@@ -74,26 +62,24 @@ protected: ...@@ -74,26 +62,24 @@ protected:
/// Attitude of the robot computed by extended Kalman filter. /// Attitude of the robot computed by extended Kalman filter.
std::vector<double> baseAtt_; std::vector<double> baseAtt_;
/// Accelerations read by Accelerometers /// Accelerations read by Accelerometers
std::vector <double> accelerometer_; std::vector<double> accelerometer_;
/// Angular velocity read by gyrometers /// Angular velocity read by gyrometers
std::vector <double> gyrometer_; std::vector<double> gyrometer_;
/// URDF string description of the robot. /// URDF string description of the robot.
std::string robot_desc_string_; std::string robot_desc_string_;
/// The thread running dynamic graph /// The thread running dynamic graph
boost::thread thread_; boost::thread thread_;
// \brief Start control loop // \brief Start control loop
virtual void startControlLoop(); virtual void startControlLoop();
// Robot Pose Publisher
tf2_ros::TransformBroadcaster freeFlyerPublisher_;
geometry_msgs::TransformStamped freeFlyerPose_;
//Robot Pose Publisher public:
tf::TransformBroadcaster freeFlyerPublisher_;
tf::Transform freeFlyerPose_;
public:
SotLoader(); SotLoader();
~SotLoader(); ~SotLoader();
...@@ -105,17 +91,13 @@ public: ...@@ -105,17 +91,13 @@ public:
void oneIteration(); void oneIteration();
// \brief Fill the sensors value for the SoT. // \brief Fill the sensors value for the SoT.
void fillSensors(std::map<std::string, void fillSensors(std::map<std::string, dgs::SensorValues> &sensorsIn);
dgs::SensorValues> & sensorsIn);
// \brief Read the control computed by the SoT framework. // \brief Read the control computed by the SoT framework.
void readControl(std::map<std::string, void readControl(std::map<std::string, dgs::ControlValues> &controlValues);
dgs::ControlValues> & controlValues);
// \brief Prepare the SoT framework. // \brief Prepare the SoT framework.
void setup(); void setup();
}; };
#endif /* SOT_LOADER_HH_ */ #endif /* SOT_LOADER_HH_ */
...@@ -4,17 +4,6 @@ ...@@ -4,17 +4,6 @@
* *
* CNRS * CNRS
* *
* This file is part of dynamic_graph_bridge.
* dynamic_graph_bridge is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
* dynamic_graph_bridge is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. You should
* have received a copy of the GNU Lesser General Public License along
* with sot-core. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* --- INCLUDES ------------------------------------------------------------- */ /* --- INCLUDES ------------------------------------------------------------- */
...@@ -29,38 +18,40 @@ ...@@ -29,38 +18,40 @@
// STL includes // STL includes
#include <map> #include <map>
// Pinocchio includes
#include <pinocchio/fwd.hpp>
// Boost includes // Boost includes
#include <boost/program_options.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/program_options.hpp>
// ROS includes // ROS includes
#include <sensor_msgs/JointState.h>
#include "ros/ros.h" #include "ros/ros.h"
#include "std_srvs/Empty.h" #include "std_srvs/Empty.h"
#include <sensor_msgs/JointState.h>
// Sot Framework includes // Sot Framework includes
#include <sot/core/debug.hh>
#include <sot/core/abstract-sot-external-interface.hh> #include <sot/core/abstract-sot-external-interface.hh>
#include <sot/core/debug.hh>
namespace po = boost::program_options; namespace po = boost::program_options;
namespace dgs = dynamicgraph::sot; namespace dgs = dynamicgraph::sot;
class SotLoaderBasic { class SotLoaderBasic {
protected: protected:
// Dynamic graph is stopped. // Dynamic graph is stopped.
bool dynamic_graph_stopped_; bool dynamic_graph_stopped_;
/// \brief the sot-hrp2 controller /// \brief the sot-hrp2 controller
dgs::AbstractSotExternalInterface * sotController_; dgs::AbstractSotExternalInterface* sotController_;
po::variables_map vm_; po::variables_map vm_;
std::string dynamicLibraryName_; std::string dynamicLibraryName_;
/// \brief Handle on the SoT library. /// \brief Handle on the SoT library.
void * sotRobotControllerLibrary_; void* sotRobotControllerLibrary_;
/// \brief Map between SoT state vector and some joint_state_links /// \brief Map between SoT state vector and some joint_state_links
XmlRpc::XmlRpcValue stateVectorMap_; XmlRpc::XmlRpcValue stateVectorMap_;
...@@ -71,7 +62,6 @@ protected: ...@@ -71,7 +62,6 @@ protected:
/// \brief Coefficient between parallel joints and the state vector. /// \brief Coefficient between parallel joints and the state vector.
std::vector<double> coefficient_parallel_joints_; std::vector<double> coefficient_parallel_joints_;
/// Advertises start_dynamic_graph services /// Advertises start_dynamic_graph services
ros::ServiceServer service_start_; ros::ServiceServer service_start_;
...@@ -80,7 +70,7 @@ protected: ...@@ -80,7 +70,7 @@ protected:
// Joint state publication. // Joint state publication.
ros::Publisher joint_pub_; ros::Publisher joint_pub_;
// Joint state to be published. // Joint state to be published.
sensor_msgs::JointState joint_state_; sensor_msgs::JointState joint_state_;
...@@ -88,12 +78,12 @@ protected: ...@@ -88,12 +78,12 @@ protected:
int nbOfJoints_; int nbOfJoints_;
parallel_joints_to_state_vector_t::size_type nbOfParallelJoints_; parallel_joints_to_state_vector_t::size_type nbOfParallelJoints_;
public: public:
SotLoaderBasic(); SotLoaderBasic();
~SotLoaderBasic() {}; ~SotLoaderBasic(){};
// \brief Read user input to extract the path of the SoT dynamic library. // \brief Read user input to extract the path of the SoT dynamic library.
int parseOptions(int argc, char *argv[]); int parseOptions(int argc, char* argv[]);
/// \brief Load the SoT device corresponding to the robot. /// \brief Load the SoT device corresponding to the robot.
void Initialization(); void Initialization();
...@@ -102,16 +92,15 @@ public: ...@@ -102,16 +92,15 @@ public:
void CleanUp(); void CleanUp();
// \brief Create a thread for ROS. // \brief Create a thread for ROS.
virtual void initializeRosNode(int argc, char *argv[]); virtual void initializeRosNode(int argc, char* argv[]);
// \brief Callback function when starting dynamic graph. // \brief Callback function when starting dynamic graph.
bool start_dg(std_srvs::Empty::Request& request, bool start_dg(std_srvs::Empty::Request& request,
std_srvs::Empty::Response& response); std_srvs::Empty::Response& response);
// \brief Callback function when stopping dynamic graph. // \brief Callback function when stopping dynamic graph.
bool stop_dg(std_srvs::Empty::Request& request, bool stop_dg(std_srvs::Empty::Request& request,
std_srvs::Empty::Response& response); std_srvs::Empty::Response& response);
// \brief Read the state vector description based upon the robot links. // \brief Read the state vector description based upon the robot links.
int readSotVectorStateParam(); int readSotVectorStateParam();
...@@ -120,13 +109,10 @@ public: ...@@ -120,13 +109,10 @@ public:
int initPublication(); int initPublication();
// \brief Get Status of dg. // \brief Get Status of dg.
bool isDynamicGraphStopped() bool isDynamicGraphStopped() { return dynamic_graph_stopped_; }
{ return dynamic_graph_stopped_; }
// \brief Specify the name of the dynamic library. // \brief Specify the name of the dynamic library.
void setDynamicLibraryName(std::string &afilename); void setDynamicLibraryName(std::string& afilename);
}; };
#endif /* _SOT_LOADER_BASIC_HH_ */ #endif /* _SOT_LOADER_BASIC_HH_ */
<package format="2"> <package format="2">
<name>dynamic_graph_bridge</name> <name>dynamic_graph_bridge</name>
<version>3.0.8</version> <version>3.4.5</version>
<description> <description>
ROS bindings for dynamic graph. ROS bindings for dynamic graph.
</description> </description>
<maintainer email="hpp@laas.fr">hpp@laas.fr</maintainer> <maintainer email="guilhem.saurel@laas.fr">guilhem.saurel@laas.fr</maintainer>
<author email="hpp@laas.fr">hpp@laas.fr</author> <author email="hpp@laas.fr">hpp@laas.fr</author>
<license>LGPL</license> <license>LGPL</license>
...@@ -16,18 +16,17 @@ ...@@ -16,18 +16,17 @@
<rosdoc config="rosdoc.yaml" /> <rosdoc config="rosdoc.yaml" />
</export> </export>
<buildtool_depend>catkin</buildtool_depend> <buildtool_depend>catkin</buildtool_depend>
<build_depend>std_msgs</build_depend> <build_depend>std_msgs</build_depend>
<build_depend>std_srvs</build_depend> <build_depend>std_srvs</build_depend>
<build_depend>roscpp</build_depend> <build_depend>roscpp</build_depend>
<build_depend>geometry_msgs</build_depend> <build_depend>geometry_msgs</build_depend>
<build_depend>sensor_msgs</build_depend> <build_depend>sensor_msgs</build_depend>
<build_depend>tf</build_depend> <build_depend>tf2_ros</build_depend>
<build_depend>realtime_tools</build_depend> <build_depend>realtime_tools</build_depend>
<build_depend>message_generation</build_depend> <build_depend>message_generation</build_depend>
<build_depend>message_runtime</build_depend> <build_depend>message_runtime</build_depend>
<build_depend>tf2_bullet</build_depend>
<build_depend>dynamic-graph</build_depend> <build_depend>dynamic-graph</build_depend>
<build_depend>dynamic-graph-python</build_depend> <build_depend>dynamic-graph-python</build_depend>
<build_depend>sot-core</build_depend> <build_depend>sot-core</build_depend>
...@@ -39,11 +38,10 @@ ...@@ -39,11 +38,10 @@
<exec_depend>roscpp</exec_depend> <exec_depend>roscpp</exec_depend>
<exec_depend>geometry_msgs</exec_depend> <exec_depend>geometry_msgs</exec_depend>
<exec_depend>sensor_msgs</exec_depend> <exec_depend>sensor_msgs</exec_depend>
<exec_depend>tf</exec_depend> <exec_depend>tf2_ros</exec_depend>
<exec_depend>realtime_tools</exec_depend> <exec_depend>realtime_tools</exec_depend>
<exec_depend>message_generation</exec_depend> <exec_depend>message_generation</exec_depend>
<exec_depend>message_runtime</exec_depend> <exec_depend>message_runtime</exec_depend>
<exec_depend>tf2_bullet</exec_depend>
<exec_depend>dynamic-graph</exec_depend> <exec_depend>dynamic-graph</exec_depend>
<exec_depend>dynamic-graph-python</exec_depend> <exec_depend>dynamic-graph-python</exec_depend>
<exec_depend>sot-core</exec_depend> <exec_depend>sot-core</exec_depend>
......
[tool.black]
exclude = "cmake"
...@@ -8,23 +8,26 @@ import rospy ...@@ -8,23 +8,26 @@ import rospy
import tf import tf
import sensor_msgs.msg import sensor_msgs.msg
frame = '' frame = ""
childFrame = '' childFrame = ""
#DEPRECATED. Robot Pose is already being published
def pose_broadcaster(msg): def pose_broadcaster(msg):
translation = msg.position[0:3]; # DEPRECATED. Robot Pose is already being published
rotation = tf.transformations.quaternion_from_euler(msg.position[3], msg.position[4], msg.position[5]) translation = msg.position[0:3]
rotation = tf.transformations.quaternion_from_euler(
msg.position[3], msg.position[4], msg.position[5]
)
tfbr = tf.TransformBroadcaster() tfbr = tf.TransformBroadcaster()
tfbr.sendTransform(translation, rotation, tfbr.sendTransform(translation, rotation, rospy.Time.now(), childFrame, frame)
rospy.Time.now(), childFrame, frame)
if __name__ == "__main__":
rospy.init_node("robot_pose_publisher", anonymous=True)
if __name__ == '__main__': frame = rospy.get_param("~frame", "odom")
rospy.init_node('robot_pose_publisher', anonymous=True) childFrame = rospy.get_param("~child_frame", "base_link")
topic = rospy.get_param("~topic", "joint_states")
frame = rospy.get_param('~frame', 'odom')
childFrame = rospy.get_param('~child_frame', 'base_link')
topic = rospy.get_param('~topic', 'joint_states')
rospy.Subscriber(topic, sensor_msgs.msg.JointState, pose_broadcaster) rospy.Subscriber(topic, sensor_msgs.msg.JointState, pose_broadcaster)
rospy.spin() rospy.spin()
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import rospy import rospy
import dynamic_graph import dynamic_graph # noqa: F401
import dynamic_graph_bridge_msgs.srv import dynamic_graph_bridge_msgs.srv
import sys import sys
import code import code
...@@ -18,7 +18,8 @@ except ImportError: ...@@ -18,7 +18,8 @@ except ImportError:
print("Module readline not available.") print("Module readline not available.")
# Enable a History # Enable a History
HISTFILE="%s/.pyhistory" % os.environ["HOME"] HISTFILE = "%s/.pyhistory" % os.environ["HOME"]
def savehist(): def savehist():
readline.write_history_file(HISTFILE) readline.write_history_file(HISTFILE)
...@@ -29,30 +30,31 @@ class RosShell(InteractiveConsole): ...@@ -29,30 +30,31 @@ class RosShell(InteractiveConsole):
self.cache = "" self.cache = ""
InteractiveConsole.__init__(self) InteractiveConsole.__init__(self)
rospy.loginfo('waiting for service...') rospy.loginfo("waiting for service...")
rospy.wait_for_service('run_command') rospy.wait_for_service("run_command")
self.client = rospy.ServiceProxy( self.client = rospy.ServiceProxy(
'run_command', dynamic_graph_bridge_msgs.srv.RunCommand, True) "run_command", dynamic_graph_bridge_msgs.srv.RunCommand, True
rospy.wait_for_service('run_script') )
rospy.wait_for_service("run_script")
self.scriptClient = rospy.ServiceProxy( self.scriptClient = rospy.ServiceProxy(
'run_script', dynamic_graph_bridge_msgs.srv.RunPythonFile, True) "run_script", dynamic_graph_bridge_msgs.srv.RunPythonFile, True
)
readline.set_completer(DGCompleter(self.client).complete) readline.set_completer(DGCompleter(self.client).complete)
readline.parse_and_bind("tab: complete") readline.parse_and_bind("tab: complete")
# Read the existing history if there is one # Read the existing history if there is one
if os.path.exists(HISTFILE): if os.path.exists(HISTFILE):
readline.read_history_file(HISTFILE) readline.read_history_file(HISTFILE)
# Set maximum number of items that will be written to the history file # Set maximum number of items that will be written to the history file
readline.set_history_length(300) readline.set_history_length(300)
import atexit import atexit
atexit.register(savehist)
atexit.register(savehist)
def runcode(self, code, retry = True): def runcode(self, code, retry=True):
source = self.cache[:-1] source = self.cache[:-1]
self.cache = "" self.cache = ""
if source != "": if source != "":
...@@ -60,50 +62,53 @@ class RosShell(InteractiveConsole): ...@@ -60,50 +62,53 @@ class RosShell(InteractiveConsole):
if not self.client: if not self.client:
print("Connection to remote server lost. Reconnecting...") print("Connection to remote server lost. Reconnecting...")
self.client = rospy.ServiceProxy( self.client = rospy.ServiceProxy(
'run_command', dynamic_graph_bridge_msgs.srv.RunCommand, True) "run_command", dynamic_graph_bridge_msgs.srv.RunCommand, True
)
if retry: if retry:
print("Retrying previous command...") print("Retrying previous command...")
self.cache = source self.cache = source
return self.runcode(code, False) return self.runcode(code, False)
response = self.client(str(source)) response = self.client(str(source))
if response.standardoutput != "": if response.standardoutput != "":
print response.standardoutput[:-1] print(response.standardoutput[:-1])
if response.standarderror != "": if response.standarderror != "":
print response.standarderror[:-1] print(response.standarderror[:-1])
elif response.result != "None": elif response.result != "None":
print response.result print(response.result)
except rospy.ServiceException, e: except rospy.ServiceException:
print("Connection to remote server lost. Reconnecting...") print("Connection to remote server lost. Reconnecting...")
self.client = rospy.ServiceProxy( self.client = rospy.ServiceProxy(
'run_command', dynamic_graph_bridge_msgs.srv.RunCommand, True) "run_command", dynamic_graph_bridge_msgs.srv.RunCommand, True
)
if retry: if retry:
print("Retrying previous command...") print("Retrying previous command...")
self.cache = source self.cache = source
self.runcode(code, False) self.runcode(code, False)
def runsource(self, source, filename = '<input>', symbol = 'single'): def runsource(self, source, filename="<input>", symbol="single"):
try: try:
c = code.compile_command(source, filename, symbol) c = code.compile_command(source, filename, symbol)
if c: if c:
return self.runcode(c) return self.runcode(c)
else: else:
return True return True
except SyntaxError, OverflowError: except (SyntaxError, OverflowError):
self.showsyntaxerror() self.showsyntaxerror()
self.cache = "" self.cache = ""
return False return False
def push(self,line): def push(self, line):
self.cache += line + "\n" self.cache += line + "\n"
return InteractiveConsole.push(self,line) return InteractiveConsole.push(self, line)
if __name__ == '__main__':
if __name__ == "__main__":
import optparse import optparse
import os.path import os.path
rospy.init_node('run_command', argv=sys.argv)
rospy.init_node("run_command", argv=sys.argv)
sys.argv = rospy.myargv(argv=None) sys.argv = rospy.myargv(argv=None)
parser = optparse.OptionParser( parser = optparse.OptionParser(usage="\n\t%prog [options]")
usage='\n\t%prog [options]')
(options, args) = parser.parse_args(sys.argv[1:]) (options, args) = parser.parse_args(sys.argv[1:])
sh = RosShell() sh = RosShell()
...@@ -118,6 +123,6 @@ if __name__ == '__main__': ...@@ -118,6 +123,6 @@ if __name__ == '__main__':
if not response: if not response:
print("Error while file parsing ") print("Error while file parsing ")
else: else:
print("Provided file does not exist: %s"%(infile)) print("Provided file does not exist: %s" % (infile))
else: else:
sh.interact("Interacting with remote server.") sh.interact("Interacting with remote server.")
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
# through dynamic_graph_bridge. # through dynamic_graph_bridge.
# #
import logging
import rospy import rospy
import tf import tf
...@@ -13,15 +15,15 @@ import geometry_msgs.msg ...@@ -13,15 +15,15 @@ import geometry_msgs.msg
def main(): def main():
rospy.init_node('tf_publisher', anonymous=True) rospy.init_node("tf_publisher", anonymous=True)
frame = rospy.get_param('~frame', '') frame = rospy.get_param("~frame", "")
childFrame = rospy.get_param('~child_frame', '') childFrame = rospy.get_param("~child_frame", "")
topic = rospy.get_param('~topic', '') topic = rospy.get_param("~topic", "")
rateSeconds = rospy.get_param('~rate', 5) rateSeconds = rospy.get_param("~rate", 5)
if not frame or not childFrame or not topic: if not frame or not childFrame or not topic:
logpy.error("frame, childFrame and topic are required parameters") logging.error("frame, childFrame and topic are required parameters")
return return
rate = rospy.Rate(rateSeconds) rate = rospy.Rate(rateSeconds)
...@@ -35,11 +37,10 @@ def main(): ...@@ -35,11 +37,10 @@ def main():
ok = False ok = False
while not rospy.is_shutdown() and not ok: while not rospy.is_shutdown() and not ok:
try: try:
tl.waitForTransform(childFrame, frame, tl.waitForTransform(childFrame, frame, rospy.Time(), rospy.Duration(0.1))
rospy.Time(), rospy.Duration(0.1))
ok = True ok = True
except tf.Exception, e: except tf.Exception:
rospy.logwarn("waiting for tf transform") logging.warning("waiting for tf transform")
ok = False ok = False
while not rospy.is_shutdown(): while not rospy.is_shutdown():
...@@ -60,4 +61,5 @@ def main(): ...@@ -60,4 +61,5 @@ def main():
pub.publish(transform) pub.publish(transform)
rate.sleep() rate.sleep()
main() main()