Advertisement
Guest User

Untitled

a guest
Sep 10th, 2014
560
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. /*
  2.  * Copyright (C) 2012-2014 Open Source Robotics Foundation
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *     http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  *
  16. */
  17.  
  18. #include <gazebo/gazebo.hh>
  19. #include <gazebo/transport/transport.hh>
  20. #include <gazebo/msgs/msgs.hh>
  21. #include <gazebo/math/gzmath.hh>
  22.  
  23. #include <iostream>
  24.  
  25.  
  26. /////////////////////////////////////////////////
  27. int main(int _argc, char **_argv)
  28. {
  29.   // Load gazebo
  30.   gazebo::setupClient(_argc, _argv);
  31.  
  32.   // Create our node for communication
  33.   gazebo::transport::NodePtr node(new gazebo::transport::Node());
  34.   node->Init();
  35.    
  36.   gazebo::transport::PublisherPtr modelPub = node->Advertise<gazebo::msgs::Model>("~/model/modify");
  37.   // Wait for a subscriber to connect
  38.   modelPub->WaitForConnection();
  39.  
  40.  
  41.   // Publisher loop...replace with your own code.
  42.   while (true)
  43.   {
  44.     // Throttle Publication
  45.     gazebo::common::Time::MSleep(1000);
  46.  
  47.     // Generate a pose
  48.     gazebo::math::Pose pose(10, 10, 0, 0, 0, 0);
  49.  
  50.     gazebo::msgs::Model msg;
  51.     msg.set_name("box"); // name of the model as defined in the .world file
  52.     gazebo::msgs::Set(msg.mutable_pose(), pose);
  53.  
  54.  
  55.     modelPub->Publish(msg);
  56.   }
  57.  
  58.   // Make sure to shut everything down.
  59.   gazebo::shutdown();
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement