Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radio to Gui code #69

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d266cdf
Initialize tranceiver branch
sxj754 Jan 21, 2023
50cf04d
Receiver module sends submerge signal
sxj754 Jan 28, 2023
7e6a809
Code to manually set RTC
rickyrnt Feb 11, 2023
339b18a
Merge branch 'main' into tranceiver
rickyrnt Feb 11, 2023
8aaf7d5
Added serial reader node
rickyrnt Feb 15, 2023
ffc24af
Merge remote-tracking branch 'origin/main' into tranceiver
rickyrnt Feb 25, 2023
f399053
Added serial monitor read capability
rickyrnt Feb 25, 2023
068bd69
added stuff to cobtrol callback
Hwodza Mar 24, 2023
4be6a44
Add code to parse commands
rickyrnt Mar 24, 2023
f4ba7e2
Finish float communication code
rickyrnt Mar 25, 2023
603dc9d
Merge remote-tracking branch 'origin/main' into tranceiver
rickyrnt Mar 25, 2023
d7425de
Integrate into gui
rickyrnt Mar 25, 2023
7b7f28d
small pog
InvincibleRMC Apr 8, 2023
af7c55c
work?
InvincibleRMC Apr 8, 2023
059afb1
fixed spelling
InvincibleRMC Apr 8, 2023
c6e6559
remapping
InvincibleRMC Apr 8, 2023
13abd8e
Remove unneccessary messages
rickyrnt Apr 8, 2023
4585983
Merge branch 'tranceiver' of https://github.com/cwruRobotics/rov-23 i…
rickyrnt Apr 8, 2023
ba078f7
Added response codes
rickyrnt Apr 8, 2023
f34f00f
Appease the all-powerful linter
rickyrnt Apr 8, 2023
7e37ae8
fixed message
InvincibleRMC Apr 8, 2023
e996037
Fix formatting
rickyrnt Apr 22, 2023
0d2adf6
Change to custom message
rickyrnt Apr 22, 2023
65aba37
Rectify the egrigous typographical error
rickyrnt Apr 29, 2023
0f5a9e7
Merge branch 'main' into tranceiver
rickyrnt Apr 29, 2023
5cc91e8
Sensible filenames
benjaminwp18 May 29, 2023
93dbe82
Spellcheck & formatting
benjaminwp18 May 29, 2023
1b834ad
Create profiling schedule
benjaminwp18 Jun 1, 2023
d60c981
Merge branch 'main' into tranceiver
benjaminwp18 Jun 1, 2023
c245134
Add FloatCommand to CMake
benjaminwp18 Jun 1, 2023
e143218
Float GUI has single command on main tab
benjaminwp18 Jun 1, 2023
d096419
Unused button vars
benjaminwp18 Jun 1, 2023
bb3c04e
Update team name
benjaminwp18 Jun 1, 2023
9d5920f
Merge remote-tracking branch 'origin/main' into tranceiver
Jun 15, 2023
48a0496
Fixed float code
Jun 21, 2023
171ccc1
comm
Jun 22, 2023
f489768
Merge branch 'main' into tranceiver
Jun 23, 2023
732a3a1
Add time set button to gui (maybe)
NoahMollerstuen Jun 23, 2023
672277d
Fix layout
cwru-rov-laptop Jun 23, 2023
52f75fd
Float stuff idk
NoahMollerstuen Jun 23, 2023
4061850
Merge remote-tracking branch 'origin/tranceiver' into tranceiver
NoahMollerstuen Jun 23, 2023
d13bf97
Add time set buttons
cwru-rov-laptop Jun 23, 2023
12a0957
Merge branch 'tranceiver' of github.com:cwruRobotics/rov-23 into tran…
cwru-rov-laptop Jun 23, 2023
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
23 changes: 13 additions & 10 deletions float/Tranciever_Reciever/Tranciever_Reciever.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
// Digital input pin where the input source(physical switch or GUI) will be coonnected.
// High = submerge, Low = float
// You might change pin number
#define SyringeInput 9
#define SYRINCE_INPUT 9
benjaminwp18 marked this conversation as resolved.
Show resolved Hide resolved

// True = submerge, False = float
bool SyringeCtrl = false;
bool syringeCtrl = false;

/************ Radio Setup ***************/

//yes, the key is EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE. best key ever.
uint8_t key[] = { 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE,
uint8_t key[] = {
0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE,
0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE
};
benjaminwp18 marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -137,7 +138,7 @@ void setup()
rf69.setEncryptionKey(key);

pinMode(LED, OUTPUT);
pinMode(SyringeInput, INPUT);
pinMode(SYRINCE_INPUT, INPUT);
benjaminwp18 marked this conversation as resolved.
Show resolved Hide resolved

Serial.print("RFM69 radio @"); Serial.print((int)RF69_FREQ); Serial.println(" MHz");
}
Expand All @@ -146,16 +147,18 @@ void setup()
void loop() {
receiveData();
// Check if serial signal recieved
if(Serial.available() == 1){
if (Serial.available() == 1) {
String command;
command = Serial.readString();
if(command == "submerge")
if (command == "submerge") {
sendControlSignal("submerge");
benjaminwp18 marked this conversation as resolved.
Show resolved Hide resolved
else if (command == "extend")
} else if (command == "extend") {
sendControlSignal("extend");
else if (command == "retract")
} else if (command == "retract") {
sendControlSignal("retract");
else Serial.println("Invalid command");
} else {
Serial.println("Invalid command");
}
}
}

Expand Down Expand Up @@ -187,7 +190,7 @@ void sendControlSignal(char* message) {
}


void Blink(byte PIN, byte DELAY_MS, byte loops) {
void blink(byte PIN, byte DELAY_MS, byte loops) {
for (byte i = 0; i < loops; i++) {
digitalWrite(PIN, HIGH);
delay(DELAY_MS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ RTC_PCF8523 rtc;
// Digital output pin where the syringe will be connected.
// High = submerge, Low = float
// You might change pin number
#define SyringeOutput 9
#define SYRINGE_OUTPUT 9

// True = submerge, False = float
bool SyringeCtrl = false;
bool syringeCtrl = false;

/************ Radio Setup ***************/

//If you ever forget the key, just remember that it's EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
uint8_t key[] = { 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE,
uint8_t key[] = {
0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE,
0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE
};
benjaminwp18 marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -123,23 +124,23 @@ void setup()

Serial.println("Assume year is 2023");
Serial.println("Enter month [number format]");
while (Serial.available() == 0){}
while (Serial.available() == 0);
int month = Serial.parseInt();
Serial.println(month);
Serial.println("Enter day");
while (Serial.available() == 0){}
while (Serial.available() == 0);
int day = Serial.parseInt();
Serial.println(day);
Serial.println("Enter hour");
while (Serial.available() == 0){}
while (Serial.available() == 0);
int hour = Serial.parseInt();
Serial.println(hour);
Serial.println("Enter minute [make sure you have enough time to enter seconds!]");
while (Serial.available() == 0){}
while (Serial.available() == 0);
int minute = Serial.parseInt();
Serial.println(minute);
Serial.println("Enter second");
while (Serial.available() == 0){}
while (Serial.available() == 0);
int second = Serial.parseInt();
Serial.println(second);

Expand Down Expand Up @@ -191,9 +192,11 @@ void setup()
rf69.setEncryptionKey(key);

pinMode(LED, OUTPUT);
pinMode(SyringeOutput, OUTPUT);
pinMode(SYRINGE_OUTPUT, OUTPUT);

Serial.print("RFM69 radio @"); Serial.print((int)RF69_FREQ); Serial.println(" MHz");
Serial.print("RFM69 radio @");
Serial.print((int)RF69_FREQ);
Serial.println(" MHz");
}


Expand Down Expand Up @@ -243,7 +246,7 @@ void sendData() {
Serial.println("Receive failed");
}
} else {
Serial.println("No reply.");
Serial.println("No reply.");
}*/
benjaminwp18 marked this conversation as resolved.
Show resolved Hide resolved

prevTime = now;
Expand All @@ -266,11 +269,11 @@ void receiveSubmergeSignal() {
Serial.print("RSSI: ");
Serial.println(rf69.lastRssi(), DEC);

if (strcmp((char*)buf, "su") == 0){
if (strcmp((char*)buf, "su") == 0) {
submerge();
} else if (strcmp((char*)buf, "ex") == 0){
} else if (strcmp((char*)buf, "ex") == 0) {
extend();
} else if (strcmp((char*)buf, "re") == 0){
} else if (strcmp((char*)buf, "re") == 0) {
retract();
} else {
Serial.println("Invalid command");
Expand All @@ -283,29 +286,32 @@ void receiveSubmergeSignal() {

void submerge() {
char radiopacket[20] = "Submerging!";
Serial.print("Sending: "); Serial.println(radiopacket);
Serial.print("Sending: ");
Serial.println(radiopacket);

// Send a message!
rf69.send((uint8_t *)radiopacket, strlen(radiopacket));
rf69.waitPacketSent();
digitalWrite(SyringeOutput, HIGH);
digitalWrite(SYRINGE_OUTPUT, HIGH);
delay(1000);
digitalWrite(SyringeOutput, LOW);
digitalWrite(SYRINGE_OUTPUT, LOW);
}

void extend(){
void extend() {
//extend code here
char radiopacket[20] = "Extending!";
Serial.print("Sending: "); Serial.println(radiopacket);
Serial.print("Sending: ");
Serial.println(radiopacket);

// Send a message!
rf69.send((uint8_t *)radiopacket, strlen(radiopacket));
rf69.waitPacketSent();
}

void retract(){
void retract() {
char radiopacket[20] = "Retracting!";
Serial.print("Sending: "); Serial.println(radiopacket);
Serial.print("Sending: ");
Serial.println(radiopacket);

// Send a message!
rf69.send((uint8_t *)radiopacket, strlen(radiopacket));
Expand Down
1 change: 1 addition & 0 deletions interfaces/msg/FloatCommand.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
string command
20 changes: 10 additions & 10 deletions surface/gui/gui/modules/float_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
from PyQt5.QtWidgets import QPushButton, QHBoxLayout, QLabel, QWidget
from gui.event_nodes.publisher import GUIEventPublisher
from gui.event_nodes.subscriber import GUIEventSubscriber
from std_msgs.msg import String
from interfaces.msg import FloatCommand
from PyQt5.QtCore import pyqtSignal, pyqtSlot


class FloatComm(QWidget):
"""Arm widget for sending Arm Commands."""

handle_scheduler_response_signal: pyqtSignal = pyqtSignal(String)
handle_scheduler_response_signal: pyqtSignal = pyqtSignal(FloatCommand)

def __init__(self):
super().__init__()
Expand Down Expand Up @@ -44,25 +44,25 @@ def __init__(self):
layout.addWidget(self.label)

self.transceiver_publisher: GUIEventPublisher = GUIEventPublisher(
String,
FloatCommand,
"transceiver_control"
)

self.transceiver_subscription: GUIEventSubscriber = GUIEventSubscriber(
String,
FloatCommand,
"transceiver_data",
self.handle_scheduler_response_signal
)

@pyqtSlot(String)
def handle_text(self, msg: String):
self.label.setText(msg.data)
@pyqtSlot(FloatCommand)
def handle_text(self, msg: FloatCommand):
self.label.setText(msg.command)

def submerge_clicked(self):
self.transceiver_publisher.publish(String(data="submerge"))
self.transceiver_publisher.publish(FloatCommand(command="submerge"))

def extend_clicked(self):
self.transceiver_publisher.publish(String(data="extend"))
self.transceiver_publisher.publish(FloatCommand(command="extend"))

def retract_clicked(self):
self.transceiver_publisher.publish(String(data="retract"))
self.transceiver_publisher.publish(FloatCommand(command="retract"))
16 changes: 8 additions & 8 deletions surface/transceiver/transceiver/serial_reader.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import serial
import rclpy
from rclpy.node import Node
from std_msgs.msg import String
from interfaces.msg import FloatCommand


class SerialReader(Node):

def __init__(self):
super().__init__('serial_reader',
parameter_overrides=[])
self.publisher_ = self.create_publisher(String, 'transceiver_data', 10)
self.publisher = self.create_publisher(FloatCommand, 'transceiver_data', 10)
self.listener = self.create_subscription(
String,
FloatCommand,
'transceiver_control',
self.control_callback,
10)
Expand All @@ -21,14 +21,14 @@ def __init__(self):
self.i = 0

def timer_callback(self):
msg = String()
msg.data = self.ser.readline().decode()
self.publisher_.publish(msg)
msg = FloatCommand()
msg.command = self.ser.readline().decode()
self.publisher.publish(msg)
# self.get_logger().info('Publishing: "%s"' % msg.data)
# self.i += 1

def control_callback(self, msg: String):
msg_encode: bytes = msg.data.encode()
def control_callback(self, msg: FloatCommand):
msg_encode: bytes = msg.command.encode()
self.ser.write(msg_encode)
self.get_logger().info(f'Command sent via serial monitor: {msg_encode}')

Expand Down