Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d4c87a1
init commit
andrew2002zhao Apr 28, 2022
77de3c2
created circular_turtle files
andrew2002zhao May 2, 2022
4006c76
added a little bit of circular turtle code
andrew2002zhao May 2, 2022
d3f324c
made moving circular turtle1
andrew2002zhao May 4, 2022
c758cb3
added a publisher line
andrew2002zhao May 6, 2022
7f8b9e0
made another shared req
andrew2002zhao May 8, 2022
74028b9
added another line
andrew2002zhao May 10, 2022
ea4a6a4
make circular turtle 1
andrew2002zhao May 15, 2022
4faa692
updated some portions
andrew2002zhao May 20, 2022
a3c308b
finished circular turtle movement
andrew2002zhao May 21, 2022
2285275
changed file names to include node
andrew2002zhao May 24, 2022
163485f
added reset_turtle_node file
andrew2002zhao May 24, 2022
d1b4782
finished reset_turtle_node.cpp
andrew2002zhao May 25, 2022
9d63907
created hacky way of doing messages
andrew2002zhao May 27, 2022
dfd1e66
defined an action file
andrew2002zhao May 31, 2022
963a59f
action file generated and xml and cmakelists is edited
andrew2002zhao May 31, 2022
81fadbd
commit
andrew2002zhao Jun 1, 2022
d0ee6a3
removed log from git
andrew2002zhao Jun 1, 2022
2bb0bda
fix merge conflict
andrew2002zhao Jun 1, 2022
62b7b04
begin debugging code
andrew2002zhao Jun 3, 2022
4f36ad8
updated gitignore
andrew2002zhao Jun 3, 2022
755e3f8
fixed timer
andrew2002zhao Jun 4, 2022
b324c1c
debugged clear_turtles_node
andrew2002zhao Jun 7, 2022
7b4da97
updated reset turtle node a bit
andrew2002zhao Jun 10, 2022
fce41d8
fixed the timer for reset turtle
andrew2002zhao Jun 11, 2022
2fd5c16
commit
andrew2002zhao Jun 14, 2022
0b05e01
editing reset_turtle_node and added a service
andrew2002zhao Jun 15, 2022
5c68633
Merge branch 'main' of https://github.com/andrew2002zhao/uwrt_softwar…
andrew2002zhao Jun 15, 2022
81126eb
made progress
andrew2002zhao Jun 15, 2022
714e364
added all the different turtle requests to cmakelists
andrew2002zhao Jun 16, 2022
6190b01
updated circular turtle node
andrew2002zhao Jun 18, 2022
487521b
updated circular turtle node
andrew2002zhao Jun 19, 2022
8c71338
updated spawn turtles node
andrew2002zhao Jun 21, 2022
2649509
added stuff
andrew2002zhao Jun 24, 2022
54cc8c2
updated spanw turtle node
andrew2002zhao Jun 25, 2022
9c95f4e
updated action server header file
andrew2002zhao Jun 26, 2022
bf77f36
updated turtle distance node function
andrew2002zhao Jun 28, 2022
620e301
added action server
andrew2002zhao Jun 28, 2022
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
68 changes: 67 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,67 @@
/software_training/launch/__pycache__/

/software_training/launch/__pycache__/

devel/
logs/
build/
bin/
lib/
msg_gen/
srv_gen/
msg/*Action.msg
msg/*ActionFeedback.msg
msg/*ActionGoal.msg
msg/*ActionResult.msg
msg/*Feedback.msg
msg/*Goal.msg
msg/*Result.msg
msg/_*.py
build_isolated/
devel_isolated/

# Generated by dynamic reconfigure
*.cfgc
/cfg/cpp/
/cfg/*.py

# Ignore generated docs
*.dox
*.wikidoc

# eclipse stuff
.project
.cproject

# qcreator stuff
CMakeLists.txt.user

srv/_*.py
*.pcd
*.pyc
qtcreator-*
*.user

/planning/cfg
/planning/docs
/planning/src

*~

# Emacs
.#*

# Catkin custom files
CATKIN_IGNORE

.vscode/

.idea/

CMakeLists.txt.user

cmake-build-debug/

install/


log/
131 changes: 131 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
cmake_minimum_required(VERSION 3.5)
project(software_training_assignment)

# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(turtlesim REQUIRED)
find_package(std_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(builtin_interfaces REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)


#include the 'include' directory
include_directories(include)

# add clear_turtles_node
add_library(turtle_request SHARED
src/clear_turtles_node.cpp)

target_compile_definitions(turtle_request PRIVATE "COMPOSITION_BUILDING_DLL")

ament_target_dependencies(turtle_request
"rclcpp"
"rclcpp_components"
"turtlesim"
"std_msgs")
rclcpp_components_register_nodes(turtle_request "composition::turtle_service_request_node")

#add reset_turtle_node
add_library(turtle_reset_request SHARED
src/reset_turtle_node.cpp)

ament_target_dependencies(turtle_reset_request
"rclcpp"
"rclcpp_components"
"turtlesim"
"std_msgs")
rclcpp_components_register_nodes(turtle_reset_request "composition::turtle_service_request_node")


rosidl_generate_interfaces(${PROJECT_NAME}
"msg/Software.msg"
"srv/Software.srv"
"action/Software.action"
DEPENDENCIES std_msgs geometry_msgs builtin_interfaces
)
ament_export_dependencies(rosidl_default_runtime)


add_library(circular_turtle_request SHARED
src/circular_turtle_node.cpp)
ament_target_dependencies(circular_turtle_request
"rclcpp"
"rclcpp_components"
"turtlesim"
"std_msgs"
"geometry_msgs")
rclcpp_components_register_nodes(circular_turtle_request "composition::circular_turtle_node")


add_library(spawn_turtle_request SHARED
src/spawn_turtles_node.cpp)
ament_target_dependencies(spawn_turtle_request
"rclcpp"
"rclcpp_components"
"turtlesim"
"std_msgs")
rclcpp_components_register_nodes(circular_turtle_request "composition::spawn_turtles_node")


add_library(turtle_distance_request SHARED
src/turtle_distance_node.cpp)
ament_target_dependencies(turtle_distance_request
"rclcpp"
"rclcpp_components"
"turtlesim"
"std_msgs"
"geometry_msgs")
rclcpp_components_register_nodes(turtle_distance_request "composition::turtle_distance_node")

add_library(moving_turtle_action_node SHARED
src/moving_turtle_action_node.cpp)
ament_target_dependencies(moving_turtle_action_node
"rclcpp"
"rclcpp_components"
"turtlesim"
"std_msgs"
"geometry_msgs")
rclcpp_components_register_nodes(moving_turtle_action_node "composition::moving_turtle_action_node")


install(TARGETS
turtle_request
turtle_reset_request
circular_turtle_request
turtle_distance_request
spawn_turtle_request
DESTINATION lib/${PROJECT_NAME})

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
#set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
#set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@

# Goal Request /moving_turtle/cmd_vel
geometry_msgs/Vector3 linear_pos
geometry_msgs/Vector3 angular_pos

# Result - time
---
uint64 duration
int64 duration

---
# Feedback /moving_turtle/pose
float32 x_pos
float32 y_pos
float32 theta_pos



36 changes: 36 additions & 0 deletions include/software_training_assignment/circular_turtle_node.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//ppdirective that states the header only gets included once in the project

#pragma once

#include <rclcpp.hpp>
#include <cstdlib>
namespace composition{
class circular_turtle : public rclcpp::Node {
public:
circular_turtle(const rclcpp::NodeOptions &options);
private:
rclcpp::TimerBase::SharedPtr timer_;
rclcpp::Publisher<geometry_msgs::msg::Twist>::SharedPtr publisher;
//need to figure out how to publish a message to turtle1 outlining its angular velocity and all that
typedef struct point {

typedef struct linear {
static constexpr float x = 12;
static constexpr float y = 12;
static constexpr float z = 12;
} linear;

typedef struct angular {
static constexpr float x = 1.41;
static constexpr float y = 1.41;
static constexpr float z = 1.41;

} angular;

} coordinates;
void rotate();

};
}


24 changes: 24 additions & 0 deletions include/software_training_assignment/clear_turtles_node.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

//get all turtle names and request to kill each one
//make a request to the turtle killing service

#include <rclcpp/rclcpp.hpp>
#include <turtlesim/srv/kill.hpp>
#include <cstdlib>



namespace composition {
class clear_turtles_node : public rclcpp::Node{
public:
clear_turtles_node(const rclcpp::NodeOptions &options);

private:
rclcpp::Client<turtlesim::srv::Kill>::SharedPtr client; //shared request
std::vector<std::string> nodes = {"turtle1", "moving_turtle", "stationary_turtle"};
rclcpp::TimerBase::SharedPtr timer_;
void kill();

};
}
37 changes: 37 additions & 0 deletions include/software_training_assignment/moving_turtle_action_node.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <cstdlib>
#include <rclcpp_action/rclcpp_action.hpp>
#include <rclcpp/rclcpp.hpp>
#include <geometry_msgs/msg/twist.hpp>
#include <turtlesim/msg/pose.hpp>
#include <software_training/action/Software.hpp>

namespace composition{
class moving_turtle_action_node : public rclcpp::Node {
public:

moving_turtle_action_node();
using GoalHandleActionServer =
rclcpp_action::ServerGoalHandle<software_training::action::Software>;
private:
float x;
float y;
float theta;

rclcpp_action::Server<software_training::action::Software>::SharedPtr action_server;

rclcpp::Publisher<geometry_msgs::msg::Twist>::SharedPtr publisher;

rclcpp::Subscription<turtlesim::msg::Pose>::SharedPtr subscriber;

//copied some code from software training, since action server is hard to figure out
rclcpp_action::GoalResponse handle_goal(
const rclcpp_action::GoalUUID &uuid,
std::shared_ptr<const software_training::action::Software::Goal> goal);

rclcpp_action::CancelResponse
handle_cancel(const std::shared_ptr<GoalHandleActionServer> goal_handle);

static constexpr unsigned int QUEUE{10};

};
}
20 changes: 20 additions & 0 deletions include/software_training_assignment/reset_turtle_node.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once
#include <cstdlib>
#include <rclcpp/rclcpp.hpp>
#include <turtlesim/srv/teleport_absolute.hpp>
// #include <software_training_assignment/srv/Software.hpp>

namespace composition{
class reset_turtle_node : public rclcpp::Node {
public:
reset_turtle_node(const rclcpp::NodeOptions &options);
private:
//make a service....
//how do i do that lmao
rclcpp::Service<software_training_assignment::srv::Software::Request>::SharedPtr service_;
rclcpp::TimerBase::SharedPtr timer_;
rclcpp::Client<turtlesim::srv::TeleportAbsolute>::SharedPtr client_;
void reset();
void reset_moving_turtle();
};
}
17 changes: 17 additions & 0 deletions include/software_training_assignment/spawn_turtles_node.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <cstdlib>
#include <rclcpp/rclcpp.hpp>
#include <turtlesim/srv/spawn.hpp>

class spawn_turtles : public rclcpp::Node {
private:
/* data */
rclcpp::Client<turtlesim::srv::Spawn>::SharedPtr client;

rclcpp::TimerBase::SharedPtr timer_;
void spawn();

public:
spawn_turtles(const rclcpp::NodeOptions &options);

};

24 changes: 24 additions & 0 deletions include/software_training_assignment/turtle_distance_node.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <rclcpp/rclcpp.hpp>
#include <cstdlib>
#include <cmath>
#include <turtlesim/msg/pose.hpp>

namespace composition {
class turtle_distance_node : public rclcpp::Node {
public:
turtle_distance_node(const rclcpp::NodeOptions &options);
private:
rclcpp::Subscription<turtlesim::msg::Pose>::SharedPtr subscription;
rclcpp::Publisher<software_training::msg::Software>::SharedPtr publisher;
rclcpp::TimerBase::SharedPtr timer;
float turtleDistance();

float turtle1_x;
float turtle1_y;
float turtle2_x;
float turtle2_y;
};
}

3 changes: 3 additions & 0 deletions msg/Software.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
float64 x
float64 y
float64 distance
Loading