Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

using namespace wpi;

ExpansionHubPositionConstants::ExpansionHubPositionConstants(int hubNumber,
int motorNumber) {
ExpansionHubPositionConstants::ExpansionHubPositionConstants(
int hubNumber, int motorNumber) {

auto systemServer = SystemServer::GetSystemServer();

wpi::nt::PubSubOptions options;
Expand All @@ -20,33 +21,42 @@ ExpansionHubPositionConstants::ExpansionHubPositionConstants(int hubNumber,

m_pPublisher =
systemServer
.GetDoubleTopic(fmt::format("/rhsp/{}/motor{}/constants/position/kp",
hubNumber, motorNumber))
.GetDoubleTopic(fmt::format(
"/rhsp/{}/motor{}/constants/position/kp",
hubNumber, motorNumber))
.Publish(options);

m_iPublisher =
systemServer
.GetDoubleTopic(fmt::format("/rhsp/{}/motor{}/constants/position/ki",
hubNumber, motorNumber))
.GetDoubleTopic(fmt::format(
"/rhsp/{}/motor{}/constants/position/ki",
hubNumber, motorNumber))
.Publish(options);

m_dPublisher =
systemServer
.GetDoubleTopic(fmt::format("/rhsp/{}/motor{}/constants/position/kd",
hubNumber, motorNumber))
.GetDoubleTopic(fmt::format(
"/rhsp/{}/motor{}/constants/position/kd",
hubNumber, motorNumber))
.Publish(options);

// Default PID values
m_pPublisher.SetDefault(1.0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use SetDefault here, just use Set

m_iPublisher.SetDefault(0.0);
m_dPublisher.SetDefault(0.01);

m_sPublisher =
systemServer
.GetDoubleTopic(fmt::format("/rhsp/{}/motor{}/constants/position/ks",
hubNumber, motorNumber))
.GetDoubleTopic(fmt::format(
"/rhsp/{}/motor{}/constants/position/ks",
hubNumber, motorNumber))
.Publish(options);

m_continuousPublisher =
systemServer
.GetBooleanTopic(
fmt::format("/rhsp/{}/motor{}/constants/position/continuous",
hubNumber, motorNumber))
.GetBooleanTopic(fmt::format(
"/rhsp/{}/motor{}/constants/position/continuous",
hubNumber, motorNumber))
.Publish(options);

m_continuousMinimumPublisher =
Expand All @@ -64,26 +74,31 @@ ExpansionHubPositionConstants::ExpansionHubPositionConstants(int hubNumber,
.Publish(options);
}

ExpansionHubPositionConstants& ExpansionHubPositionConstants::SetPID(double p,
double i,
double d) {
ExpansionHubPositionConstants&
ExpansionHubPositionConstants::SetPID(double p,
double i,
double d) {
m_pPublisher.Set(p);
m_iPublisher.Set(i);
m_dPublisher.Set(d);
return *this;
}

ExpansionHubPositionConstants& ExpansionHubPositionConstants::SetS(double s) {
ExpansionHubPositionConstants&
ExpansionHubPositionConstants::SetS(double s) {
m_sPublisher.Set(s);
return *this;
}

ExpansionHubPositionConstants&
ExpansionHubPositionConstants::EnableContinuousInput(double minimumInput,
double maximumInput) {
ExpansionHubPositionConstants::EnableContinuousInput(
double minimumInput,
double maximumInput) {

m_continuousMaximumPublisher.Set(maximumInput);
m_continuousMinimumPublisher.Set(minimumInput);
m_continuousPublisher.Set(true);

return *this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ ExpansionHubVelocityConstants::ExpansionHubVelocityConstants(int hubNumber,
.GetDoubleTopic(fmt::format("/rhsp/{}/motor{}/constants/velocity/kd",
hubNumber, motorNumber))
.Publish(options);
m_pPublisher.SetDefault(1.0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here, use Set

m_iPublisher.SetDefault(0.0);
m_dPublisher.SetDefault(0.01);

m_sPublisher =
systemServer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

/** This class contains feedback and feedforward constants for an ExpansionHub motor. */
public class ExpansionHubPositionConstants {

private final DoublePublisher m_pPublisher;
private final DoublePublisher m_iPublisher;
private final DoublePublisher m_dPublisher;
Expand All @@ -23,35 +24,43 @@ public class ExpansionHubPositionConstants {
private final DoublePublisher m_continuousMaximumPublisher;

ExpansionHubPositionConstants(int hubNumber, int motorNumber) {

NetworkTableInstance systemServer = SystemServer.getSystemServer();

PubSubOption[] options =
new PubSubOption[] {
PubSubOption.SEND_ALL, PubSubOption.KEEP_DUPLICATES, PubSubOption.periodic(0.005)
PubSubOption.SEND_ALL,
PubSubOption.KEEP_DUPLICATES,
PubSubOption.periodic(0.005)
};

m_pPublisher =
systemServer
.getDoubleTopic(
"/rhsp/" + hubNumber + "/motor" + motorNumber + "/constants/position" + "/kp")
"/rhsp/" + hubNumber + "/motor" + motorNumber + "/constants/position/kp")
.publish(options);

m_iPublisher =
systemServer
.getDoubleTopic(
"/rhsp/" + hubNumber + "/motor" + motorNumber + "/constants/position" + "/ki")
"/rhsp/" + hubNumber + "/motor" + motorNumber + "/constants/position/ki")
.publish(options);

m_dPublisher =
systemServer
.getDoubleTopic(
"/rhsp/" + hubNumber + "/motor" + motorNumber + "/constants/position" + "/kd")
"/rhsp/" + hubNumber + "/motor" + motorNumber + "/constants/position/kd")
.publish(options);

// Default PID values
m_pPublisher.setDefault(1.0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, use set

m_iPublisher.setDefault(0.0);
m_dPublisher.setDefault(0.01);

m_sPublisher =
systemServer
.getDoubleTopic(
"/rhsp/" + hubNumber + "/motor" + motorNumber + "/constants/position" + "/ks")
"/rhsp/" + hubNumber + "/motor" + motorNumber + "/constants/position/ks")
.publish(options);

m_continuousPublisher =
Expand All @@ -61,8 +70,7 @@ public class ExpansionHubPositionConstants {
+ hubNumber
+ "/motor"
+ motorNumber
+ "/constants/position"
+ "/continuous")
+ "/constants/position/continuous")
.publish(options);

m_continuousMinimumPublisher =
Expand All @@ -72,8 +80,7 @@ public class ExpansionHubPositionConstants {
+ hubNumber
+ "/motor"
+ motorNumber
+ "/constants/position"
+ "/continuousMinimum")
+ "/constants/position/continuousMinimum")
.publish(options);

m_continuousMaximumPublisher =
Expand All @@ -83,8 +90,7 @@ public class ExpansionHubPositionConstants {
+ hubNumber
+ "/motor"
+ motorNumber
+ "/constants/position"
+ "/continuousMaximum")
+ "/constants/position/continuousMaximum")
.publish(options);
}

Expand Down Expand Up @@ -123,18 +129,21 @@ public ExpansionHubPositionConstants setS(double s) {
/**
* Enables continuous input.
*
* <p>Rather then using the max and min input range as constraints, it considers them to be the
* same point and automatically calculates the shortest route to the setpoint.
* <p>Rather then using the max and min input range as constraints, it considers
* them to be the same point and automatically calculates the shortest route to
* the setpoint.
*
* @param minimumInput The minimum value expected from the input.
* @param maximumInput The maximum value expected from the input.
* @return This object, for method chaining.
*/
public ExpansionHubPositionConstants enableContinuousInput(
double minimumInput, double maximumInput) {

m_continuousMaximumPublisher.set(maximumInput);
m_continuousMinimumPublisher.set(minimumInput);
m_continuousPublisher.set(true);

return this;
}

Expand Down
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where did the rest of this file go

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alr i think i did it

Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class ExpansionHubVelocityConstants {
.getDoubleTopic(
"/rhsp/" + hubNumber + "/motor" + motorNumber + "/constants/velocity" + "/kd")
.publish(options);
m_pPublisher.set(1);
m_iPublisher.set(0);
m_dPublisher.set(0.01);

m_sPublisher =
systemServer
Expand Down
Loading