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

WholeBodyMasterSlave #1104

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bae6a22
init commit
ishiguroJSK May 30, 2016
053a18e
add bridge for human tracker
ishiguroJSK Jun 8, 2016
c2492bc
Merge branch 'master' into ht-bridge
ishiguroJSK Sep 16, 2016
85f51a1
add neck bridge
ishiguroJSK Dec 20, 2016
39ba859
merge from master
ishiguroJSK Dec 20, 2016
8c60ad7
Merge branch 'master' into ht-bridge
ishiguroJSK Jan 11, 2017
0ccb815
change data type PointStamped -> PoseStamped
ishiguroJSK Jan 18, 2017
3d9679a
cam -> head
ishiguroJSK Feb 8, 2017
f961928
add many debug port for visualization
ishiguroJSK Mar 4, 2017
3bd032b
complete transport ABC->WBMS
ishiguroJSK Apr 22, 2017
9f09b21
fix typo rh lh
ishiguroJSK May 3, 2017
c77fd7a
merge from master
ishiguroJSK May 18, 2017
1efe9a9
Merge branch 'master' into ht-bridge
ishiguroJSK Jun 1, 2017
43dfcf5
Merge branch 'master' of https://github.com/start-jsk/rtmros_common i…
ishiguroJSK Aug 1, 2017
025d22b
import vs-hotfix
ishiguroJSK Aug 22, 2017
f6e17c3
merge from master
ishiguroJSK Mar 26, 2019
0ab1069
use OpenHRP::Wrench instead of Double6
ishiguroJSK May 15, 2019
23ca662
remove undesired files
ishiguroJSK May 15, 2019
f70e89b
add force feedback port
ishiguroJSK Jul 24, 2019
6763bfe
add teleopOdom
ishiguroJSK Aug 22, 2019
c50cbcc
merge
ishiguroJSK Aug 22, 2019
80a1ad8
add haptic controller
ishiguroJSK Aug 27, 2019
6f6e5d1
add MasterSlaveROSBridge
ishiguroJSK Aug 29, 2019
6fc8b35
merge
ishiguroJSK Aug 29, 2019
02c6814
add switch connection group by IS_MASTER_SIDE_OF_MASTERSLAVE
Aug 30, 2019
1aac9a5
up
Aug 30, 2019
1848a59
tune for ee contact
Sep 3, 2019
255c918
update teleopOdom
ishiguroJSK Sep 5, 2019
41587d1
move teleopOdom
ishiguroJSK Sep 6, 2019
53a1ac8
revert HrpsysSeqStateROSBridge to master
ishiguroJSK Sep 6, 2019
52986f0
up
ishiguroJSK Sep 6, 2019
64383c4
add calc delat
ishiguroJSK Oct 23, 2019
bcb9ad0
up
ishiguroJSK Oct 23, 2019
cf2cb18
rhp finger
ishiguroJSK Nov 5, 2019
a932c20
add pose wrench to both side
ishiguroJSK Nov 15, 2019
928c88c
up
ishiguroJSK Jan 7, 2020
f733de0
change path order
Mar 29, 2021
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ msg/_.*\.py$

# Catkin custom files
CATKIN_IGNORE

# gedit
*~
1 change: 1 addition & 0 deletions hrpsys_ros_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ string(RANDOM _random_string)
rtmbuild_add_executable(HrpsysSeqStateROSBridge src/HrpsysSeqStateROSBridgeImpl.cpp src/HrpsysSeqStateROSBridge.cpp src/HrpsysSeqStateROSBridgeComp.cpp)
rtmbuild_add_executable(ImageSensorROSBridge src/ImageSensorROSBridge.cpp src/ImageSensorROSBridgeComp.cpp)
rtmbuild_add_executable(RangeSensorROSBridge src/RangeSensorROSBridge.cpp src/RangeSensorROSBridgeComp.cpp)
rtmbuild_add_executable(MasterSlaveROSBridge src/MasterSlaveROSBridge.cpp src/MasterSlaveROSBridgeComp.cpp)
rtmbuild_add_executable(PointCloudROSBridge src/PointCloudROSBridge.cpp src/PointCloudROSBridgeComp.cpp)
rtmbuild_add_executable(HrpsysJointTrajectoryBridge src/HrpsysJointTrajectoryBridge.cpp src/HrpsysJointTrajectoryBridgeComp.cpp)

Expand Down
75 changes: 73 additions & 2 deletions hrpsys_ros_bridge/launch/hrpsys_ros_bridge.launch

Large diffs are not rendered by default.

361 changes: 361 additions & 0 deletions hrpsys_ros_bridge/src/MasterSlaveROSBridge.cpp

Large diffs are not rendered by default.

108 changes: 108 additions & 0 deletions hrpsys_ros_bridge/src/MasterSlaveROSBridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#ifndef MASTERSLAVEROSBRIDGE_H
#define MASTERSLAVEROSBRIDGE_H

#include <rtm/idl/BasicDataTypeSkel.h>
#include <rtm/idl/InterfaceDataTypes.hh>
#include <rtm/Manager.h>
#include <rtm/DataFlowComponentBase.h>
#include <rtm/CorbaPort.h>
#include <rtm/DataInPort.h>
#include <rtm/DataOutPort.h>
// ros
#include "ros/ros.h"
#include "std_msgs/Time.h"
#include "geometry_msgs/PoseStamped.h"
#include "geometry_msgs/WrenchStamped.h"
//#include <tf/transform_listener.h>
#include <tf/transform_broadcaster.h>

using namespace RTC;

class MasterSlaveROSBridge : public RTC::DataFlowComponentBase
{
public:
MasterSlaveROSBridge(RTC::Manager* manager);
~MasterSlaveROSBridge();
virtual RTC::ReturnCode_t onInitialize();
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id);
void updateOdometryTF(const ros::Time &stamp);
void onMasterTgtPoseCB (const geometry_msgs::PoseStamped::ConstPtr& msg, std::string& key);
void onSlaveTgtPoseCB (const geometry_msgs::PoseStamped::ConstPtr& msg, std::string& key);
void onMasterEEWrenchCB (const geometry_msgs::WrenchStamped::ConstPtr& msg, std::string& key);
void onSlaveEEWrenchCB (const geometry_msgs::WrenchStamped::ConstPtr& msg, std::string& key);
void ondelayCheckPacketCB(const std_msgs::Time::ConstPtr& msg);

protected:
// used in both case
bool is_master_side;
ros::NodeHandle nh;
coil::TimeMeasure tm;
unsigned long loop;
std::vector<std::string> ee_names, tgt_names;
typedef boost::shared_ptr<RTC::InPort <RTC::TimedPose3D> > ITP3_Ptr;
typedef boost::shared_ptr<RTC::InPort <RTC::TimedDoubleSeq> > ITDS_Ptr;
typedef boost::shared_ptr<RTC::OutPort <RTC::TimedPose3D> > OTP3_Ptr;
typedef boost::shared_ptr<RTC::OutPort <RTC::TimedDoubleSeq> > OTDS_Ptr;
std::map<std::string, RTC::TimedPose3D> m_masterTgtPoses;
std::map<std::string, RTC::TimedPose3D> m_slaveTgtPoses;
std::map<std::string, RTC::TimedDoubleSeq> m_masterEEWrenches;
std::map<std::string, RTC::TimedDoubleSeq> m_slaveEEWrenches;

// master side
std::map<std::string, ITP3_Ptr> m_masterTgtPosesIn;
std::map<std::string, OTDS_Ptr> m_slaveEEWrenchesOut;
std::map<std::string, ros::Publisher> masterTgtPoses_pub;
std::map<std::string, ros::Subscriber> slaveEEWrenches_sub;
// sub usage
std::map<std::string, ITDS_Ptr> m_masterEEWrenchesIn;
std::map<std::string, OTP3_Ptr> m_slaveTgtPosesOut;
std::map<std::string, ros::Publisher> masterEEWrenches_pub;
std::map<std::string, ros::Subscriber> slaveTgtPoses_sub;
RTC::TimedPose3D m_teleopOdom;
ITP3_Ptr m_teleopOdomIn;
tf::TransformBroadcaster br;

// slave side
std::map<std::string, ITDS_Ptr> m_slaveEEWrenchesIn;
std::map<std::string, OTP3_Ptr> m_masterTgtPosesOut;
std::map<std::string, ros::Publisher> slaveEEWrenches_pub;
std::map<std::string, ros::Subscriber> masterTgtPoses_sub;
// sub usage
std::map<std::string, ITP3_Ptr> m_slaveTgtPosesIn;
std::map<std::string, OTDS_Ptr> m_masterEEWrenchesOut;
std::map<std::string, ros::Publisher> slaveTgtPoses_pub;
std::map<std::string, ros::Subscriber> masterEEWrenches_sub;

// delay calc
ros::Subscriber delay_check_packet_sub;
ros::Publisher delay_check_packet_pub;
RTC::Time m_delayCheckPacketInbound, m_delayCheckPacketOutbound;
RTC::OutPort<RTC::Time> m_delayCheckPacketInboundOut;
RTC::InPort<RTC::Time> m_delayCheckPacketOutboundIn;

RTC::TimedDoubleSeq m_exData;
RTC::TimedStringSeq m_exDataIndex;
RTC::OutPort<RTC::TimedDoubleSeq> m_exDataOut;
RTC::OutPort<RTC::TimedStringSeq> m_exDataIndexOut;
};


////// copy
#define dbg(var) std::cout<<#var"= "<<(var)<<std::endl
#define dbgn(var) std::cout<<#var"= "<<std::endl<<(var)<<std::endl
#define dbgv(var) std::cout<<#var"= "<<(var.transpose())<<std::endl
#define RTC_INFO_STREAM(var) std::cout << "[" << m_profile.instance_name << "] "<< var << std::endl;
#define RTC_WARN_STREAM(var) std::cerr << "\x1b[31m[" << m_profile.instance_name << "] " << var << "\x1b[39m" << std::endl;

#define eps_eq(a, b, c) (fabs((a)-(b)) <= c)
#define LIMIT_NORM(x,max) (x= ( x<(-max) ? -max : (x>max ? max : x)))
#define LIMIT_MIN(x,min) (x= ( x<min ? min : x ))
#define LIMIT_MAX(x,max) (x= ( x>max ? max : x ))
#define LIMIT_MINMAX(x,min,max) (x= ( x<min ? min : ( x>max ? max : x )))
#define LIMIT_NORM_V(v,max) if(v.norm()>max){v=v.normalized()*max;}
#define LIMIT_MIN_V(v,minv) (v= v.cwiseMax(minv))
#define LIMIT_MAX_V(v,maxv) (v= v.cwiseMin(maxv))
#define LIMIT_MINMAX_V(v,minv,maxv) (v= v.cwiseMin(minv).cwiseMax(maxv))

extern "C"{ DLL_EXPORT void MasterSlaveROSBridgeInit(RTC::Manager* manager);};
#endif // MASTERSLAVEROSBRIDGE_H
50 changes: 50 additions & 0 deletions hrpsys_ros_bridge/src/MasterSlaveROSBridgeComp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// -*- C++ -*-
/*!
* @file MasterSlaveROSBridgeComp.cpp
* @brief Standalone component
* @date $Date$
*
* $Id$
*/
#include <rtm/Manager.h>
#include <iostream>
#include <string>
#include "MasterSlaveROSBridge.h"

void MyModuleInit(RTC::Manager* manager)
{
MasterSlaveROSBridgeInit(manager);
RTC::RtcBase* comp;

// Create a component
comp = manager->createComponent("MasterSlaveROSBridge");

return;
}

int main (int argc, char** argv)
{
RTC::Manager* manager;
manager = RTC::Manager::init(argc, argv);
ros::init(argc, argv, "MasterSlaveROSBridgeComp", ros::init_options::NoSigintHandler);

// Initialize manager
manager->init(argc, argv);

// Set module initialization proceduer
// This procedure will be invoked in activateManager() function.
manager->setModuleInitProc(MyModuleInit);

// Activate manager and register to naming service
manager->activateManager();

// run the manager in blocking mode
// runManager(false) is the default.
manager->runManager();

// If you want to run the manager in non-blocking mode, do like this
// manager->runManager(true);

return 0;
}

2 changes: 2 additions & 0 deletions hrpsys_tools/launch/hrpsys.launch
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
-o "example.EmergencyStopper.config_file:$(arg CONF_FILE)"
-o "example.ReferenceForceUpdater.config_file:$(arg CONF_FILE)"
-o "example.ObjectContactTurnaroundDetector.config_file:$(arg CONF_FILE)"
-o "example.WholeBodyMasterSlave.config_file:$(arg CONF_FILE)"
-o "example.HapticController.config_file:$(arg CONF_FILE)"
-o "example.RobotHardware.config_file:$(arg RobotHardware_conf)"
'/>
<arg name="hrpsys_opt_rtc_config_args" default=''/>
Expand Down
12 changes: 8 additions & 4 deletions rtmbuild/cmake/rtmbuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,17 @@ macro(rtmbuild_init)
rosbuild_gensrv()
endif()

include_directories(${catkin_INCLUDE_DIRS} ${openrtm_aist_INCLUDE_DIRS} ${openhrp3_INCLUDE_DIRS})
#include_directories(${catkin_INCLUDE_DIRS} ${openrtm_aist_INCLUDE_DIRS} ${openhrp3_INCLUDE_DIRS})
include_directories( ${openhrp3_INCLUDE_DIRS} ${openrtm_aist_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})
# since catkin > 0.7.0, the CPATH is no longer being set by catkin, so rtmbuild manually add them
set(_cmake_prefix_path_tmp $ENV{CMAKE_PREFIX_PATH})
string(REPLACE ":" ";" _cmake_prefix_path_tmp ${_cmake_prefix_path_tmp})
foreach(_cmake_prefix_path ${_cmake_prefix_path_tmp})
include_directories(${_cmake_prefix_path}/include)
endforeach()

link_directories(${catkin_LIBRARY_DIRS} ${openrtm_aist_LIBRARY_DIRS} ${openhrp3_LIBRARY_DIRS})
#link_directories(${catkin_LIBRARY_DIRS} ${openrtm_aist_LIBRARY_DIRS} ${openhrp3_LIBRARY_DIRS})
link_directories(${openhrp3_LIBRARY_DIRS} ${openrtm_aist_LIBRARY_DIRS} ${catkin_LIBRARY_DIRS})

endmacro(rtmbuild_init)

Expand Down Expand Up @@ -308,7 +310,8 @@ macro(rtmbuild_add_executable exe)
set_target_properties(${exe} PROPERTIES COMPILE_FLAGS "-Wno-deprecated")
##
add_dependencies(${exe} RTMBUILD_${PROJECT_NAME}_genbridge ${${_package}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS} )
target_link_libraries(${exe} ${catkin_LIBRARIES} ${openrtm_aist_LIBRARIES} ${openhrp3_LIBRARIES} ${${PROJECT_NAME}_IDLLIBRARY_DIRS} )
#target_link_libraries(${exe} ${catkin_LIBRARIES} ${openrtm_aist_LIBRARIES} ${openhrp3_LIBRARIES} ${${PROJECT_NAME}_IDLLIBRARY_DIRS} )
target_link_libraries(${exe} ${openhrp3_LIBRARIES} ${${PROJECT_NAME}_IDLLIBRARY_DIRS} ${openrtm_aist_LIBRARIES} ${catkin_LIBRARIES} )
endmacro(rtmbuild_add_executable)

macro(rtmbuild_add_library lib)
Expand All @@ -318,6 +321,7 @@ macro(rtmbuild_add_library lib)
else()
rosbuild_add_library(${ARGV})
endif()
target_link_libraries(${lib} ${openrtm_aist_LIBRARIES} ${openhrp3_LIBRARIES} ${${PROJECT_NAME}_IDLLIBRARY_DIRS})
#target_link_libraries(${lib} ${openrtm_aist_LIBRARIES} ${openhrp3_LIBRARIES} ${${PROJECT_NAME}_IDLLIBRARY_DIRS})
target_link_libraries(${lib} ${openhrp3_LIBRARIES} ${openrtm_aist_LIBRARIES} ${${PROJECT_NAME}_IDLLIBRARY_DIRS})
endmacro(rtmbuild_add_library)