diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 362c149..85959f7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,32 +1,38 @@ // See https://aka.ms/vscode-remote/devcontainer.json for format details. { - "dockerFile": "Dockerfile", - "build": { - "args": { - "WORKSPACE": "${containerWorkspaceFolder}" - } - }, + // "dockerFile": "../Dockerfile.devcontainer", + // "build": { + // "args": { + // "WORKSPACE": "${containerWorkspaceFolder}" + // } + // }, + "image": "irth7/ros2aria-dev", "remoteUser": "ros", "runArgs": [ "--network=host", "--cap-add=SYS_PTRACE", "--security-opt=seccomp:unconfined", "--security-opt=apparmor:unconfined", - "--volume=/tmp/.X11-unix:/tmp/.X11-unix" + "--volume=/tmp/.X11-unix:/tmp/.X11-unix", + "--device=/dev/ttyS0" ], "containerEnv": { "DISPLAY": "${localEnv:DISPLAY}" }, - // Set *default* container specific settings.json values on container create. + "workspaceFolder": "/ws", + "workspaceMount": "source=/home/lab1_5/ros2aria_ws,target=/ws,type=bind,consistency=delegated", "settings": { "terminal.integrated.shell.linux": "/bin/bash" }, + "mounts": [ + "source=ros2aria-dev-bashhistory,target=/commandhistory,type=volume", + ], "extensions": [ "dotjoshjohnson.xml", "laurenttreguier.uncrustify", "ms-azuretools.vscode-docker", - "ms-iot.vscode-ros", "ms-python.python", + "ms-iot.vscode-ros", "ms-vscode.cpptools", "redhat.vscode-yaml", "smilerobotics.urdf", @@ -34,4 +40,4 @@ "twxs.cmake", "yzhang.markdown-all-in-one" ] -} +} \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..cd8b450 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/AriaCoda"] + path = src/AriaCoda + url = https://github.com/reedhedges/AriaCoda diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index e083a4a..13765aa 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -8,7 +8,8 @@ "includePath": [ "/opt/ros/foxy/include/**", "/workspaces/ros2aria/src/ros2aria/include/**", - "/usr/include/**" + "/usr/include/**", + "/usr/local/Aria/include" ], "name": "ROS" } diff --git a/.devcontainer/Dockerfile b/Dockerfile.devcontainer similarity index 61% rename from .devcontainer/Dockerfile rename to Dockerfile.devcontainer index a34445d..5b9b2cc 100644 --- a/.devcontainer/Dockerfile +++ b/Dockerfile.devcontainer @@ -13,5 +13,17 @@ FROM athackst/ros2:foxy-dev # ENV DEBIAN_FRONTEND=dialog # Set up auto-source of workspace for ros user + +COPY ./src/AriaCoda /usr/local/Aria +RUN cd /usr/local/Aria && make -j$(nproc) + ARG WORKSPACE RUN echo "if [ -f ${WORKSPACE}/install/setup.bash ]; then source ${WORKSPACE}/install/setup.bash; fi" >> /home/ros/.bashrc + +ARG USERNAME=ros + +RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \ + && mkdir /commandhistory \ + && touch /commandhistory/.bash_history \ + && chown -R $USERNAME /commandhistory \ + && echo $SNIPPET >> "/home/$USERNAME/.bashrc" \ No newline at end of file diff --git a/build_devcontainer.sh b/build_devcontainer.sh new file mode 100644 index 0000000..4a269e0 --- /dev/null +++ b/build_devcontainer.sh @@ -0,0 +1,3 @@ +#!/bin/sh +docker build --build-arg WORKSPACE=/ws -f Dockerfile.devcontainer -t irth7/ros2aria-dev . + diff --git a/src/AriaCoda b/src/AriaCoda new file mode 160000 index 0000000..4f60425 --- /dev/null +++ b/src/AriaCoda @@ -0,0 +1 @@ +Subproject commit 4f60425ef757bdd9c4e077c65d1c80665a2b33d6 diff --git a/src/ros2aria/CMakeLists.txt b/src/ros2aria/CMakeLists.txt index 0f92bfb..021ef11 100644 --- a/src/ros2aria/CMakeLists.txt +++ b/src/ros2aria/CMakeLists.txt @@ -21,10 +21,14 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) + add_executable(ros2aria src/ros2aria.cpp) target_include_directories(ros2aria PUBLIC $ - $) + $ + /usr/local/Aria/include) + +target_link_libraries(ros2aria /usr/local/Aria/lib/libAria.so) install(TARGETS ros2aria DESTINATION lib/${PROJECT_NAME}) diff --git a/src/ros2aria/src/ros2aria.cpp b/src/ros2aria/src/ros2aria.cpp index 1906f0f..aab96fb 100644 --- a/src/ros2aria/src/ros2aria.cpp +++ b/src/ros2aria/src/ros2aria.cpp @@ -1,10 +1,46 @@ #include -int main(int argc, char ** argv) +#include "Aria/Aria.h" + +int main(int argc, char **argv) { - (void) argc; - (void) argv; + (void)argc; + (void)argv; printf("hello world ros2aria package\n"); + ArRobot *robot = new ArRobot(); + + ArArgumentBuilder *args = new ArArgumentBuilder(); // never freed + ArArgumentParser *argparser = new ArArgumentParser(args); // Warning never freed + argparser->loadDefaultArguments(); // adds any arguments given in /etc/Aria.args. Useful on robots with unusual serial port or baud rate (e.g. pioneer lx) + args->add("-robotPort /dev/ttyS0"); // pass robot's serial port to Aria + // args->add("-robotLogPacketsReceived"); // log received packets + // args->add("-robotLogPacketsSent"); // log sent packets + args->add("-robotLogVelocitiesReceived"); // log received velocities + args->add("-robotLogMovementSent"); + args->add("-robotLogMovementReceived"); + ArRobotConnector *conn = new ArRobotConnector(argparser, robot); // warning never freed + if (!conn->connectRobot()) + { + printf("RosAria: ARIA could not connect to robot! (Check ~port parameter is correct, and permissions on port device, or any errors reported above)\n"); + return 1; + } + robot->runAsync(true); + sleep(3); + printf("Enabling motors\n"); + robot->enableMotors(); + + printf("Enabled motors\n"); + robot->setVel(2); + robot->move(500); + + sleep(10); + + robot->move(-500); + sleep(2); + conn->disconnectAll(); + + return 0; + return 0; }