Example usage for org.apache.commons.logging.impl SimpleLog SimpleLog

List of usage examples for org.apache.commons.logging.impl SimpleLog SimpleLog

Introduction

In this page you can find the example usage for org.apache.commons.logging.impl SimpleLog SimpleLog.

Prototype

public SimpleLog(String name) 

Source Link

Usage

From source file:main.java.org.ros.navigation.MotorControl.java

@Override
public void main(NodeConfiguration configuration) {

    Preconditions.checkState(node == null);
    Preconditions.checkNotNull(configuration);

    try {/*from  w w w  .  j a v  a  2 s  . co  m*/
        node = new DefaultNodeFactory().newNode("motor_control", configuration);
        wheelbase = node.newParameterTree().getDouble("wheelbase");
        log = new SimpleLog(node.getName().toString());
        log.setLevel(SimpleLog.LOG_LEVEL_OFF);

        prevPriority = 6;

        motorData = node.newPublisher("motordata", "robot_msgs/MotorData");
        node.newSubscriber("Motor_Command", "MotorControlMsg/MotorCommand", this);
    } catch (Exception e) {
        if (node != null) {
            node.getLog().fatal(e);
        } else {
            e.printStackTrace();
        }
    }

}

From source file:main.java.org.ros.navigation.SensorSideAvoidanceTestPublisher.java

@Override
public void main(NodeConfiguration configuration) {
    Preconditions.checkState(node == null);
    Preconditions.checkNotNull(configuration);

    try {//from  ww w. j a v  a  2 s .c om
        // the name of the node gets changed when it is created... so not "sensor_listener"
        node = new DefaultNodeFactory().newNode("sensor_listener", configuration);

        log = new SimpleLog(node.getName().toString());
        // Print out the name
        log.info("Sensor name: " + node.getName());
        log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
        filteredRangeMap = new TreeMap<String, Publisher<Range>>();

        // get the names of the sensors for the IR sensors so I can make
        // the name of the topic I am going to publish to 
        List<String> topics = (List<String>) node.newParameterTree().getList("left_IR");
        for (String topic : topics) {
            Publisher<Range> filteredRange = node.newPublisher(topic + "filtered", "sensor_msgs/Range");
            log.debug("Publishing to: " + topic + "filtered");
            // make the new publisher and add it to the map
            filteredRangeMap.put(topic, filteredRange);
        }

        // make this node a subscriber to the Range messages that are being published
        // by SensorListener.
        // must do this after I create the publishers because I start recieving messages
        // as soon as I subscribe.
        int count = 0;
        boolean allSub = false;
        while (allSub == false) {
            allSub = true;
            for (String topic : topics) {
                if (filteredRangeMap.get(topic).hasSubscribers() == false) {
                    allSub = false;
                }
            }
        }

        while (true) {

            for (String topic : topics) {

                // subscribe to the topic that sensorListener is publishing to
                Range message = new Range();
                message.header.frame_id = topic;
                message.header.stamp.secs = count;

                filteredRangeMap.get(topic).publish(message);
                log.debug(count);
                Thread.sleep(200);

            }

            count++;
        }

    } catch (Exception e) {
        if (node != null) {
            node.getLog().fatal(e);
        } else {
            e.printStackTrace();
        }
    }

}

From source file:main.java.org.ros.navigation.SensorSideAvoidanceTestSubscriber.java

@Override
public void main(NodeConfiguration configuration) {
    Preconditions.checkState(node == null);
    Preconditions.checkNotNull(configuration);
    try {/*from   ww  w .ja  v a  2 s .  c o  m*/
        node = new DefaultNodeFactory().newNode("motor_listener", configuration);
        numberInputs = 2;// Left and right sensor motor control messages

        // Set up the debug log
        log = new SimpleLog(node.getName().toString());
        log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);

        node.newSubscriber("left_IR_Motor_Command", "MotorControlMsg/MotorCommand", this);

    } catch (Exception e) {
        if (node != null) {
            node.getLog().fatal(e);
        } else {
            e.printStackTrace();
        }
    }

}

From source file:main.java.org.ros.robot.SensorListener.java

@Override
public void main(NodeConfiguration configuration) {
    Preconditions.checkState(node == null);
    Preconditions.checkNotNull(configuration);
    //ParameterTreenode.newParameterTree();
    try {//w  w  w  . j  a  va2s.  co  m
        node = new DefaultNodeFactory().newNode("sensor_listener", configuration);
        pubRange = new TreeMap<String, Range>();

        log = new SimpleLog(node.getName().toString());
        log.setLevel(SimpleLog.LOG_LEVEL_OFF);
        publisher = new TreeMap<String, Publisher<Range>>();
        count = 0;

        Field[] fields = SensorData.class.getDeclaredFields();
        // Loop through all the fields and extract the name of the field
        // to use as the name of the topic
        // NOTE that I may have to add stuff to the name here because of the whole 
        // namespace thing.  Not sure yet how that works.

        // get the angle measurements of the sensors from the parameter server
        // in order to put that info into the Range messages
        ParameterTree paramTree = node.newParameterTree();
        sensorAngles = (Map<String, Integer>) paramTree.getMap("sensor_angles");

        for (int i = 0; i < fields.length; i++) {

            //   log.info("The name of the first field is: " + fields[i].getName() + "degree " + sensorAngles.get(fields[i].getName()));
            Publisher<Range> pub = node.newPublisher(fields[i].getName() + "raw", "sensor_msgs/Range");
            Range curRange = (Range) node.getMessageFactory().newMessage("sensor_msgs/Range");

            if (fields[i].getName().contains("infrared")) {
                curRange.max_range = (float) .8; // 80cm
                curRange.min_range = (float) .075; // 7.5cm
                curRange.radiation_type = Range.INFRARED;
                // name it the same as the sensor
                curRange.header.frame_id = fields[i].getName();
                // not right field_of_view but fill it in
                curRange.field_of_view = (float) sensorAngles.get(fields[i].getName());
            } else if (fields[i].getName().contains("ultrasonic")) {
                curRange.max_range = (float) 2.55; // 255cm
                curRange.min_range = (float) .04; // 4cm
                curRange.radiation_type = Range.ULTRASOUND;
                // not right but fill it in
                curRange.field_of_view = (float) sensorAngles.get(fields[i].getName());
                // name it the same as the sensor
                curRange.header.frame_id = fields[i].getName();
            } else if (fields[i].getName().contains("human")) {
                curRange.header.frame_id = fields[i].getName();
                curRange.max_range = 4095;
                curRange.min_range = 0;
                curRange.radiation_type = 3;
                curRange.field_of_view = 0;
            }

            pubRange.put(fields[i].getName(), curRange);

            publisher.put(fields[i].getName(), pub);
        }

        node.newSubscriber("sensordata", "robot_msgs/SensorData", this);

    } catch (Exception e) {
        if (node != null) {
            node.getLog().fatal(e);
        } else {
            e.printStackTrace();
        }
    }

}

From source file:main.java.org.ros.navigation.HeatTrack.java

@Override
public void main(NodeConfiguration configuration) {
    Preconditions.checkState(node == null);
    Preconditions.checkNotNull(configuration);

    try {//  w ww  .jav  a 2 s  .  c o m
        //get max velocity from parameter server
        node = new DefaultNodeFactory().newNode("heat_track", configuration);
        maxVelocity = node.newParameterTree().getDouble("MAX_LINEAR_VELOCITY");

        log = new SimpleLog(node.getName().toString());
        log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);

        // set up publisher
        pubCmd = node.newPublisher("Motor_Command", "MotorControlMsg/MotorCommand");

        // set up cmd to be published
        mtrCmd = node.getMessageFactory().newMessage("MotorControlMsg/MotorCommand");

        mtrCmd.isLeftRightVel = true;
        mtrCmd.precedence = 1;
        // set up count 
        countLeft = 0;
        countRight = 0;
        // set the mid range of the sensor
        midRange = 2047;
        // set the threshold for which something is said to be human
        thresh = node.newParameterTree().getDouble("human_thresh");
        // set the max that we expect the range to be
        maxAvg = node.newParameterTree().getDouble("human_range_avg_dif");

        // set up subscriptions
        List<String> topics = (List<String>) node.newParameterTree().getList("human_topics");
        for (String topic : topics) {
            // only care about presence
            if (topic.contains("presence")) {
                node.newSubscriber(topic + "filtered", "sensor_msgs/Range", this);
            }
        }

    } catch (Exception e) {
        if (node != null) {
            node.getLog().fatal(e);
        } else {
            e.printStackTrace();
        }
    }

}

From source file:com.azavea.fop.pdf.Foplet.java

/**
 * Initialize the foplet servlet. This method configures a log,
 * transformer factory and resolvers necessary for pulling in
 * external graphics from URLs./* w w w. j av  a 2 s  . c o  m*/
 *
 * @see javax.servlet.GenericServlet#init()
 * @throws ServletException
 */
public void init() throws ServletException {
    this.log = new SimpleLog("foplet");
    log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
    this.uriResolver = new ServletContextURIResolver(getServletContext());
    this.transFactory = TransformerFactory.newInstance();
    this.transFactory.setURIResolver(this.uriResolver);

    // Configure FopFactory as desired
    this.fopFactory = FopFactory.newInstance();
    this.fopFactory.setURIResolver(this.uriResolver);
}

From source file:main.java.org.ros.navigation.ObstacleAvoidance.java

@SuppressWarnings("unchecked")
@Override/*from  w w w .j a  v  a 2  s.c om*/
public void main(NodeConfiguration configuration) {
    Preconditions.checkState(node == null);
    Preconditions.checkNotNull(configuration);
    try {
        node = new DefaultNodeFactory().newNode("motor_listener", configuration);
        numberInputs = 2;// IR and US think of moving to parameter server.

        //mesCollector = new MessageCollection<MotorCommand>(numberInputs);
        mtrCmd = node.getMessageFactory().newMessage("MotorControlMsg/MotorCommand");
        curNum = 0;
        curKey = 0;

        // get the max linear and angular velocity so that I can later compute the
        // real velocities from the normalized velocities.
        maxLinearVelocity = node.newParameterTree().getDouble("MAX_LINEAR_VELOCITY");
        maxAngularVelocity = node.newParameterTree().getDouble("MAX_ANGULAR_VELOCITY");
        // publish to Motor_Command
        pubCmd = node.newPublisher("Motor_Command", "MotorControlMsg/MotorCommand");
        log = new SimpleLog(node.getName().toString());
        //log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
        log.setLevel(SimpleLog.LOG_LEVEL_OFF);

        // The job of this node is to provide to the MotorControler a linear and
        // angular velocity such that the robot avoids obstacles.  It uses
        // Braitenberg's Aggression behavior and motor fusion.
        // These constants sum to 1 and provide the percentage that each sensor type contributes to the final
        // motorcommand
        constants = (Map<String, Double>) node.newParameterTree().getMap("comb_const");

        // must say who I subscribe to.  So get my subscriptions from the Parameter server 
        @SuppressWarnings("unchecked")
        List<String> topics = (List<String>) node.newParameterTree().getList(node.getName() + "_subscriptions");
        for (String topic : topics) {
            node.newSubscriber(topic, "MotorControlMsg/MotorCommand", this);
        }

    } catch (Exception e) {
        if (node != null) {
            node.getLog().fatal(e);
        } else {
            e.printStackTrace();
        }
    }

}

From source file:hadoopInstaller.installation.Installer.java

public MessageFormattingLog getLog() {
    if (this.log == null) {
        SimpleLog newLog = new SimpleLog(INSTALLER_NAME);
        newLog.setLevel(SimpleLog.LOG_LEVEL_INFO);
        this.log = new MessageFormattingLog(newLog);
    }/*from  w  w w  .j a v  a 2  s.  c om*/
    return this.log;
}

From source file:net.ymate.platform.log.jcl.JCLoggerAdapter.java

public Log getLogger(String name) {
    if (YMP.get() != null && YMP.get().isInited() && Logs.get().isInited()) {
        return new JCLogger(LogManager.getLogger(name), Logs.get().getModuleCfg().allowOutputConsole());
    }/*from  w  ww . ja va2s  .c  o m*/
    return new SimpleLog(name);
}

From source file:nonjsp.application.XulViewHandlerImpl.java

public UIViewRoot restoreView(FacesContext context, String viewId) {
    if (context == null) {
        throw new NullPointerException("RestoreView: FacesContext is null");
    }//from  w w  w.j  av a2s .  com

    if (log.isTraceEnabled()) {
        log.trace("viewId: " + viewId);
    }
    UIViewRoot root = null;
    InputStream viewInput = null;
    RuleSetBase ruleSet = null;

    root = new UIViewRoot();
    root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);

    if (null == viewId) {
        // PENDING(edburns): need name for default view
        // PENDING(rogerk) : what to specify for page url
        // (last parameter)????
        root.setViewId("default");
        context.setViewRoot(root);
        Locale locale = calculateLocale(context);
        root.setLocale(locale);
        return root;
    }

    try {
        viewInput = context.getExternalContext().getResourceAsStream(viewId);
        if (null == viewInput) {
            throw new NullPointerException();
        }
    } catch (Throwable e) {
        throw new FacesException("Can't get stream for " + viewId, e);
    }

    // PENDING(edburns): can this digester instance be maintained as an
    // ivar?

    Digester digester = new Digester();

    // SimpleLog implements the Log interface (from commons.logging).
    // This replaces deprecated "Digester.setDebug" method.
    // PENDING(rogerk) Perhaps the logging level should be configurable..
    // For debugging, you can set the log level to
    // "SimpleLog.LOG_LEVEL_DEBUG".
    //
    SimpleLog sLog = new SimpleLog("digesterLog");
    sLog.setLevel(SimpleLog.LOG_LEVEL_ERROR);
    digester.setLogger(sLog);

    digester.setNamespaceAware(true);

    digester.setValidating(validate);

    ruleSet = dialectProvider.getRuleSet();

    digester.addRuleSet(ruleSet);

    if (validate) {
        for (int i = 0; i < registrations.length; i += 2) {
            URL url = this.getClass().getResource(registrations[i + 1]);
            if (url != null) {
                digester.register(registrations[i], url.toString());
            }
        }
    }

    digester.push(root);
    try {
        root = (UIViewRoot) digester.parse(viewInput);
    } catch (Throwable e) {
        throw new FacesException("Can't parse stream for " + viewId, e);
    }

    //Print view for debugging
    if (log.isDebugEnabled()) {
        printView(root);
    }

    root.setViewId(viewId);
    context.setViewRoot(root);

    return root;
}