forked from eborghi10/create_autonomy
-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Charles padawan #125
Open
jlurgo
wants to merge
7
commits into
RoboticaUtnFrba:kinetic-devel
Choose a base branch
from
jlurgo:charles_padawan
base: kinetic-devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Charles padawan #125
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6f04538
2 rooms with separation door
jlurgo 3c30e23
added pose and spawned a second robot
jlurgo d076aab
Model plugin and door hinge working
jlurgo b5b8d49
Door pose publication
jlurgo 3098a19
Changes in launchfile
jlurgo 55f1af2
More changes in launchfile
jlurgo 0fb59fc
Using smart pinter for rosnode property of plugin
jlurgo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<launch> | ||
<param name="create1/amcl/initial_pose_x" value="0.29"/> | ||
<param name="create1/amcl/initial_pose_y" value="0.20"/> | ||
<param name="create1/amcl/initial_pose_a" value="-1.57"/> | ||
|
||
<param name="create2/amcl/initial_pose_x" value="0.29"/> | ||
<param name="create2/amcl/initial_pose_y" value="0.55"/> | ||
<param name="create2/amcl/initial_pose_a" value="-1.57"/> | ||
|
||
<include file="$(find ca_gazebo)/launch/create_empty_world.launch"> | ||
<arg name="env" value="two_rooms"/> | ||
</include> | ||
</launch> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#include <ros/ros.h> | ||
#include <sdf/sdf.hh> | ||
#include <ignition/math/Pose3.hh> | ||
#include <ignition/math/Vector3.hh> | ||
#include "gazebo/gazebo.hh" | ||
#include "gazebo/common/Plugin.hh" | ||
#include "gazebo/msgs/msgs.hh" | ||
#include "gazebo/physics/physics.hh" | ||
#include "gazebo/transport/transport.hh" | ||
#include "std_msgs/String.h" | ||
#include "geometry_msgs/Pose.h" | ||
|
||
static const ros::Duration update_rate = ros::Duration(1); // 1 Hz | ||
namespace gazebo | ||
{ | ||
class ModelPosePublisherPlugin : public ModelPlugin | ||
{ | ||
|
||
public: void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/) | ||
{ | ||
// Make sure the ROS node for Gazebo has already been initialized | ||
if (!ros::isInitialized()) | ||
{ | ||
ROS_FATAL_STREAM("A ROS node for Gazebo has not been initialized, unable to load plugin. " | ||
<< "Load the Gazebo system plugin 'libgazebo_ros_api_plugin.so' in the gazebo_ros package)"); | ||
return; | ||
} | ||
ROS_INFO("Model pose publisher started!"); | ||
ROS_INFO("model Name = %s", _parent->GetName().c_str()); | ||
|
||
// Store the pointer to the model | ||
this->model = _parent; | ||
|
||
// Listen to the update event. This event is broadcast every | ||
// simulation iteration. | ||
this->updateConnection = event::Events::ConnectWorldUpdateBegin( | ||
std::bind(&ModelPosePublisherPlugin::OnUpdate, this)); | ||
this->prev_update_time_ = ros::Time::now(); | ||
|
||
this->rosnode_.reset(new ros::NodeHandle("ModelPose")); | ||
this->pub_ = this->rosnode_->advertise<geometry_msgs::Pose>("/ca_gazebo/model_pose", 100); | ||
} | ||
|
||
// Called by the world update start event | ||
public: void OnUpdate() | ||
{ | ||
if ((ros::Time::now() - this->prev_update_time_) < update_rate) { | ||
return; | ||
} | ||
|
||
geometry_msgs::Pose msg; | ||
ignition::math::Pose3d pose = this->model->GetLink("link")->WorldPose(); | ||
msg.position.x = pose.Pos().X(); | ||
msg.position.y = pose.Pos().Y(); | ||
msg.position.z = pose.Pos().Z(); | ||
|
||
msg.orientation.x = pose.Rot().X(); | ||
msg.orientation.y = pose.Rot().Y(); | ||
msg.orientation.z = pose.Rot().Z(); | ||
msg.orientation.w = pose.Rot().W(); | ||
|
||
this->pub_.publish(msg); | ||
|
||
this->prev_update_time_ = ros::Time::now(); | ||
} | ||
|
||
private: std::shared_ptr<ros::NodeHandle> rosnode_; | ||
private: ros::Publisher pub_; | ||
// Pointer to the model | ||
private: physics::ModelPtr model; | ||
|
||
private: ros::Time prev_update_time_; | ||
|
||
// Pointer to the update event connection | ||
private: event::ConnectionPtr updateConnection; | ||
}; | ||
|
||
// Register this plugin with the simulator | ||
GZ_REGISTER_MODEL_PLUGIN(ModelPosePublisherPlugin) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the plugin that you're using to detect whether the robot is docker or not?