2 * rectangle.cc 07/08/01
4 * Movement test: move in a rectangle.
6 * Copyright: (c) 2007 CTU Dragons
7 * CTU FEE - Department of Control Engineering
12 #include <movehelper.h>
20 UL_LOG_CUST(ulogd_rectangle); /* Log domain name = ulogd + name of the file */
22 FSM_STATE_DECL(rectangle);
27 /* Where we are at the begining? */
33 FSM_TRANSITION(rectangle);
34 robot_set_est_pos_trans(0.5, 0.5, DEG2RAD(0));
41 void follow_rectangle()
43 double rectangle[][2] = { { 0.5, 0.5 },
47 static bool backward = false;
48 struct TrajectoryConstraints tc = trajectoryConstraintsDefault;
54 /* Allocate new trajectory */
56 robot_trajectory_new(&tc);
58 robot_trajectory_new_backward(&tc);
61 for (i=0; i<sizeof(rectangle)/sizeof(rectangle[0]); i++) {
62 if (!backward) j=(i+1)%4;
65 robot_trajectory_add_point_trans(rectangle[j][0], rectangle[j][1]);
67 robot_trajectory_add_final_point_trans(rectangle[j][0], rectangle[j][1], TURN(0));
70 //backward = !backward;
80 //FSM_TRANSITION(turn);
92 robot_trajectory_new(NULL);
93 robot_trajectory_add_final_point_trans(1, 0.5,
94 TURN_CCW(DEG2RAD(0)));
110 FSM_TRANSITION(rectangle);
117 void transition_callback(struct robo_fsm *fsm)
119 ul_loginf("fsmcb %s: %s(%s)\n", fsm->debug_name, fsm->state_name, fsm_event_str(fsm->events[fsm->ev_head]));
129 if (rv) error(1, errno, "robot_init() returned %d\n", rv);
131 //robot.fsm.main.transition_callback = transition_callback;
132 //robot.fsm.motion.transition_callback = transition_callback;
133 //robot.fsm.main.debug_states = 1;
134 robot.fsm.motion.debug_states = 1;
136 robot.fsm.main.state = &fsm_state_main_init;
139 if (rv) error(1, errno, "robot_start() returned %d\n", rv);