How to start smart dashboard

We are trying to use an ultrasonic sensor this year, and we want to check the value given by the sensor to se if it is measuring corectly. We want to get the smart dashboard running to get the sensor values. If anyone could help we would apprieciate it very much. If you have any examples we would aprieciate it much if we could see it

#include <frc/Joystick.h>

#include <frc/PWMVictorSPX.h>

#include <frc/TimedRobot.h>

#include <frc/drive/DifferentialDrive.h>

#include <frc/Spark.h>

#include <rev/SparkMax.h>

#include

#include <cameraserver/CameraServer.h>

#include <wpi/raw_ostream.h>

#include <frc/AnalogInput.h>

#include <frc/MedianFilter.h>

class Robot : public frc::TimedRobot {

frc::Spark m_leftMotor{9};

frc::Spark m_rightMotor{8};

frc::DifferentialDrive m_robotDrive{m_leftMotor, m_rightMotor};

frc::Joystick m_stick{0};

rev::SparkMax m_intake{7};

static constexpr double kValueToInches = 0.125;

static constexpr int kUltrasonicPort = 0;

frc::MedianFilter m_filter{10};

frc::AnalogInput m_ultrasonic{kUltrasonicPort};

public:

void RobotInit() override{

#if defined(linux)

frc::CameraServer::GetInstance()->StartAutomaticCapture(0);

frc::CameraServer::GetInstance()->StartAutomaticCapture(1);

#else

wpi::errs() << “Vision only available on Linux.\n”;

wpi::errs().flush();

#endif

}

void TeleopPeriodic() {

double currentDistance =

    m_filter.Calculate(m_ultrasonic.GetVoltage()) * kValueToInches;



// Drive with arcade style

m_robotDrive.ArcadeDrive(m_stick.GetY(), m_stick.GetX());



if(m_stick.GetRawButton(1) == true)

{

m_intake.Set(.5);

}

if(m_stick.GetRawButton(2) == true)

{

m_intake.Set(-.5);

}

if(m_stick.GetRawButton(1) == false && m_stick.GetRawButton(2) == false)

{

m_intake.Set(0);

}

}

};

#ifndef RUNNING_FRC_TESTS

int main() { return frc::StartRobot(); }

#endif

There are examples on this page: Displaying Expressions from a Robot Program — FIRST Robotics Competition documentation

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.