Skip to content

Commit f4355f4

Browse files
committed
added rosserial library
1 parent 9965ed2 commit f4355f4

File tree

368 files changed

+35831
-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.

368 files changed

+35831
-0
lines changed
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
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#ifndef _ROS_actionlib_TestActionFeedback_h
2+
#define _ROS_actionlib_TestActionFeedback_h
3+
4+
#include <stdint.h>
5+
#include <string.h>
6+
#include <stdlib.h>
7+
#include "ros/msg.h"
8+
#include "std_msgs/Header.h"
9+
#include "actionlib_msgs/GoalStatus.h"
10+
#include "actionlib/TestFeedback.h"
11+
12+
namespace actionlib
13+
{
14+
15+
class TestActionFeedback : public ros::Msg
16+
{
17+
public:
18+
typedef std_msgs::Header _header_type;
19+
_header_type header;
20+
typedef actionlib_msgs::GoalStatus _status_type;
21+
_status_type status;
22+
typedef actionlib::TestFeedback _feedback_type;
23+
_feedback_type feedback;
24+
25+
TestActionFeedback():
26+
header(),
27+
status(),
28+
feedback()
29+
{
30+
}
31+
32+
virtual int serialize(unsigned char *outbuffer) const override
33+
{
34+
int offset = 0;
35+
offset += this->header.serialize(outbuffer + offset);
36+
offset += this->status.serialize(outbuffer + offset);
37+
offset += this->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->header.deserialize(inbuffer + offset);
45+
offset += this->status.deserialize(inbuffer + offset);
46+
offset += this->feedback.deserialize(inbuffer + offset);
47+
return offset;
48+
}
49+
50+
virtual const char * getType() override { return "actionlib/TestActionFeedback"; };
51+
virtual const char * getMD5() override { return "6d3d0bf7fb3dda24779c010a9f3eb7cb"; };
52+
53+
};
54+
55+
}
56+
#endif

0 commit comments

Comments
 (0)