Example program showing use of the original 5DOF P2 arm accessory.Demonstrates how to connect with the Pioneer 2 controller and set up the P2Arm class, including the ARMpac handler. It simply queries and prints the status of the arm, moving it to a position, then exits. Note, The P2Arm class is only for use with the microcontroller-integrated original 5DOF Pioneer 2 arm (Robotica arm). The newer Energid Cyton 7DOF arm is accessed through separate cyton libraries.
#include "Aria.h"
int main(int argc, char **argv)
{
{
return 1;
}
{
return 1;
}
{
return 1;
}
printf("Current joint info:\nJoint Vel Home Center\n");
{
printf(
" %2i: %5i %5i %5i\n", i, joint->
myVel, joint->
myHome, joint->
myCenter);
}
printf("\n");
printf("Powering on (takes a couple seconds to stabilize)\n");
printf("Current arm status:\n");
printf("Arm Status: ");
printf("Good=1 ");
else
printf("Good=0 ");
printf("Inited=1 ");
else
printf("Inited=0 ");
printf("Power=1 ");
else
printf("Power=0 ");
printf("Homing=1 ");
else
printf("Homing=0 ");
printf("\n\n");
printf("Moving Arm...\n");
int deploy_offset[] = {0, -100, 10, 40, 80, -55, 20};
{
arm.
moveToTicks(i, joint->myCenter + deploy_offset[i]);
}
bool moving = true;
while (moving)
{
moving = false;
printf("Joints: ");
{
{
printf("M; ");
moving = true;
}
else
{
printf("NM; ");
}
}
printf("\r");
}
printf("\n\n");
printf("Parking arm.\n");
{
}
printf("Shutting down ARIA and exiting.\n");
return(0);
}
virtual P2ArmJoint * getJoint(int joint)
Get the joints data structure.
Definition: ArP2Arm.cpp:523
@ SUCCESS
Succeded.
Definition: ArP2Arm.h:86
static const int ArmGood
Bit for arm good state in arm status byte.
Definition: ArP2Arm.h:127
@ Terse
Use terse logging.
Definition: ArLog.h:61
Legacy connector for robot and laser.
Definition: ArSimpleConnector.h:51
virtual State park()
Home the arm and power if off.
Definition: ArP2Arm.cpp:671
bool comInt(unsigned char command, short int argument)
Sends a command to the robot with an int for argument.
Definition: ArRobot.cpp:5634
static int NumJoints
Number of joints that the arm has.
Definition: ArP2Arm.h:135
virtual State init()
Init the arm class.
Definition: ArP2Arm.cpp:93
bool connectRobot(ArRobot *robot)
Sets up the robot then connects it.
Definition: ArSimpleConnector.cpp:209
virtual int getStatus()
Get the two byts of status info from P2OS.
Definition: ArP2Arm.h:226
static void exit(int exitCode=0)
Shutdown all Aria processes/threads, call exit callbacks, and exit the program.
Definition: Aria.cpp:367
static void log(LogLevel level, const char *str,...)
Log a message, with formatting and variable number of arguments.
Definition: ArLog.cpp:93
static const int ArmHoming
Bit for arm homing in arm status byte.
Definition: ArP2Arm.h:133
@ StatusSingle
Send a single status packets.
Definition: ArP2Arm.h:110
static const int ArmPower
Bit for arm powered on in arm status byte.
Definition: ArP2Arm.h:131
@ StatusContinuous
Send continous packets. Once every 100ms.
Definition: ArP2Arm.h:111
static void init(SigHandleMethod method=SIGHANDLE_THREAD, bool initSockets=true, bool sigHandleExitNotShutdown=true)
Initialize Aria global data struture and perform OS-specific initialization, including adding OS sign...
Definition: Aria.cpp:128
P2 Arm joint info.
Definition: ArP2Arm.h:37
Central class for communicating with and operating the robot.
Definition: ArRobot.h:82
virtual State requestStatus(StatusType status)
Request the arm status packet.
Definition: ArP2Arm.cpp:224
static void logOptions(void)
Logs all the options for the program (Calls all the callbacks added with addLogOptionsCB())
Definition: Aria.cpp:794
void setRobot(ArRobot *robot)
Set the robot to use to talk to the arm.
Definition: ArP2Arm.h:144
void runAsync(bool stopRunIfNotConnected, bool runNonThreadedPacketReader=false)
Starts the instance to do processing in its own new thread.
Definition: ArRobot.cpp:301
static bool parseArgs(void)
Parses the arguments for the program (calls all the callbacks added with addParseArgsCB())
Definition: Aria.cpp:759
static void sleep(unsigned int ms)
Sleep for the given number of milliseconds.
Definition: ariaUtil.cpp:151
ArP2Arm is the interface to the AROS/P2OS-based Pioneer 2 Arm servers, by means of which the robot mi...
Definition: ArP2Arm.h:80
@ Normal
Use normal logging.
Definition: ArLog.h:62
virtual float getJointPos(int joint)
Get the joints position in degrees.
Definition: ArP2Arm.cpp:504
virtual State powerOn(bool doWait=true)
Power on the arm.
Definition: ArP2Arm.cpp:159
virtual State moveToTicks(int joint, unsigned char pos)
Move a joint to a position in low level arm controller ticks.
Definition: ArP2Arm.cpp:388
virtual bool getMoving(int joint=-1)
Check to see if the arm is moving.
Definition: ArP2Arm.cpp:644
static const int ArmInited
Bit for arm initialized in arm status byte.
Definition: ArP2Arm.h:129