Skip to content

Commit b0837d7

Browse files
authored
Merge branch 'main' into user/Jay/rpi-workspace
2 parents 7e34bff + 59a5b53 commit b0837d7

File tree

10 files changed

+35
-17
lines changed

10 files changed

+35
-17
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "Sailbot Workspace",
44
"dockerComposeFile": [
55
"docker-compose.yml",
6-
"website/docker-compose.website.yml", // website
6+
// "website/docker-compose.website.yml", // website
77

88
// Uncomment the files containing the programs you need
99
// "docs/docker-compose.docs.yml", // docs

src/local_pathfinding/local_pathfinding/node_mock_gps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from geopy.distance import great_circle
1111
from rclpy.node import Node
1212

13-
from local_pathfinding.objectives import get_true_wind
13+
from local_pathfinding.ompl_objectives import get_true_wind
1414

1515
MEAN_SPEED = ci.HelperSpeed(speed=15.0) # mean boat speed in kmph
1616

File renamed without changes.

src/local_pathfinding/local_pathfinding/ompl_path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import local_pathfinding.coord_systems as cs
2323
import local_pathfinding.obstacles as ob
24-
from local_pathfinding.objectives import get_sailing_objective
24+
from local_pathfinding.ompl_objectives import get_sailing_objective
2525

2626
if TYPE_CHECKING:
2727
from local_pathfinding.local_path import LocalPathState

src/local_pathfinding/local_pathfinding/visualizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from shapely.geometry import Polygon
2828

2929
import local_pathfinding.coord_systems as cs
30-
from local_pathfinding.objectives import get_true_wind
30+
from local_pathfinding.ompl_objectives import get_true_wind
3131

3232
app = dash.Dash(__name__)
3333

src/local_pathfinding/test/test_objectives.py renamed to src/local_pathfinding/test/test_ompl_objectives.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
from rclpy.impl.rcutils_logger import RcutilsLogger
66

77
import local_pathfinding.coord_systems as coord_systems
8-
import local_pathfinding.objectives as objectives
8+
import local_pathfinding.ompl_objectives as objectives
99
import local_pathfinding.ompl_path as ompl_path
1010
from local_pathfinding.local_path import LocalPathState
11-
from local_pathfinding.objectives import get_true_wind
11+
from local_pathfinding.ompl_objectives import get_true_wind
1212

1313
# Upwind downwind cost multipliers
1414
UPWIND_MULTIPLIER = 3000.0

src/network_systems/lib/cmn_hdrs/shared_constants.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ constexpr float LON_LBND = -180.0;
6767
constexpr float LON_UBND = 180.0;
6868

6969
/***** Bounds for Speed ******/
70-
constexpr float SPEED_LBND = -10.0; // Placeholder number
71-
constexpr float SPEED_UBND = 10.0; // Placeholder number
70+
constexpr float SPEED_LBND = -10.0; // Placeholder number (kmph)
71+
constexpr float SPEED_UBND = 10.0; // Placeholder number (kmph)
7272

7373
/***** Bounds for Heading ******/
7474
constexpr float HEADING_LBND = 0.0;
@@ -102,9 +102,9 @@ constexpr float PH_LBND = -1.6; // lbnd of sensor being used
102102
constexpr float PH_UBND = 15.6; // ubnd of sensor being used
103103

104104
/***** Bounds for Salinity Sensor ******/
105-
constexpr float SALINITY_LBND = 0; // lbnd of sensor being used is 0.07
105+
constexpr float SALINITY_LBND = 0; // lbnd of sensor being used is 0.07
106106
constexpr float SALINITY_UBND = 1000000; // ubnd of sensor being used is 500000+
107107

108108
/***** Bounds for Pressure Sensor ******/
109-
constexpr float PRESSURE_LBND = -100; // lowest lbnd of pressure sensors under consideration is -14.5 psi
109+
constexpr float PRESSURE_LBND = -100; // lowest lbnd of pressure sensors under consideration is -14.5 psi
110110
constexpr float PRESSURE_UBND = 1000; // highest lbnd of pressure sensors is 8702 psi

src/network_systems/projects/can_transceiver/src/can_frame_parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ std::string WindSensor::debugStr() const
275275
{
276276
std::stringstream ss;
277277
ss << BaseFrame::debugStr() << "\n"
278-
<< "Wind speed (m/s): " << wind_speed_ << "\n"
278+
<< "Wind speed (km/h): " << wind_speed_ << "\n"
279279
<< "Wind angle (degrees): " << wind_angle_;
280280
return ss.str();
281281
}

src/network_systems/projects/can_transceiver/src/can_transceiver.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "can_transceiver.h"
22

33
#include <errno.h>
4+
#include <fcntl.h>
45
#include <linux/can.h>
56
#include <net/if.h>
67
#include <sys/ioctl.h>
@@ -108,11 +109,21 @@ CanTransceiver::~CanTransceiver()
108109

109110
void CanTransceiver::receive()
110111
{
112+
int flags = fcntl(sock_desc_, F_GETFL, 0);
113+
if (flags == -1) {
114+
std::cerr << "failed to get flags for CAN socket fd" << std::endl;
115+
}
116+
// make read() non-blocking so mutex gets released
117+
flags |= O_NONBLOCK;
118+
if (fcntl(sock_desc_, F_SETFL, flags) == -1) {
119+
std::cerr << "failed to set flags for CAN socket fd" << std::endl;
120+
}
111121
while (!shutdown_flag_) {
112122
// make sure the lock is acquired and released INSIDE the loop, otherwise send() will never get the lock
113-
std::lock_guard<std::mutex> lock(can_mtx_);
114-
CanFrame frame;
115-
ssize_t bytes_read = read(sock_desc_, &frame, sizeof(CanFrame));
123+
CanFrame frame;
124+
std::unique_lock<std::mutex> lock(can_mtx_);
125+
ssize_t bytes_read = read(sock_desc_, &frame, sizeof(CanFrame));
126+
lock.unlock();
116127
if (bytes_read > 0) {
117128
if (bytes_read != sizeof(CanFrame)) {
118129
std::cerr << "CAN read error: read " << bytes_read << "B but CAN frames are expected to be "
@@ -121,8 +132,12 @@ void CanTransceiver::receive()
121132
onNewCanData(frame);
122133
}
123134
} else if (bytes_read < 0) {
124-
std::cerr << "CAN read error: " << errno << "(" << strerror(errno) // NOLINT(concurrency-mt-unsafe)
125-
<< ")" << std::endl;
135+
if (errno != EAGAIN && errno != EWOULDBLOCK) {
136+
std::cerr << "CAN read error: " << errno << "(" << strerror(errno) // NOLINT(concurrency-mt-unsafe)
137+
<< ")" << std::endl;
138+
} else {
139+
std::this_thread::sleep_for(std::chrono::milliseconds(1));
140+
}
126141
}
127142
}
128143
}

src/network_systems/projects/can_transceiver/src/can_transceiver_ros_intf.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ class CanTransceiverIntf : public NetNode
9090
std::make_pair(CanId::SAIL_WIND, std::function<void(const CanFrame &)>([this](const CanFrame & frame) {
9191
publishWindSensor(frame);
9292
})),
93+
std::make_pair(CanId::DATA_WIND, std::function<void(const CanFrame &)>([this](const CanFrame & frame) {
94+
publishWindSensor(frame);
95+
})),
9396
std::make_pair(
9497
CanId::GENERIC_SENSOR_START,
9598
std::function<void(const CanFrame &)>([this](const CanFrame & frame) { publishGeneric(frame); })),
@@ -533,7 +536,7 @@ class CanTransceiverIntf : public NetNode
533536
{
534537
desired_heading_ = desired_heading;
535538
try {
536-
CAN_FP::DesiredHeading desired_heading_frame(desired_heading, CanId::MAIN_TR_TAB);
539+
auto desired_heading_frame = CAN_FP::DesiredHeading(desired_heading_, CanId::MAIN_HEADING);
537540
can_trns_->send(desired_heading_frame.toLinuxCan());
538541
RCLCPP_INFO(
539542
this->get_logger(), "%s %s", getCurrentTimeString().c_str(), desired_heading_frame.toString().c_str());

0 commit comments

Comments
 (0)