コード例 #1
0
    /*
     * private void HandleImage(ROSAgent sender, CompressedImageMsg compressedImage, CameraInfo info)
     * {
     *  lock (_cameraDataToConsume)
     *  {
     *      _cameraInfoToConsume = info;
     *      _cameraDataToConsume = compressedImage;
     *      _hasCameraDataToConsume = true;
     *  }
     * }*/

    protected override void StartROS()
    {
        _rosLocomotionDirect        = new ROSLocomotionDirect(ROSAgent.AgentJob.Publisher, _rosBridge, "/cmd_vel");
        _rosLocomotionWaypoint      = new ROSLocomotionWaypoint(ROSAgent.AgentJob.Publisher, _rosBridge, "/waypoint");
        _rosLocomotionWaypointState = new ROSLocomotionWaypointState(ROSAgent.AgentJob.Publisher, _rosBridge, "/waypoint/state");
        _rosLocomotionControlParams = new ROSLocomotionControlParams(ROSAgent.AgentJob.Publisher, _rosBridge, "/waypoint/control_parameters");
        _rosLocomotionLinear        = new ROSGenericPublisher(_rosBridge, "/waypoint/max_linear_speed", Float32Msg.GetMessageType());
        _rosLocomotionAngular       = new ROSGenericPublisher(_rosBridge, "/waypoint/max_angular_speed", Float32Msg.GetMessageType());
        _rosOdometryOverride        = new ROSGenericPublisher(_rosBridge, "/odo_calib_pose", OdometryMsg.GetMessageType());
        _rosReset  = new ROSGenericPublisher(_rosBridge, "arlobot/reset_motorBoard", BoolMsg.GetMessageType());
        _rosLogger = new ROSGenericPublisher(_rosBridge, "/debug_output", StringMsg.GetMessageType());

        _rosUltrasound = new ROSGenericSubscriber <StringMsg>(_rosBridge, "/ultrasonic_data", StringMsg.GetMessageType(), (msg) => new StringMsg(msg));
        _rosUltrasound.OnDataReceived += ReceivedUltrasoundUpdata;
        _rosOdometry = new ROSGenericSubscriber <OdometryMsg>(_rosBridge, "/robot_gps_pose", OdometryMsg.GetMessageType(), (msg) => new OdometryMsg(msg));
        _rosOdometry.OnDataReceived += ReceivedOdometryUpdate;

        _maxLinearSpeed  = RobotConfig.MaxLinearSpeed;
        _maxAngularSpeed = RobotConfig.MaxAngularSpeed;

        _rosLocomotionLinear.PublishData(new Float32Msg(_maxLinearSpeed));
        _rosLocomotionAngular.PublishData(new Float32Msg(_maxAngularSpeed));
        _rosLocomotionControlParams.PublishData(RobotConfig.LinearSpeedParameter, RobotConfig.RollSpeedParameter, RobotConfig.PitchSpeedParameter, RobotConfig.AngularSpeedParameter);
    }
コード例 #2
0
 public ROSLocomotionWaypointState(AgentJob job, ROSBridgeWebSocketConnection rosConnection, string topicName)
 {
     if (job == AgentJob.Publisher)
     {
         _publisher = new ROSGenericPublisher(rosConnection, topicName, StringMsg.GetMessageType());
         rosConnection.AddPublisher(_publisher);
     }
     else if (job == AgentJob.Subscriber)
     {
         _subscriber = new ROSGenericSubscriber <StringMsg>(rosConnection, topicName, StringMsg.GetMessageType(), (msg) => new StringMsg(msg));
         _subscriber.OnDataReceived += (data) =>
         {
             if (OnDataReceived != null)
             {
                 OnDataReceived(data);
             }
         };
         rosConnection.AddSubscriber(_subscriber);
     }
 }