Beispiel #1
0
        public void Run()
        {
            metadata_pub = rosNodeHandle.advertise <nm.MapMetaData>("map_metadata", 1, true);
            if (metadata_pub != null)
            {
                metadata_pub.publish(mete_data_message_);
            }
            else
            {
                throw new Exception("map_metadata话题发布失败!");
            }
            map_pub = rosNodeHandle.advertise <nm.OccupancyGrid>("map", 1, true);
            if (map_pub != null)
            {
                map_pub.publish(map_resp_.map);
            }
            else
            {
                throw new Exception("map话题发布失败!");
            }

            server = rosNodeHandle.advertiseService <TwoInts.Request, TwoInts.Response>("/add_two_ints", addition);
            //可能rosnet 框架问题,服务不能够发布,后面解决
            service = rosNodeHandle.advertiseService <nm.GetMap.Request, nm.GetMap.Response>("/static_map", mapCallback);
        }
        public void AdvertiseReconfigureService()
        {
            string sn = names.resolve(name, "set_parameters");

            if (timeout == 0)
            {
                try
                {
                    Service.waitForService(sn, 1);
                }
                catch
                {
                    Service.waitForService(sn, timeout);
                }
            }
            else
            {
                Service.waitForService(sn, timeout);
            }
            setServer = nh.advertiseService(sn, (Reconfigure.Request req, ref Reconfigure.Request res) =>
            {
                res.config = req.config;
                return(true);
            });
        }
Beispiel #3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ROS.Init(new string[0], NODE_NAME);

            nodeHandle = new NodeHandle();

            server = nodeHandle.advertiseService <TwoInts.Request, TwoInts.Response>("/add_two_ints", addition);
        }
Beispiel #4
0
         private void Window_Loaded(object sender, RoutedEventArgs e) 
         {
            ROS.Init(new string[0], NODE_NAME);

            nodeHandle = new NodeHandle();

            server = nodeHandle.advertiseService<TwoInts.Request, TwoInts.Response>("/add_two_ints", addition);
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            // Setup the logging system
            var loggerFactory = new LoggerFactory();

            loggerFactory.AddProvider(
                new ConsoleLoggerProvider(
                    (string text, LogLevel logLevel) => { return(logLevel >= LogLevel.Information); }, true)
                );
            Logger = ApplicationLogging.CreateLogger(nameof(Main));
            ROS.SetLoggerFactory(loggerFactory);

            NodeHandle    nodeHandle;
            string        NODE_NAME = "ServiceServerTest";
            ServiceServer server;

            try
            {
                ROS.Init(new string[0], NODE_NAME);
            }
            catch (RosException e)
            {
                Logger.LogCritical("ROS.Init failed, shutting down: {0}", e.Message);
                ROS.shutdown();
                ROS.waitForShutdown();
                return;
            }

            try
            {
                nodeHandle = new NodeHandle();
                server     = nodeHandle.advertiseService <TwoInts.Request, TwoInts.Response>("/add_two_ints", addition);
                while (ROS.ok && server.IsValid)
                {
                    Thread.Sleep(10);
                }
            }
            catch (RosException e)
            {
                Logger.LogCritical("Shutting down: {0}", e.Message);
            }


            ROS.shutdown();
            ROS.waitForShutdown();
        }
Beispiel #6
0
 public void AdvertiseReconfigureService()
 {
     if (timeout == 0)
     {
         try
         {
             Service.waitForService(set_service_name, 1);
         }
         catch
         {
             Service.waitForService(set_service_name, timeout);
         }
     }
     else
     {
         Service.waitForService(set_service_name, timeout);
     }
     setServer = nh.advertiseService(set_service_name, (Reconfigure.Request req, ref Reconfigure.Request res) =>
     {
         res.config = req.config;
         return(true);
     });
 }
Beispiel #7
0
        static void Main(string[] args)
        {
            NodeHandle    nodeHandle;
            string        NODE_NAME = "ServiceServerTest";
            ServiceServer server;

            try
            {
                ROS.Init(new string[0], NODE_NAME);
                var spinner = new AsyncSpinner();
                spinner.Start();
            }
            catch (RosException e)
            {
                ROS.Critical()("ROS.Init failed, shutting down: {0}", e.Message);
                ROS.shutdown();
                ROS.waitForShutdown();
                return;
            }

            try
            {
                nodeHandle = new NodeHandle();
                server     = nodeHandle.advertiseService <TwoInts.Request, TwoInts.Response>("/add_two_ints", addition);
                while (ROS.ok && server.IsValid)
                {
                    Thread.Sleep(10);
                }
            }
            catch (RosException e)
            {
                ROS.Critical()("Shutting down: {0}", e.Message);
            }

            ROS.shutdown();
            ROS.waitForShutdown();
        }
    void OnRosInit()
    {
        nh = ROS.GlobalNodeHandle;
//		nh = new NodeHandle ( "~" );
        pathSrv = nh.advertiseService <GetPath.Request, GetPath.Response> ("quad_rotor/get_path", GetPathService);
//		setOrientSrv = nh.advertiseService<Messages.std_srvs.Empty.Request> ("quad_rotor/reset_orientation", TriggerReset)
//		enableMotorSrv = nh.advertiseService<EnableMotors.Request, EnableMotors.Response> ( "enable_motors", OnEnableMotors );
        nh.setParam("control_mode", "wrench");            // for now force twist mode
        twistSub  = nh.subscribe <Twist> ("quad_rotor/cmd_vel", 10, TwistCallback);
        wrenchSub = nh.subscribe <Wrench> ("quad_rotor/cmd_force", 10, WrenchCallback);
        posePub   = nh.advertise <PoseStamped> ("quad_rotor/pose", 10, false);
        imuPub    = nh.advertise <Imu> ("quad_rotor/imu", 10, false);
//		imgPub = nh.advertise<Image> ( "quad_rotor/image", 10, false );
        pubThread = new Thread(PublishAll);
        pubThread.Start();

        gravitySrv          = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/gravity", GravityService);
        constrainForceXSrv  = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/x_force_constrained", ConstrainForceX);
        constrainForceYSrv  = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/y_force_constrained", ConstrainForceY);
        constrainForceZSrv  = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/z_force_constrained", ConstrainForceZ);
        constrainTorqueXSrv = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/x_torque_constrained", ConstrainTorqueX);
        constrainTorqueYSrv = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/y_torque_constrained", ConstrainTorqueY);
        constrainTorqueZSrv = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/z_torque_constrained", ConstrainTorqueZ);
        triggerResetSrv     = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/reset_orientation", TriggerReset);
//		triggerResetSrv = nh.advertiseService<Empty.Request, Empty.Response> ( "quad_rotor/reset_orientation", TriggerReset );
        setPoseSrv   = nh.advertiseService <SetPose.Request, SetPose.Response> ("quad_rotor/set_pose", SetPoseService);
        clearPathSrv = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/clear_path", ClearPathService);
        setPathSrv   = nh.advertiseService <SetPath.Request, SetPath.Response> ("quad_rotor/set_path", SetPathService);
    }
Beispiel #9
0
 void OnRosInit()
 {
     nh          = ROS.GlobalNodeHandle;
     poseTypeSrv = nh.advertiseService <SetInt.Request, SetInt.Response> ("/quad_rotor/camera_pose_type", SetCameraPoseType);
     distanceSrv = nh.advertiseService <SetFloat.Request, SetFloat.Response> ("/quad_rotor/camera_distance", SetFollowDistance);
 }