Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ec7c200
Create project2
SquidneySquush Oct 6, 2021
a971ce8
Delete project2
SquidneySquush Oct 6, 2021
ac42210
Make project 2 folder add readme
Oct 6, 2021
fbcd299
New Files
efredin1 Oct 27, 2021
06ce9e0
Week One Deliverables
efredin1 Nov 3, 2021
0ba7e95
Create dance_cmd.dic
SquidneySquush Nov 17, 2021
ee30308
Create voice_control.py
SquidneySquush Nov 17, 2021
9b355d7
Create main.py
SquidneySquush Nov 17, 2021
0aa9c48
Create FinalProject.launch
SquidneySquush Nov 17, 2021
57178c4
Update main.py
SquidneySquush Dec 1, 2021
6867673
Create twistleft.py
SquidneySquush Dec 1, 2021
3050f6c
Create twistright.py
SquidneySquush Dec 1, 2021
f3222f3
Create circle.py
SquidneySquush Dec 1, 2021
0229114
Update main.py
SquidneySquush Dec 1, 2021
3dfd6ea
add cha cha state machine folder
Dec 1, 2021
9b32fe4
Update main.py
efredin1 Dec 1, 2021
97d8b47
add states
Dec 1, 2021
bfd9cae
Merge branch 'FinalProject' of https://github.com/SAREC-Lab/CARS6 int…
Dec 1, 2021
e877507
Update main.py
efredin1 Dec 1, 2021
d250972
change file names
Dec 1, 2021
9b16aa5
Merge branch 'FinalProject' of https://github.com/SAREC-Lab/CARS6 int…
Dec 1, 2021
42d5c9a
adjust cricle
Dec 1, 2021
17224e0
add clap state and edits
Dec 1, 2021
17481f8
updated forward and backward
gerry101 Dec 3, 2021
9d0a4f1
Update
Dec 3, 2021
4c6cdb3
Merge branch 'FinalProject' of https://github.com/SAREC-Lab/CARS6 int…
Dec 3, 2021
ea6d0ec
update
Dec 3, 2021
5dbb158
Update main.py
gerry101 Dec 3, 2021
9072a2f
Create plan2.json
gerry101 Dec 3, 2021
0de1318
init commit
Dec 13, 2021
99276ab
added tests
Dec 15, 2021
3e700c4
Merge branch 'final-project' into FinalProject
Dec 15, 2021
e739a92
Cleaned up project
Dec 15, 2021
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
Binary file added .moves.py.swp
Binary file not shown.
199 changes: 199 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
cmake_minimum_required(VERSION 2.8.3)
project(final_project)

## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
geometry_msgs
rospy
smach
)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)


## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()

################################################
## Declare ROS messages, services and actions ##
################################################

## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend tag for "message_generation"
## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
## but can be declared for certainty nonetheless:
## * add a exec_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)

## Generate messages in the 'msg' folder
# add_message_files(
# FILES
# Message1.msg
# Message2.msg
# )

## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )

## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )

## Generate added messages and services with any dependencies listed here
# generate_messages(
# DEPENDENCIES
# geometry_msgs
# )

################################################
## Declare ROS dynamic reconfigure parameters ##
################################################

## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt):
## * add "dynamic_reconfigure" to
## find_package(catkin REQUIRED COMPONENTS ...)
## * uncomment the "generate_dynamic_reconfigure_options" section below
## and list every .cfg file to be processed

## Generate dynamic reconfigure parameters in the 'cfg' folder
# generate_dynamic_reconfigure_options(
# cfg/DynReconf1.cfg
# cfg/DynReconf2.cfg
# )

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES final_project
# CATKIN_DEPENDS geometry_msgs rospy smach
# DEPENDS system_lib
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
${catkin_INCLUDE_DIRS}
)

## Declare a C++ library
# add_library(${PROJECT_NAME}
# src/${PROJECT_NAME}/final_project.cpp
# )

## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
# add_executable(${PROJECT_NAME}_node src/final_project_node.cpp)

## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
## target back to the shorter version for ease of user use
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")

## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Specify libraries to link a library or executable target against
# target_link_libraries(${PROJECT_NAME}_node
# ${catkin_LIBRARIES}
# )

#############
## Install ##
#############

# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark executables and/or libraries for installation
# install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )

## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )

#############
## Testing ##
#############

## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_final_project.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()

## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
Empty file added ChaChaDance/__init__.py
Empty file.
Binary file added ChaChaDance/__init__.pyc
Binary file not shown.
38 changes: 38 additions & 0 deletions ChaChaDance/backward.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python

# Import libraries
import rospy
import smach
import time
from geometry_msgs.msg import Twist


# Define backward state
class Backward(smach.State):
def __init__(self, pub_controls):
smach.State.__init__(self, outcomes=["do_plan"], input_keys=["curr_state"])
self.counter = 0
self.pub_controls = pub_controls

def execute(self, userdata):
# get state attributes
state_name = userdata.curr_state["name"]

rospy.loginfo("Running {} state".format(state_name))

dur = rospy.Duration(2.8 / (6.0))
rate = rospy.Rate(10)
start = rospy.Time.now()

while rospy.Time.now() - start < dur:
move_cmd = Twist()
move_cmd.linear.x = -3.0
self.pub_controls.publish(move_cmd)
rate.sleep()

move_cmd = Twist()
move_cmd.linear.x = 0.0
self.pub_controls.publish(move_cmd)

return "do_plan"

Binary file added ChaChaDance/backward.pyc
Binary file not shown.
44 changes: 44 additions & 0 deletions ChaChaDance/circle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python

# Import libraries
import rospy
import smach
import time
import math
from geometry_msgs.msg import Twist


# Define circle state
class Circle(smach.State):
def __init__(self, pub_controls):
smach.State.__init__(self, outcomes=["do_plan"], input_keys=["curr_state"])
self.counter = 0
self.pub_controls = pub_controls

def execute(self, userdata):
# get state attributes
state_name = userdata.curr_state["name"]
direction = userdata.curr_state["direction"]

rospy.loginfo("Running {} state".format(state_name))

dur = rospy.Duration(47 / (70.0))
rate = rospy.Rate(10)

move_cmd = Twist()
move_cmd.linear.x= 5
move_cmd.angular.z = 5 * direction

t0=rospy.Time.now()
while rospy.Time.now() - t0 < dur:
self.pub_controls.publish(move_cmd)
rate.sleep()

#After the loop, stops the robot
move_cmd = Twist()
move_cmd.angular.z = 0
move_cmd.linear.x = 0
self.pub_controls.publish(move_cmd)

return "do_plan"

Binary file added ChaChaDance/circle.pyc
Binary file not shown.
38 changes: 38 additions & 0 deletions ChaChaDance/forward.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python

# Import libraries
import rospy
import smach
import time
from geometry_msgs.msg import Twist


# Define forward state
class Forward(smach.State):
def __init__(self, pub_controls):
smach.State.__init__(self, outcomes=["do_plan"], input_keys=["curr_state"])
self.counter = 0
self.pub_controls = pub_controls

def execute(self, userdata):
# get state attributes
state_name = userdata.curr_state["name"]

rospy.loginfo("Running {} state".format(state_name))

dur = rospy.Duration(2.8 / (6.0))
rate = rospy.Rate(10)
start = rospy.Time.now()

while rospy.Time.now() - start < dur:
move_cmd = Twist()
move_cmd.linear.x = 3.0
self.pub_controls.publish(move_cmd)
rate.sleep()

move_cmd = Twist()
move_cmd.linear.x = 0.0
self.pub_controls.publish(move_cmd)

return "do_plan"

Binary file added ChaChaDance/forward.pyc
Binary file not shown.
31 changes: 31 additions & 0 deletions ChaChaDance/plan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python

# Import libraries
import rospy
import smach
import time


# Define planning state
class Plan(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes=["do_forward", "do_backward", "do_exit",
"do_turnL", "do_turnR", "do_circle"],
input_keys=["plan", "curr_state", "plan_length"],
output_keys=["curr_state"])

self.counter = 0

def execute(self, userdata):
# if plan is empty, exit
if not userdata.plan:
return 'do_exit'

# get the first state
current_state = userdata.plan.pop(0)
userdata.curr_state = current_state
rospy.loginfo("Planning attempting to run: {}".format(current_state["name"]))

time.sleep(1)

return current_state["name"]
Binary file added ChaChaDance/plan.pyc
Binary file not shown.
26 changes: 26 additions & 0 deletions ChaChaDance/stop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python

# Import libraries
import rospy
import smach
import time
from geometry_msgs.msg import Twist


# Define the stop state
class Stop(smach.State):
def __init__(self, pub_controls):
smach.State.__init__(self, outcomes=["do_exit"])
self.counter = 0
self.pub_controls = pub_controls

def execute(self, userdata):
rospy.loginfo("Running Stop state")

move_cmd = Twist()
move_cmd.linear.x = 0.0
self.pub_controls.publish(move_cmd)

time.sleep(1)

return "do_exit"
Binary file added ChaChaDance/stop.pyc
Binary file not shown.
Loading