Skip to content

Commit

Permalink
Moved from transformClient to frameTransformClient (#41)
Browse files Browse the repository at this point in the history
* Moved from transformClient to frameTransformClient

* Specifying the port prefix when opening the frameTransformClient

* Fixed opening of local_rpc port in visualizer.

Added possibility to specify the rpc port name.
  • Loading branch information
S-Dafarra authored Oct 16, 2023
1 parent 6e1c923 commit c81176c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
28 changes: 22 additions & 6 deletions src/devices/openxrheadset/OpenXrHeadset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ bool yarp::dev::OpenXrHeadset::open(yarp::os::Searchable &cfg)
m_prefix = name;
}

std::string rpcName = cfg.check("rpc_name", yarp::os::Value("rpc")).toString();
if (rpcName.front() != '/')
{
m_rpcPortName = m_prefix + '/' + rpcName;
}
else
{
m_rpcPortName = m_prefix + rpcName;
}

//checking the additional guis parameter in the configuration file..
{
constexpr unsigned int STRING = 0;
Expand Down Expand Up @@ -305,9 +315,15 @@ bool yarp::dev::OpenXrHeadset::open(yarp::os::Searchable &cfg)

//opening tf client
yarp::os::Property tfClientCfg;
tfClientCfg.put("device", cfg.check("tfDevice", yarp::os::Value("transformClient")).asString());
tfClientCfg.put("local", cfg.check("tfLocal", yarp::os::Value(m_prefix + "/tf")).asString());
tfClientCfg.put("remote", cfg.check("tfRemote", yarp::os::Value("/transformServer")).asString());
tfClientCfg.put("device", cfg.check("tfDevice", yarp::os::Value("frameTransformClient")).asString());
tfClientCfg.put("filexml_option", cfg.check("tfFile", yarp::os::Value("ftc_yarp_only.xml")).asString());
tfClientCfg.put("ft_client_prefix", cfg.check("tfLocal", yarp::os::Value(m_prefix + "/tf")).asString());
if (cfg.check("tfRemote"))
{
tfClientCfg.put("ft_server_prefix", cfg.find("tfRemote").asString());
}
tfClientCfg.put("period", period);
tfClientCfg.put("local_rpc", m_prefix + "/tf/local_rpc");

if (!m_driver.open(tfClientCfg))
{
Expand All @@ -320,7 +336,7 @@ bool yarp::dev::OpenXrHeadset::open(yarp::os::Searchable &cfg)
yCError(OPENXRHEADSET) << "Unable to view IFrameTransform interface.";
return false;
}
yCInfo(OPENXRHEADSET) << "TransformCLient successfully opened at port: " << cfg.find("tfLocal").asString();
yCInfo(OPENXRHEADSET) << "Transform client successfully opened.";

FilteredPosePublisherSettings posePublisherSettings;
posePublisherSettings.tfPublisher = m_tfPublisher;
Expand Down Expand Up @@ -436,9 +452,9 @@ bool yarp::dev::OpenXrHeadset::threadInit()
std::lock_guard<std::mutex> lock(m_mutex);

this->yarp().attachAsServer(this->m_rpcPort);
if(!m_rpcPort.open(m_prefix + "/rpc"))
if(!m_rpcPort.open(m_rpcPortName))
{
yCError(OPENXRHEADSET) << "Could not open" << m_prefix + "/rpc" << " RPC port.";
yCError(OPENXRHEADSET) << "Could not open" << m_rpcPortName << " RPC port.";
return false;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/devices/openxrheadset/OpenXrHeadset.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ class yarp::dev::OpenXrHeadset : public yarp::dev::DeviceDriver,

OpenXrInterface::Pose m_rootFrameRawHRootFrame;

std::string m_rpcPortName;
yarp::os::Port m_rpcPort;

std::atomic_bool m_closed{ false };
Expand Down
13 changes: 10 additions & 3 deletions src/utils/OpenXrFrameViz/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,17 @@ int main(int argc, char** argv)
return EXIT_FAILURE;
}

std::string name = rf.check("name", yarp::os::Value("OpenXrFrameViewer")).asString();

yarp::os::Property tfClientCfg;
tfClientCfg.put("device", "transformClient");
tfClientCfg.put("local", rf.check("tfLocal", yarp::os::Value("/OpenXrFrameViewer/tf")).asString());
tfClientCfg.put("remote", rf.check("tfRemote", yarp::os::Value("/transformServer")).asString());
tfClientCfg.put("device", rf.check("tfDevice", yarp::os::Value("frameTransformClient")).asString());
tfClientCfg.put("filexml_option", rf.check("tfFile", yarp::os::Value("ftc_yarp_only.xml")).asString());
tfClientCfg.put("ft_client_prefix", "/" + name + "/tf");
if (rf.check("tfRemote"))
{
tfClientCfg.put("ft_server_prefix", rf.find("tfRemote").asString());
}
tfClientCfg.put("local_rpc", "/" + name + "/tf/local_rpc");

yarp::dev::PolyDriver driver;
yarp::dev::IFrameTransform* tfReader;
Expand Down

0 comments on commit c81176c

Please sign in to comment.