Skip to content

Commit 5125e18

Browse files
authored
Merge pull request #118 from mcgill-robotics/powerROS1
Power ros1
2 parents 308c724 + 824bff1 commit 5125e18

File tree

452 files changed

+43514
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

452 files changed

+43514
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
#ifdef ACTUATOR_H
2+
13
#include <Arduino.h>
24

35
void actuator_setup();
46
void actuator_loop();
7+
8+
#endif
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
#ifdef DISPLAY_H
2+
13
#include <Arduino.h>
24

35
void display_setup();
46
void display_loop();
7+
8+
#endif

pio_workspace/include/power_main.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
#ifdef POWER_H
2+
13
#include <Arduino.h>
24

35
void power_setup();
46
void power_loop();
7+
8+
#endif
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifdef POWER_ROS1_H
2+
3+
#include <Arduino.h>
4+
5+
void power_ros1_setup();
6+
void power_ros1_loop();
7+
8+
#endif

pio_workspace/lib/power_custom/ThrusterControl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ifdef POWER_H
2+
13
#include "ThrusterControl.h"
24

35
// Initialize thrusters
@@ -29,3 +31,5 @@ void updateThrusters(const int16_t microseconds[8]) {
2931
thrusters[i].writeMicroseconds(microseconds[i]);
3032
}
3133
}
34+
35+
#endif

pio_workspace/lib/power_custom/ThrusterControl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ifdef POWER_H
2+
13
#ifndef THRUSTER_CONTROL_H
24
#define THRUSTER_CONTROL_H
35

@@ -28,3 +30,5 @@ void initThrusters();
2830
void updateThrusters(const int16_t microseconds[8]);
2931

3032
#endif
33+
34+
#endif
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* Software License Agreement (BSD License)
3+
*
4+
* Copyright (c) 2011, Willow Garage, Inc.
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions
9+
* are met:
10+
*
11+
* * Redistributions of source code must retain the above copyright
12+
* notice, this list of conditions and the following disclaimer.
13+
* * Redistributions in binary form must reproduce the above
14+
* copyright notice, this list of conditions and the following
15+
* disclaimer in the documentation and/or other materials provided
16+
* with the distribution.
17+
* * Neither the name of Willow Garage, Inc. nor the names of its
18+
* contributors may be used to endorse or promote prducts derived
19+
* from this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
* POSSIBILITY OF SUCH DAMAGE.
33+
*/
34+
35+
#ifndef ROS_ARDUINO_HARDWARE_H_
36+
#define ROS_ARDUINO_HARDWARE_H_
37+
38+
#if ARDUINO>=100
39+
#include <Arduino.h> // Arduino 1.0
40+
#else
41+
#include <WProgram.h> // Arduino 0022
42+
#endif
43+
44+
#if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__MKL26Z64__) || defined(__IMXRT1062__)
45+
#if defined(USE_TEENSY_HW_SERIAL)
46+
#define SERIAL_CLASS HardwareSerial // Teensy HW Serial
47+
#else
48+
#include <usb_serial.h> // Teensy 3.0 and 3.1
49+
#define SERIAL_CLASS usb_serial_class
50+
#endif
51+
#elif defined(_SAM3XA_)
52+
#include <UARTClass.h> // Arduino Due
53+
#define SERIAL_CLASS UARTClass
54+
#elif defined(USE_USBCON)
55+
// Arduino Leonardo USB Serial Port
56+
#define SERIAL_CLASS Serial_
57+
#elif (defined(__STM32F1__) and !(defined(USE_STM32_HW_SERIAL))) or defined(SPARK)
58+
// Stm32duino Maple mini USB Serial Port
59+
#define SERIAL_CLASS USBSerial
60+
#else
61+
#include <HardwareSerial.h> // Arduino AVR
62+
#define SERIAL_CLASS HardwareSerial
63+
#endif
64+
65+
class ArduinoHardware {
66+
public:
67+
ArduinoHardware(SERIAL_CLASS* io , long baud= 57600){
68+
iostream = io;
69+
baud_ = baud;
70+
}
71+
ArduinoHardware()
72+
{
73+
#if defined(USBCON) and !(defined(USE_USBCON))
74+
/* Leonardo support */
75+
iostream = &Serial1;
76+
#elif defined(USE_TEENSY_HW_SERIAL) or defined(USE_STM32_HW_SERIAL)
77+
iostream = &Serial1;
78+
#else
79+
iostream = &Serial;
80+
#endif
81+
baud_ = 57600;
82+
}
83+
ArduinoHardware(ArduinoHardware& h){
84+
this->iostream = h.iostream;
85+
this->baud_ = h.baud_;
86+
}
87+
88+
void setPort(SERIAL_CLASS* io){
89+
this->iostream = io;
90+
}
91+
92+
void setBaud(long baud){
93+
this->baud_= baud;
94+
}
95+
96+
int getBaud(){return baud_;}
97+
98+
void init(){
99+
#if defined(USE_USBCON)
100+
// Startup delay as a fail-safe to upload a new sketch
101+
delay(3000);
102+
#endif
103+
iostream->begin(baud_);
104+
}
105+
106+
int read(){return iostream->read();};
107+
void write(uint8_t* data, int length){
108+
iostream->write(data, length);
109+
}
110+
111+
unsigned long time(){return millis();}
112+
113+
protected:
114+
SERIAL_CLASS* iostream;
115+
long baud_;
116+
};
117+
118+
#endif
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* Software License Agreement (BSD License)
3+
*
4+
* Copyright (c) 2011, Willow Garage, Inc.
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions
9+
* are met:
10+
*
11+
* * Redistributions of source code must retain the above copyright
12+
* notice, this list of conditions and the following disclaimer.
13+
* * Redistributions in binary form must reproduce the above
14+
* copyright notice, this list of conditions and the following
15+
* disclaimer in the documentation and/or other materials provided
16+
* with the distribution.
17+
* * Neither the name of Willow Garage, Inc. nor the names of its
18+
* contributors may be used to endorse or promote prducts derived
19+
* from this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
* POSSIBILITY OF SUCH DAMAGE.
33+
*/
34+
35+
#ifndef ROS_ARDUINO_TCP_HARDWARE_H_
36+
#define ROS_ARDUINO_TCP_HARDWARE_H_
37+
38+
#include <Arduino.h>
39+
#if defined(ESP8266)
40+
#include <ESP8266WiFi.h>
41+
#elif defined(ESP32)
42+
#include <WiFi.h> // Using Espressif's WiFi.h
43+
#else
44+
#include <SPI.h>
45+
#include <Ethernet.h>
46+
#endif
47+
48+
class ArduinoHardware {
49+
public:
50+
ArduinoHardware()
51+
{
52+
}
53+
54+
void setConnection(IPAddress &server, int port = 11411)
55+
{
56+
server_ = server;
57+
serverPort_ = port;
58+
}
59+
60+
IPAddress getLocalIP()
61+
{
62+
#if defined(ESP8266) or defined(ESP32)
63+
return tcp_.localIP();
64+
#else
65+
return Ethernet.localIP();
66+
#endif
67+
}
68+
69+
void init()
70+
{
71+
if(tcp_.connected())
72+
{
73+
tcp_.stop();
74+
}
75+
tcp_.connect(server_, serverPort_);
76+
}
77+
78+
int read(){
79+
if (tcp_.connected())
80+
{
81+
return tcp_.read();
82+
}
83+
else
84+
{
85+
tcp_.stop();
86+
tcp_.connect(server_, serverPort_);
87+
}
88+
return -1;
89+
}
90+
91+
void write(const uint8_t* data, int length)
92+
{
93+
tcp_.write(data, length);
94+
}
95+
96+
unsigned long time()
97+
{
98+
return millis();
99+
}
100+
101+
bool connected()
102+
{
103+
return tcp_.connected();
104+
}
105+
106+
protected:
107+
#if defined(ESP8266) or defined(ESP32)
108+
WiFiClient tcp_;
109+
#else
110+
EthernetClient tcp_;
111+
#endif
112+
IPAddress server_;
113+
uint16_t serverPort_ = 11411;
114+
};
115+
116+
#endif
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#ifndef _ROS_actionlib_TestAction_h
2+
#define _ROS_actionlib_TestAction_h
3+
4+
#include <stdint.h>
5+
#include <string.h>
6+
#include <stdlib.h>
7+
#include "ros/msg.h"
8+
#include "actionlib/TestActionGoal.h"
9+
#include "actionlib/TestActionResult.h"
10+
#include "actionlib/TestActionFeedback.h"
11+
12+
namespace actionlib
13+
{
14+
15+
class TestAction : public ros::Msg
16+
{
17+
public:
18+
typedef actionlib::TestActionGoal _action_goal_type;
19+
_action_goal_type action_goal;
20+
typedef actionlib::TestActionResult _action_result_type;
21+
_action_result_type action_result;
22+
typedef actionlib::TestActionFeedback _action_feedback_type;
23+
_action_feedback_type action_feedback;
24+
25+
TestAction():
26+
action_goal(),
27+
action_result(),
28+
action_feedback()
29+
{
30+
}
31+
32+
virtual int serialize(unsigned char *outbuffer) const override
33+
{
34+
int offset = 0;
35+
offset += this->action_goal.serialize(outbuffer + offset);
36+
offset += this->action_result.serialize(outbuffer + offset);
37+
offset += this->action_feedback.serialize(outbuffer + offset);
38+
return offset;
39+
}
40+
41+
virtual int deserialize(unsigned char *inbuffer) override
42+
{
43+
int offset = 0;
44+
offset += this->action_goal.deserialize(inbuffer + offset);
45+
offset += this->action_result.deserialize(inbuffer + offset);
46+
offset += this->action_feedback.deserialize(inbuffer + offset);
47+
return offset;
48+
}
49+
50+
virtual const char * getType() override { return "actionlib/TestAction"; };
51+
virtual const char * getMD5() override { return "991e87a72802262dfbe5d1b3cf6efc9a"; };
52+
53+
};
54+
55+
}
56+
#endif

0 commit comments

Comments
 (0)