-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP #3: Wrote simple test to read CAN bus voltage
- Loading branch information
Jacob Gloudemans
committed
Jan 17, 2019
1 parent
5f24c1f
commit 22aac74
Showing
3 changed files
with
49 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
// General C++ includes | ||
#include <string> | ||
#include <iostream> | ||
#include <chrono> | ||
#include <thread> | ||
#include <algorithm> | ||
#include <cstdint> | ||
|
||
// Phoenix libraries | ||
#include "ctre/Phoenix.h" | ||
#include "Platform-linux-socket-can.h" | ||
|
||
// ROS libraries | ||
#include "ros/ros.h" | ||
#include "geometry_msgs/Twist.h" | ||
|
||
// Global pointers for each motor controller | ||
|
||
int main(int argc, char **argv) { | ||
|
||
// Initialize ROS node | ||
ros::init(argc, argv, "can_bus_interface"); | ||
ros::NodeHandle n; | ||
|
||
// Initialize CAN bus | ||
std::string interface = "can0"; | ||
ctre::phoenix::platform::can::SetCANInterface(interface.c_str()); | ||
|
||
// Create a Talon object | ||
ctre::phoenix::motorcontrol::can::TalonSRX fl(1); | ||
|
||
ros::Rate loop_rate(1); | ||
|
||
// Loop | ||
while (ros::ok()) | ||
{ | ||
// Read information from the Talon | ||
std::cout << "Current voltage: " << fl.GetBusVoltage() << std::endl; | ||
|
||
// Pause at loop rate | ||
loop_rate.sleep(); | ||
} | ||
|
||
|
||
return 0; | ||
} |
This file was deleted.
Oops, something went wrong.