-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
445 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
libraries/YarpPlugins/YarpOpenraveRobotManager/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright: (C) 2013 Universidad Carlos III de Madrid | ||
# Author: Juan G. Victores | ||
|
||
yarp_prepare_plugin(YarpOpenraveRobotManager | ||
CATEGORY device | ||
TYPE roboticslab::YarpOpenraveRobotManager | ||
INCLUDE YarpOpenraveRobotManager.hpp | ||
WRAPPER RobotServer) | ||
|
||
IF (NOT SKIP_YarpOpenraveRobotManager) | ||
|
||
SET(CMAKE_MODULE_PATH ${TEO_MODULE_PATH} ${CMAKE_MODULE_PATH}) | ||
FIND_PACKAGE(YARP REQUIRED) | ||
FIND_PACKAGE(OpenRAVE REQUIRED) | ||
find_package(Boost COMPONENTS iostreams python thread system) | ||
|
||
if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX ) | ||
add_definitions("-fno-strict-aliasing -Wall") | ||
endif( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX ) | ||
|
||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${OpenRAVE_INCLUDE_DIRS} ${OPENRAVE_YARP_PLUGINS_INCLUDE_DIRS}) | ||
if( Boost_INCLUDE_DIRS ) | ||
include_directories(${Boost_INCLUDE_DIRS}) | ||
endif() | ||
|
||
LINK_DIRECTORIES(${OPENRAVE_YARP_PLUGINS_LINK_DIRS}) | ||
|
||
YARP_ADD_PLUGIN(YarpOpenraveRobotManager YarpOpenraveRobotManager.hpp DeviceDriverImpl.cpp IRobotManagerImpl.cpp) | ||
add_dependencies(YarpOpenraveRobotManager COLOR_DEBUG YarpOpenraveBase) | ||
set_target_properties(YarpOpenraveRobotManager PROPERTIES COMPILE_FLAGS "${OpenRAVE_CXXFLAGS}") | ||
set_target_properties(YarpOpenraveRobotManager PROPERTIES LINK_FLAGS "${OpenRAVE_LINK_FLAGS}") | ||
TARGET_LINK_LIBRARIES(YarpOpenraveRobotManager ${OpenRAVE_LIBRARIES} ${OpenRAVE_CORE_LIBRARIES} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${YARP_LIBRARIES} YarpOpenraveBase) | ||
|
||
# Exporting dependencies for ...Config.cmake quite manually for now... | ||
set(OPENRAVE_YARP_PLUGINS_INCLUDE_DIRS ${OPENRAVE_YARP_PLUGINS_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "appended header dirs") | ||
#set(OPENRAVE_YARP_PLUGINS_LIBRARIES ${OPENRAVE_YARP_PLUGINS_LIBRARIES} YarpOpenraveRobotManager CACHE INTERNAL "appended libraries") | ||
|
||
#install(TARGETS YarpOpenraveRobotManager DESTINATION lib) | ||
yarp_install(TARGETS YarpOpenraveRobotManager | ||
EXPORT YARP | ||
COMPONENT runtime | ||
LIBRARY DESTINATION ${YARP_DYNAMIC_PLUGINS_INSTALL_DIR} | ||
ARCHIVE DESTINATION ${YARP_STATIC_PLUGINS_INSTALL_DIR}) | ||
|
||
yarp_install(FILES YarpOpenraveRobotManager.ini | ||
COMPONENT runtime | ||
DESTINATION ${YARP_PLUGIN_MANIFESTS_INSTALL_DIR}) | ||
|
||
ENDIF (NOT SKIP_YarpOpenraveRobotManager) | ||
|
54 changes: 54 additions & 0 deletions
54
libraries/YarpPlugins/YarpOpenraveRobotManager/DeviceDriverImpl.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- | ||
|
||
#include "YarpOpenraveRobotManager.hpp" | ||
|
||
namespace roboticslab | ||
{ | ||
|
||
// ------------------- DeviceDriver Related ------------------------------------ | ||
|
||
bool YarpOpenraveRobotManager::open(yarp::os::Searchable& config) | ||
{ | ||
CD_DEBUG("config: %s\n",config.toString().c_str()); | ||
|
||
if ( ! configureEnvironment(config) ) | ||
return false; | ||
|
||
if ( ! configureOpenravePlugins(config) ) | ||
return false; | ||
|
||
if ( ! configureRobot(config) ) | ||
return false; | ||
|
||
//-- Create the controller, make sure to lock environment! | ||
{ | ||
OpenRAVE::EnvironmentMutex::scoped_lock lock(penv->GetMutex()); // lock environment | ||
|
||
pcontrol = OpenRAVE::RaveCreateController(penv,"idealvelocitycontroller"); // idealcontroller, odevelocity, idealvelocitycontroller | ||
|
||
std::vector<int> dofindices( probot->GetDOF() ); | ||
for(int i = 0; i < probot->GetDOF(); ++i) | ||
{ | ||
dofindices[i] = i; | ||
} | ||
|
||
probot->SetController(pcontrol,dofindices,0); | ||
} | ||
|
||
penv->StopSimulation(); | ||
penv->StartSimulation(0.01); | ||
|
||
return true; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
bool YarpOpenraveRobotManager::close() | ||
{ | ||
CD_INFO("\n"); | ||
return true; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
} // namespace roboticslab |
55 changes: 55 additions & 0 deletions
55
libraries/YarpPlugins/YarpOpenraveRobotManager/IRobotManager.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Authors: see AUTHORS.md at project root. | ||
// CopyPolicy: released under the terms of the LGPLv2.1, see LICENSE at project root. | ||
// URL: https://github.com/asrob-uc3m/robotDevastation | ||
|
||
#ifndef __RD_I_ROBOT_MANAGER_HPP__ | ||
#define __RD_I_ROBOT_MANAGER_HPP__ | ||
|
||
|
||
namespace rd{ | ||
|
||
/** | ||
* @ingroup rd_libraries | ||
* | ||
* \defgroup RobotLib | ||
* | ||
* @brief Base class for Robot Managers. Original copy of this file at https://github.com/asrob-uc3m/robotDevastation/blob/develop/src/libraries/RobotLib/IRobotManager.hpp | ||
*/ | ||
class IRobotManager | ||
{ | ||
public: | ||
//-- Robot movement related functions | ||
virtual bool moveForward(int velocity) = 0; | ||
virtual bool moveBackwards(int velocity) = 0; | ||
virtual bool turnLeft(int velocity) = 0; | ||
virtual bool turnRight(int velocity) = 0; | ||
virtual bool stopMovement() = 0; | ||
|
||
//-- Robot camera related functions | ||
virtual bool tiltUp(int velocity) = 0; | ||
virtual bool tiltDown(int velocity) = 0; | ||
virtual bool panLeft(int velocity) = 0; | ||
virtual bool panRight(int velocity) = 0; | ||
virtual bool stopCameraMovement() = 0; | ||
|
||
//-- Robot connection related functions | ||
/// @brief Connect to the remote robot | ||
virtual bool connect() = 0; | ||
|
||
/// @brief Disconnect from the remote robot | ||
virtual bool disconnect() = 0; | ||
|
||
/// @brief Test connection (not in used yet) | ||
virtual bool test() = 0; | ||
|
||
/// @brief Enable/disable sending commands through the manager | ||
virtual void setEnabled(bool enabled) = 0; | ||
|
||
//-- Other | ||
virtual void onDestroy() = 0; | ||
virtual ~IRobotManager() {} | ||
}; | ||
|
||
} | ||
|
||
#endif //-- __RD_I_ROBOT_MANAGER_HPP__ |
148 changes: 148 additions & 0 deletions
148
libraries/YarpPlugins/YarpOpenraveRobotManager/IRobotManagerImpl.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- | ||
|
||
#include "YarpOpenraveRobotManager.hpp" | ||
|
||
namespace roboticslab | ||
{ | ||
|
||
// ------------------- DeviceDriver Related ------------------------------------ | ||
|
||
bool YarpOpenraveRobotManager::moveForward(int velocity) | ||
{ | ||
CD_DEBUG("\n"); | ||
std::vector<OpenRAVE::dReal> values(4, velocity); | ||
pcontrol->SetDesired(values); | ||
return true; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
bool YarpOpenraveRobotManager::moveBackwards(int velocity) | ||
{ | ||
CD_DEBUG("\n"); | ||
std::vector<OpenRAVE::dReal> values(4, -velocity); | ||
pcontrol->SetDesired(values); | ||
return true; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
bool YarpOpenraveRobotManager::turnLeft(int velocity) | ||
{ | ||
CD_DEBUG("\n"); | ||
std::vector<OpenRAVE::dReal> values(4); | ||
values[0] = -velocity; | ||
values[1] = velocity; | ||
values[2] = -velocity; | ||
values[3] = velocity; | ||
pcontrol->SetDesired(values); | ||
return true; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
bool YarpOpenraveRobotManager::turnRight(int velocity) | ||
{ | ||
CD_DEBUG("\n"); | ||
std::vector<OpenRAVE::dReal> values(4); | ||
values[0] = velocity; | ||
values[1] = -velocity; | ||
values[2] = velocity; | ||
values[3] = -velocity; | ||
pcontrol->SetDesired(values); | ||
return true; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
bool YarpOpenraveRobotManager::stopMovement() | ||
{ | ||
CD_DEBUG("\n"); | ||
std::vector<OpenRAVE::dReal> values(4, 0.0); | ||
pcontrol->SetDesired(values); | ||
return true; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
bool YarpOpenraveRobotManager::tiltUp(int velocity) | ||
{ | ||
CD_DEBUG("\n"); | ||
return true; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
bool YarpOpenraveRobotManager::tiltDown(int velocity) | ||
{ | ||
CD_DEBUG("\n"); | ||
return true; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
bool YarpOpenraveRobotManager::panLeft(int velocity) | ||
{ | ||
CD_DEBUG("\n"); | ||
return true; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
bool YarpOpenraveRobotManager::panRight(int velocity) | ||
{ | ||
CD_DEBUG("\n"); | ||
return true; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
bool YarpOpenraveRobotManager::stopCameraMovement() | ||
{ | ||
CD_DEBUG("\n"); | ||
return true; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
bool YarpOpenraveRobotManager::connect() | ||
{ | ||
CD_DEBUG("\n"); | ||
return true; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
bool YarpOpenraveRobotManager::disconnect() | ||
{ | ||
CD_DEBUG("\n"); | ||
return true; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
bool YarpOpenraveRobotManager::test() | ||
{ | ||
CD_DEBUG("\n"); | ||
return true; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
void YarpOpenraveRobotManager::setEnabled(bool enabled) | ||
{ | ||
CD_DEBUG("\n"); | ||
return; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
void YarpOpenraveRobotManager::onDestroy() | ||
{ | ||
CD_DEBUG("\n"); | ||
return; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
} // namespace roboticslab |
Oops, something went wrong.