Skip to content
Snippets Groups Projects
Commit 4dcc6add authored by Fabian Aichele's avatar Fabian Aichele Committed by BBP code review
Browse files

Merge "[NRRPLT-2545] Added joint_states topic to gzbridge for passing through...

Merge "[NRRPLT-2545] Added joint_states topic to gzbridge for passing through joint update messages to gz3d."
parents db7b1fb6 6409188b
No related branches found
No related tags found
No related merge requests found
...@@ -47,6 +47,9 @@ GazeboInterface::GazeboInterface() ...@@ -47,6 +47,9 @@ GazeboInterface::GazeboInterface()
this->sensorTopic = "~/sensor"; this->sensorTopic = "~/sensor";
this->visualTopic = "~/visual"; this->visualTopic = "~/visual";
this->jointTopic = "~/joint"; this->jointTopic = "~/joint";
this->jointStatesTopic = "~/joint_states";
this->modelTopic = "~/model/info"; this->modelTopic = "~/model/info";
this->poseTopic = "~/pose/info"; this->poseTopic = "~/pose/info";
this->requestTopic = "~/request"; this->requestTopic = "~/request";
...@@ -74,6 +77,9 @@ GazeboInterface::GazeboInterface() ...@@ -74,6 +77,9 @@ GazeboInterface::GazeboInterface()
this->jointSub = this->node->Subscribe(this->jointTopic, this->jointSub = this->node->Subscribe(this->jointTopic,
&GazeboInterface::OnJointMsg, this); &GazeboInterface::OnJointMsg, this);
this->jointStatesSub = this->node->Subscribe(this->jointStatesTopic,
&GazeboInterface::OnJointStateMsg, this);
// For entity creation // For entity creation
this->modelInfoSub = node->Subscribe(this->modelTopic, this->modelInfoSub = node->Subscribe(this->modelTopic,
&GazeboInterface::OnModelMsg, this); &GazeboInterface::OnModelMsg, this);
...@@ -165,6 +171,9 @@ GazeboInterface::~GazeboInterface() ...@@ -165,6 +171,9 @@ GazeboInterface::~GazeboInterface()
this->sceneMsgs.clear(); this->sceneMsgs.clear();
this->physicsMsgs.clear(); this->physicsMsgs.clear();
this->jointMsgs.clear(); this->jointMsgs.clear();
this->jointStateMsgs.clear();
this->sensorMsgs.clear(); this->sensorMsgs.clear();
this->sensorSub.reset(); this->sensorSub.reset();
...@@ -172,6 +181,9 @@ GazeboInterface::~GazeboInterface() ...@@ -172,6 +181,9 @@ GazeboInterface::~GazeboInterface()
this->lightSub.reset(); this->lightSub.reset();
this->sceneSub.reset(); this->sceneSub.reset();
this->jointSub.reset(); this->jointSub.reset();
this->jointStatesSub.reset();
this->modelInfoSub.reset(); this->modelInfoSub.reset();
this->requestPub.reset(); this->requestPub.reset();
this->modelPub.reset(); this->modelPub.reset();
...@@ -256,6 +268,8 @@ void GazeboInterface::ProcessMessages() ...@@ -256,6 +268,8 @@ void GazeboInterface::ProcessMessages()
static JointMsgs_L::iterator jointIter; static JointMsgs_L::iterator jointIter;
static SensorMsgs_L::iterator sensorIter; static SensorMsgs_L::iterator sensorIter;
static JointStateMsgs_L::iterator jointStateIter;
{ {
boost::recursive_mutex::scoped_lock lock(*this->receiveMutex); boost::recursive_mutex::scoped_lock lock(*this->receiveMutex);
...@@ -679,6 +693,16 @@ void GazeboInterface::ProcessMessages() ...@@ -679,6 +693,16 @@ void GazeboInterface::ProcessMessages()
} }
this->jointMsgs.clear(); this->jointMsgs.clear();
// Forward joint state messages.
for (jointStateIter = this->jointStateMsgs.begin();
jointStateIter != this->jointStateMsgs.end(); ++jointStateIter)
{
msg = this->PackOutgoingTopicMsg(this->jointStatesTopic,
pb2json(*(*jointStateIter).get()));
this->Send(msg);
}
this->jointStateMsgs.clear();
// Forward the request messages // Forward the request messages
for (rIter = this->requestMsgs.begin(); rIter != this->requestMsgs.end(); for (rIter = this->requestMsgs.begin(); rIter != this->requestMsgs.end();
++rIter) ++rIter)
...@@ -1021,6 +1045,19 @@ void GazeboInterface::OnJointMsg(ConstJointPtr &_msg) ...@@ -1021,6 +1045,19 @@ void GazeboInterface::OnJointMsg(ConstJointPtr &_msg)
this->receiveCondition->notify_one(); this->receiveCondition->notify_one();
} }
/////////////////////////////////////////////////
void GazeboInterface::OnJointStateMsg(ConstJointStatePtr &_msg)
{
if (!this->IsConnected())
return;
boost::recursive_mutex::scoped_lock lock(*this->receiveMutex);
this->jointStateMsgs.push_back(_msg);
this->receivedMessage = true;
lock.unlock();
this->receiveCondition->notify_one();
}
///////////////////////////////////////////////// /////////////////////////////////////////////////
void GazeboInterface::OnSensorMsg(ConstSensorPtr &_msg) void GazeboInterface::OnSensorMsg(ConstSensorPtr &_msg)
{ {
......
...@@ -130,6 +130,10 @@ namespace gzweb ...@@ -130,6 +130,10 @@ namespace gzweb
/// \param[in] _msg The message data. /// \param[in] _msg The message data.
private: void OnJointMsg(ConstJointPtr &_msg); private: void OnJointMsg(ConstJointPtr &_msg);
/// \brief Joint message callback.
/// \param[in] _msg The message data.
private: void OnJointStateMsg(ConstJointStatePtr &_msg);
/// \brief Scene message callback. /// \brief Scene message callback.
/// \param[in] _msg The message data. /// \param[in] _msg The message data.
private: void OnSensorMsg(ConstSensorPtr &_msg); private: void OnSensorMsg(ConstSensorPtr &_msg);
...@@ -222,6 +226,9 @@ namespace gzweb ...@@ -222,6 +226,9 @@ namespace gzweb
/// \brief Subscribe to joint updates. /// \brief Subscribe to joint updates.
private: gazebo::transport::SubscriberPtr jointSub; private: gazebo::transport::SubscriberPtr jointSub;
/// \brief Subscribe to joint state updates.
private: gazebo::transport::SubscriberPtr jointStatesSub;
/// \brief Subscribe to road msgs. /// \brief Subscribe to road msgs.
private: gazebo::transport::SubscriberPtr roadSub; private: gazebo::transport::SubscriberPtr roadSub;
...@@ -322,6 +329,14 @@ namespace gzweb ...@@ -322,6 +329,14 @@ namespace gzweb
/// \brief List of joint message to process. /// \brief List of joint message to process.
private: JointMsgs_L jointMsgs; private: JointMsgs_L jointMsgs;
/// \def JointStateMsgs_L
/// \brief List of joint state messages.
typedef std::list<boost::shared_ptr<gazebo::msgs::JointState const> >
JointStateMsgs_L;
/// \brief List of joint message to process.
private: JointStateMsgs_L jointStateMsgs;
/// \def SceneMsgs_L /// \def SceneMsgs_L
/// \brief List of scene messages. /// \brief List of scene messages.
typedef std::list<boost::shared_ptr<gazebo::msgs::Scene const> > typedef std::list<boost::shared_ptr<gazebo::msgs::Scene const> >
...@@ -375,6 +390,9 @@ namespace gzweb ...@@ -375,6 +390,9 @@ namespace gzweb
/// \brief Name of joint topic. /// \brief Name of joint topic.
private: std::string jointTopic; private: std::string jointTopic;
/// \brief Name of joint states topic.
private: std::string jointStatesTopic;
/// \brief Name of model topic. /// \brief Name of model topic.
private: std::string modelTopic; private: std::string modelTopic;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment