Skip to content

Commit 08fc29b

Browse files
Changed ace to ace-serial and ran linter
Signed-off-by: yamahatayukiya <[email protected]>
1 parent da70b1e commit 08fc29b

26 files changed

+1242
-775
lines changed

BarometerReader.cpp

+22-34
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2020 Carnegie Mellon University
2+
* Copyright (c) 2020, 2023 Carnegie Mellon University and Miraikan
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -20,47 +20,35 @@
2020
* THE SOFTWARE.
2121
*******************************************************************************/
2222

23-
#include "BarometerReader.h"
23+
#include "BarometerReader.hpp"
2424

25-
BarometerReader::BarometerReader(ros::NodeHandle &nh):
26-
SensorReader(nh),
27-
fp_pub_("pressure", &fp_msg_),
28-
tmp_pub_("temperature", &tmp_msg_)
29-
{
30-
nh_.advertise(fp_pub_);
31-
nh_.advertise(tmp_pub_);
32-
}
25+
BarometerReader::BarometerReader(cabot::Handle & ch)
26+
: SensorReader(ch) {}
3327

34-
void BarometerReader::init(){
35-
Wire.begin(21,22);
36-
if(!bmp_.begin(0x76, &Wire))
37-
{
38-
nh_.loginfo("Ooops, no BME280 detected ... Check your wiring or I2C ADDR!");
28+
void BarometerReader::init()
29+
{
30+
Wire.begin(21, 22);
31+
if (!bme_.begin(0x76, &Wire)) {
32+
ch_.loginfo("Ooops, no BME280 detected ... Check your wiring or I2C ADDR!");
3933
return;
4034
}
4135
initialized_ = true;
42-
43-
bmp_.setSampling(Adafruit_BME280::MODE_NORMAL, /* Operating Mode. */
44-
Adafruit_BME280::SAMPLING_X2, /* Temp. oversampling */
45-
Adafruit_BME280::SAMPLING_X16, /* Pressure oversampling */
46-
Adafruit_BME280::SAMPLING_X16,
47-
Adafruit_BME280::FILTER_X16, /* Filtering. */
48-
Adafruit_BME280::STANDBY_MS_500); /* Standby time. */
36+
37+
bme_.setSampling(
38+
Adafruit_BME280::MODE_NORMAL, /* Operating Mode. */
39+
Adafruit_BME280::SAMPLING_X2, /* Temp. oversampling */
40+
Adafruit_BME280::SAMPLING_X16, /* Pressure oversampling */
41+
Adafruit_BME280::SAMPLING_X16, /* Humidity oversampling */
42+
Adafruit_BME280::FILTER_X16, /* Filtering. */
43+
Adafruit_BME280::STANDBY_MS_500); /* Standby time. */
4944
}
5045

51-
void BarometerReader::update(){
46+
void BarometerReader::update()
47+
{
5248
if (!initialized_) {
5349
return;
5450
}
55-
fp_msg_.fluid_pressure = bmp_.readPressure();
56-
fp_msg_.variance = 0;
57-
fp_msg_.header.stamp = nh_.now();
58-
fp_msg_.header.frame_id = "bmp_frame";
59-
fp_pub_.publish( &fp_msg_ );
60-
61-
tmp_msg_.temperature = bmp_.readTemperature();
62-
tmp_msg_.variance = 0;
63-
tmp_msg_.header.stamp = nh_.now();
64-
tmp_msg_.header.frame_id = "bmp_frame";
65-
tmp_pub_.publish( &tmp_msg_ );
51+
52+
ch_.publish(0x15, bme_.readPressure());
53+
ch_.publish(0x16, bme_.readTemperature());
6654
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2020 Carnegie Mellon University
2+
* Copyright (c) 2020, 2023 Carnegie Mellon University and Miraikan
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -20,29 +20,21 @@
2020
* THE SOFTWARE.
2121
*******************************************************************************/
2222

23-
#ifndef ARDUINO_NODE_BAROMETER_H
24-
#define ARDUINO_NODE_BAROMETER_H
23+
#ifndef BAROMETERREADER_HPP_
24+
#define BAROMETERREADER_HPP_
2525

26-
#include <Wire.h>
27-
#include <Adafruit_Sensor.h>
28-
//#include <Adafruit_BMP280.h>
2926
#include <Adafruit_BME280.h>
30-
#include <sensor_msgs/FluidPressure.h>
31-
#include <sensor_msgs/Temperature.h>
27+
#include <Adafruit_Sensor.h>
28+
#include <Wire.h>
3229
#include "SensorReader.h"
3330

34-
class BarometerReader : public SensorReader{
35-
//Adafruit_BMP280 bmp_;
36-
Adafruit_BME280 bmp_;
37-
sensor_msgs::FluidPressure fp_msg_;
38-
sensor_msgs::Temperature tmp_msg_;
39-
ros::Publisher fp_pub_;
40-
ros::Publisher tmp_pub_;
31+
class BarometerReader: public SensorReader {
32+
Adafruit_BME280 bme_;
4133

4234
public:
43-
BarometerReader(ros::NodeHandle &nh);
35+
explicit BarometerReader(cabot::Handle & ch);
4436
void init();
4537
void update();
4638
};
4739

48-
#endif //ARDUINO_NODE_BAROMETER_H
40+
#endif // BAROMETERREADER_HPP_

ButtonsReader.cpp

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2020, 2023 Carnegie Mellon University and Miraikan
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*******************************************************************************/
22+
23+
#include "ButtonsReader.hpp"
24+
25+
ButtonsReader::ButtonsReader(cabot::Handle & ch, uart_com & cm)
26+
: SensorReader(ch), cm(cm) {}
27+
28+
void ButtonsReader::init() {}
29+
30+
void ButtonsReader::update()
31+
{
32+
bool reading_1 = cm.switch_up;
33+
bool reading_2 = cm.switch_down;
34+
bool reading_3 = cm.switch_left;
35+
bool reading_4 = cm.switch_right;
36+
bool reading_5 = cm.switch_center;
37+
38+
39+
int8_t temp = reading_1 ? 0x01 : 0x00 | reading_2 ? 0x02 : 0x00 | reading_3 ? 0x04 : 0x00 |
40+
reading_4 ? 0x08 : 0x00 | reading_5 ? 0x10 : 0x00;
41+
42+
ch_.publish(0x12, temp);
43+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2020, 2022 Carnegie Mellon University, IBM Corporation, and others
2+
* Copyright (c) 2020, 2023 Carnegie Mellon University and Miraikan
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -20,33 +20,20 @@
2020
* THE SOFTWARE.
2121
*******************************************************************************/
2222

23-
#ifndef ARDUINO_NODE_BUTTONS_READER_ACE_H
24-
#define ARDUINO_NODE_BUTTONS_READER_ACE_H
23+
#ifndef BUTTONSREADER_HPP_
24+
#define BUTTONSREADER_HPP_
2525

2626
#include <Wire.h>
27-
#include <std_msgs/Bool.h>
28-
#include <std_msgs/Int8.h>
2927
#include "SensorReader.h"
30-
#include "uart_com.h"
28+
#include "uart_com.h" // NOLINT
29+
30+
class ButtonsReader: public SensorReader {
31+
uart_com & cm;
3132

32-
class ButtonsReader_ace: public SensorReader {
33-
/*ros::Publisher b1_pub_;
34-
ros::Publisher b2_pub_;
35-
ros::Publisher b3_pub_;
36-
ros::Publisher b4_pub_;
37-
ros::Publisher b5_pub_;*/
38-
ros::Publisher b_pub_;
39-
/*std_msgs::Bool b1_msg_;
40-
std_msgs::Bool b2_msg_;
41-
std_msgs::Bool b3_msg_;
42-
std_msgs::Bool b4_msg_;
43-
std_msgs::Bool b5_msg_;*/
44-
std_msgs::Int8 b_msg_;
45-
uart_com& cm;
4633
public:
47-
ButtonsReader_ace(ros::NodeHandle &nh, uart_com& cm);
34+
ButtonsReader(cabot::Handle & ch, uart_com & cm);
4835
void init();
4936
void update();
5037
};
5138

52-
#endif //ARDUINO_NODE_BUTTONS_READER_ACE_H
39+
#endif // BUTTONSREADER_HPP_

ButtonsReader_ace.cpp

-74
This file was deleted.

0 commit comments

Comments
 (0)